Hello
I am Trying to run and return the result of Hydrostatics with python
I have found it with vb but nothing with python
Any more comand list than
http://4.rhino3d.com/5/ironpython/index.html
thank you
Hello
I am Trying to run and return the result of Hydrostatics with python
I have found it with vb but nothing with python
Any more comand list than
http://4.rhino3d.com/5/ironpython/index.html
thank you
Nobody!
We can not make the comand Hydrostatics with python Code ?
I believe the best you can do is script the Hydrostatics command using rs.Command
.
@steve, is this correct?
I have tried this
but nothing work
import rhinoscriptsyntax as rs
pts = rs.GetObject("Select Object for Hydrostatics")
rs.Command("Hydrostatics")
rs.Command("Enter")
rs=Hydrostatics[0]
print rs'
```'
Message: name 'Hydrostatics' is not defined
try:
import rhinoscriptsyntax as rs
pts = rs.GetObject(“Select Object for Hydrostatics”)
rs.command("-_Selnone _Hydrostatics _pause _enter")
dont; use rs=Hydrostatics[0] because Hydrostatics[0] isn’t defined or anything. rs.command starts a “script”.
Using the rs.Command is a way of scripting inputs into the command line like you would without python. Once you run Hydrostatics you must “select the object”. You can do this by adding the commands “selid” then feed the guid of the object into the command line.
it should look something like this:
import rhinoscriptsyntax as rs
pts = rs.GetObject("Select Object for Hydrostatics")
rs.Command("Hydrostatics " + "selid " + str(pts) + "_Enter ")
thank wattzie
it is working
But is i understand there is no way to get back the result in python, to use it for something else
hope you understand what i mean
thank you
If you use the hyphenated command _-Hydrostatics then you get several options for the output. Use Clipboard or File which you can parse then.
Thank jess
but i need to keep the data inside python
In your system:
i can for exemple
record the data into the txt file
then i will need to read it again with python to extract the data i need to use in the script…
just a bit complicated
If you don’t mind the clipboard you can do something like the following script (works with pre-selected valid input for the _Hydrostatics command):
#Works with a preselected Surface or Polysurface
import Rhino
import System.Windows.Forms.Clipboard
def cmdHydrostatics():
cmd = "-_Hydrostatics _WaterlineElevation=0 _Symmetric=_No "
cmd +=" _Longitude=X _Enter _Clipboard"
rc = Rhino.RhinoApp.RunScript(cmd, False)
if rc:
if System.Windows.Forms.Clipboard.ContainsText():
text = System.Windows.Forms.Clipboard.GetText()
lines = text.splitlines()
for line in lines:
keyVal = line.split("=")
if keyVal[0].strip() == "Center of Buoyancy":
sc = "_-Dot " + "CB w" + keyVal[1].replace(" ","")
rd = Rhino.RhinoApp.RunScript(sc, False)
elif keyVal[0].strip() == "Center of Floatation":
sc = "_-Dot " + "CF w" + keyVal[1].replace(" ","")
rd = Rhino.RhinoApp.RunScript(sc, False)
return text
return rc
if __name__ == '__main__':
rc = cmdHydrostatics()
if rc == False:
print "Failed to calculate Hydrostatics!"
else:
print rc
Thank you jess, it is working