I’m looking for some guidance in being able to script the Splop command.
So far my process is to:
- generate my surface using rhinocommon methods
- generate the text by scripting -TextObject (since this is the easiest way to generate solid text breps – rhinocommon doesn’t fully expose this yet)
- Select the newly generated text breps
- Run -Splop on the selected text and provide the appropriate inputs
I’m running into a snag when Splop asks to select the surface to plop the text onto.
My code is below:
# Adding the body happens above, not shown here
layer = sc.doc.Layers.Find('Text', True)
sc.doc.Layers.SetCurrentLayerIndex(layer,True)
# Add the text object
cmd = []
cmd.Add('-_TextObject')
cmd.Add('_GroupOutput=Yes')
cmd.Add('_FontName=Arial')
cmd.Add('_Italic=No')
cmd.Add('_Bold=Yes')
cmd.Add('_Height={}'.format(textHeight)) # this is the letter height
cmd.Add('_Output=Solids')
cmd.Add('_Thickness=1') # this is the extrude height
cmd.Add('_AddSpacing=No')
cmd.Add(\""Hello World\"")
cmd.Add('0,-20,0')
cmd.Add('Enter')
sendCmd = ' '.join(cmd)
rs.Command(sendCmd,False)
objTable = sc.doc.Objects.FindByLayer('Text')
for o in objTable:
if o.IsSelectable() and o.IsSelected(False) == 0:
o.Select(True)
cmd = []
cmd.Add('-_Splop')
cmd.Add('0,{},0'.format(-20+textHeight/2)) # this is the center of the sphere
cmd.Add('10') # this is the radius of the sphere
sendCmd = ' '.join(cmd)
rs.Command(sendCmd,False)
# HOW DO I SELECT THE SURFACE HERE? The attempts below don't seem to get executed because the script is waiting for input from the user
print "Never got here"
# Unselect the text (doesn't work)
for o in objTable:
if o.IsSelectable() and o.IsSelected(False) == 0:
o.Select(False)
# Select the body surface (doesn't work)
objTable = sc.doc.Objects.FindByLayer('Body')
for o in objTable:
if o.IsSelectable() and o.IsSelected(False) == 0:
o.Select(True)
If I run the body select by itself, it works fine – so I know my selection criteria is fine. However, when I run the select method during the splop command process it doesn’t seem to work – the body doesn’t get selected and the command line still asks for a surface input. Is there a way to send the surface selection at the same time as the rest of the splop commands? I’m assuming that I’m just misunderstanding how the commands are sent/processed.
Is there documentation for what parameters each Rhino command takes besides typing the command into itself? (That’s how I figured out how to use -TextObject), but with methods like Splop, it can be a little more involved than setting a few parameters.
Thanks!