Scripting -Splop


#1

I’m looking for some guidance in being able to script the Splop command.

So far my process is to:

  1. generate my surface using rhinocommon methods
  2. generate the text by scripting -TextObject (since this is the easiest way to generate solid text breps – rhinocommon doesn’t fully expose this yet)
  3. Select the newly generated text breps
  4. 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!


#2

Well, unlest you’re intent on being “purist” about it I would just import rhinoscriptsyntax and use rs.UnselectAllObjects() to unselect everything and rs.ObjectsByLayer(‘body’) to get the object on the body layer…

–Mitch


#3

The problem isn’t so much as being able to the select the objects with rhinocommon or rhinoscript, it’s that the script hangs after sending the splop command while it “waits” for objects to be selected – making it impossible (at least it seems) to have code select the objects after the splop command has been sent.


(Dale Fugier) #4

If you are using Rhino 5 SR9, use Rhino.Geometry.Morph.SplopSpaceMorph…


#5

What perfect timing. Happy to see this make its way into Rhinocommon! Thanks, Dale.