Thank u Piac That helped but i couldn’t get it running on Grasshopper . I m guessing that points should be baked from gh to active document and get points from document … or is there any way ???
import rhinoscriptsyntax as rs
import math
a= rs.command("_MeshfromPoints",True)
is something i ran on rhino py console… donno why py gh didnt work …
Oh you want that in Grasshopper. I just did a quick search and Tudor already wrote that script, maybe not in Python, but it should work as advertised. If you want to translate it to Python, it should also be possible.
Here is my generic sample for generating solids with a text object. There are a LOT of command line options and you do need to have them in the right order. --Mitch
import rhinoscriptsyntax as rs
def CreateTextObjsAsSolids():
text_string=rs.GetString("Text to insert?")
if not text_string: return
pt=rs.GetPoint("Text insert point?")
if not pt: return
ht=rs.GetReal("Text height?",minimum=0)
if not ht: return
thk=rs.GetReal("Solid thickness?",minimum=0)
if not thk: return
opts='_GroupOutput=_Yes _FontName="{}" _Italic=_No _Bold=_No '.format("Cambria")
opts+='_Height={} _Output=_Solids _Thickness={} '.format(ht,thk)
opts+='_LowerCaseAsSmallCaps=_No _AddSpacing=_No '
rs.EnableRedraw(False)
rs.Command('_-TextObject '+opts+'"'+text_string+'"'+' '+str(pt),True)
CreateTextObjsAsSolids()
that is a macro. You can read about macros in the RhinoScript 101 PDF: http://wiki.mcneel.com/developer/rhinoscript101
These are just the options that end up being written in the command line when you run a command. The hyphen sign (or minus) “-” is used to trigger the no-dialog version of the command. Please read more in the Rhino Help, under macro, or in the PDF above.
I read about macros in “http://wiki.mcneel.com/rhino/basicmacros”, but it also did not tell me where I can look up which arguments a macro needs/accepts.
Like I asked, how can I see in advance that the macro _TextObject has _Bold=_No as argument?
But this did not gave me a list of which arguments the macro '_GrasshopperOpen' accepts…
I need to open a certain GH-file with '_GrasshopperOpen' and additionally perform a Grasshopper Bake on a Rhino geometry…
Type in “_-GrasshopperOpen” in the command line, you’ll see what I mean…
This does NOT give me the list of arguments this macro accepts, there appears another command line which says:
" GH or GHX file to open:
"
I want to automatically start a certain GH-file with Grasshopper without being asked by Rhino…
Additionally I want to see, if this "_-GrasshopperOpen"-macro accepts additional arguments, as I need to perform operations with GH on a brep with has been created in Rhino, and I want to “hand over” this brep automatically to GH
You inquired about “TextObject”. This request about _GrasshopperOpen would make a good start of a new discussion.
Trying to automate Grasshopper from within a Grasshopper solution, while possible, opens several levels of issues. Be sure that you really know why you need this. The “_GrasshopperOpen” command simply accepts an argument without an option. This means that you are forced to put that one option there, and there are no additional options to call after that.
It’s possible in other cases that a developer intentionally adds hidden commands or command options. It is not possible to know which ones exist, or how to invoke them, unless the developer reveals them. In this case, there are no command options to call (that I know of).
Please start a new discussion if you need help regarding a specific command macro.
Well, you might imagine there are close to 1000 Rhino commands. That would require writing a ~1000 page documentation… Best is just to run the command with a dash and look at the arguments. --Mitch
regardless of these Grasshopper operations working correctly (for me they do not…no holes are punched in the solid), your post is really great. This is exact the “data handover” from rhino to grasshopper I need!
I will apply your example to my specific application case
Yeah sorry, i’ve just quickly hacked this together. If the solid object you select in Rhino is a 10x10x10 cube or sphere with diameter 5 it should work. Otherwise you can change the cylinder_height, either from within the script or in gh.
good. Btw. one thing about passing the name of the *.gh file i´ve forgotten: If the file path to this *.gh file or the filename itself has spaces within, you better load it using this line: