Use the “dash” version of the command - as in _-TextObject. Run the command with a dash first in Rhino to see all the command line options, then use those (copy/paste from command history) in your script to help create your command string for rs.Command().
Edit: for the insertion point in the command string you will need to convert a 3d point into a string. With Python you can actually just use str(pt) where pt is the 3d point
It’s actually somewhat complicated to set up, so below is an example… The extra quote marks around the text string is to accommodate text with spaces in it - otherwise you will only get the first word. The order in which you pass the command line arguments is critical.
Thanks Mitch, this was extremely helpful! However, I’m still having some trouble getting this implemented.
When I try to run your example code (replacing GetPoint, GetReal arguments with real values), Rhino seems to get confused when it comes to unnamed arguments - I get an interactive dialog where RunPythonScript is asking me to provide a value for “Text to insert?” -
PS Is there a Rhino reference online where I can look at the arguments for different functions? The OSX version doesn’t show arguments like Windows does.
Currently, the getString, getPoint, and getReal functions are acting interactive, even though I’m providing a value (they all prompt for a value.) Regardless of whether I input a value in the interactive box or not, none of the values get passed. No point gets chosen, the height is always the same, and the text is whatever I used for the last TextObject call.
Ahh, you can’t really do that. You would of course need the Help to see what each of these methods wants for arguments and in what order.
If you want to bypass the user input and specify a text, a height and an insert point directly, you don’t use these methods, you set them directly something like this:
import rhinoscriptsyntax as rs
text_string="nnnn"
ht=12.0
pt=rs.coerce3dpoint([0,0,0])
#etc.
Unfortunately, this is normal - it simply looks like the dash version of -TextObject has not been fully implemented in Mac Rhino - there are no command line options other than the insertion point as there are in Windows Rhino. All other parameters are taken from those which are last set when you run TextObject (without the dash). In Windows Rhino your script runs.
Sorry, I didn’t realize that this had not been done, it’s only recently that we have had a TextObject command that works at all on Mac… There is a bugtrack item for this:
Similar situaton. I use Command(“meshIntersect"), which ask for picking up intersection meshes in the Rhino5 viewport. And I tried to use "-meshIntersect” to see all the command line options, however in Rhino5, there is no command line options displayed for it.
so… how can I do for passing intersection mesh to python instead of picking them in Rhino5?
That’s because there are no options for this command…
I am not sure what you need here - you are looking for the rhinoscriptsyntax equivalent of MeshIntersect? There is rs.MeshMeshIntersection() which returns the intersection of two mesh objects. Otherwise you can script rs.Command(_MeshIntersect)
What Im trying to do is instead of picking meshes in Rhino5, I want rs.Command(“_meshIntersect(meshFromInputParametricModels)”). So I dont have to pick up mesh in Rhion5 and always stay in GH.
So this is a Grasshopper question? Grashopper has a Mesh/Mesh intersection component which you can use with Grasshopper geometry. As far as programming Rhino native commands inside a Python component in Grasshopper, I don’t really know how to do that correctly - maybe post that question in the Grasshopper section of the forum.
ahh yeah… I use Python in GH as a rookie.
Recently found rs.Command() function and thought it is so powerful.
so…the question is more about how far the rs.Command() could do even I understand we could do the function by MeshMeshIntersection. you know, just want tweak it bit more:P
Thanks so much for your help as always.
And I was wondering if there is a more detailed introduction about rs.Command(), which, at least I think, could discuss about how and what kind of commands in Rhino5 could take arguments inside rs.command(“commands”).
I would highly advise against going down this path (i.e. scripting macros), and instead start out with the rhinoscriptsyntax Python module or jump directly to the RhinoCommon API. For your case have a look at these methods: