I just updated to the Rhino version in the subject line, and it looks to me like args to rhinoscriptsyntax.Command() running under Python are broken. I whipped up a small demo script below and pasted in the script output from the command window. I am pretty sure that this exact syntax was working before the newly installed release. Anybody else seeing this? Is there a way to back out a Rhino update so I can check if the new release is the problem?
Thanks,
Craig
#-------------------------------------------------------------------------------------------------------------
import rhinoscriptsyntax as rs
def main():
# Make a test shape
shape = rs.AddCylinder([0,0,0],20,20)
# Commands using previously selected objects
rs.SelectObject(shape)
rs.Command(“-ReduceMesh _ReductionPercentage 20 _Accuracy 10 -Enter”)
rs.SelectObject(shape)
rs.Command(“-Smooth _SmoothFactor 0.5 -Enter”);
# Commands using SelID and the object ID
rs.Command(“-ReduceMesh _SelID " + str(shape) + " _ReductionPercentage 20 _Accuracy 10 -Enter”)
rs.Command(“-Smooth _SelID " + str(shape) + " _SmoothFactor 0.5 -Enter”);
return
main()
#-------------------------------------------------------------------------------------------------------------
Script output:
Creating meshes… Press Esc to cancel
( Debugging=Off ): -ReduceMesh
Select meshes: _ReductionPercentage
Unknown command: _ReductionPercentage
Select meshes: 20
Unknown command: 20
Select meshes: _Accuracy
Unknown command: _Accuracy
Select meshes: 10
Unknown command: 10
Select meshes: -Enter
Select meshes:
Command: -Smooth
Select objects to smooth: _SmoothFactor
Unknown command: _SmoothFactor
Select objects to smooth: 0.5
Unknown command: 0.5
Select objects to smooth: -Enter
Select objects to smooth:
Command: -ReduceMesh
Select meshes: _SelID
Object ID to select: b7374db5-a9f8-4000-822e-fc18dad2e34e
No objects added to selection.
Select meshes: _ReductionPercentage
Unknown command: _ReductionPercentage
Select meshes: 20
Unknown command: 20
Select meshes: _Accuracy
Unknown command: _Accuracy
Select meshes: 10
Unknown command: 10
Select meshes: -Enter
Select meshes:
Command: -Smooth
Select objects to smooth: _SelID
Object ID to select: b7374db5-a9f8-4000-822e-fc18dad2e34e
No objects added to selection.
Select objects to smooth: _SmoothFactor
Unknown command: _SmoothFactor
Select objects to smooth: 0.5
Unknown command: 0.5
Select objects to smooth: -Enter
Select objects to smooth:
Hi @Craighyattusa,
i´m shure this is not related to the update from SR11 to SR12. I´ve tested it in SR11. This line:
shape = rs.AddCylinder([0,0,0],20,20)
creates a capped solid cylinder, which is a polysurface. You then select this polysurface and call _ReduceMesh
which unselects the shape because this command expects a mesh object. If you look at your command output, you see that once you start _ReduceMesh
it asks for a mesh in this line, where you are trying to pass multiple command options:
Select meshes: _ReductionPercentage
...
The same happens later, you select the polysurface and start the _Smooth
command. The _Smooth
command does not work with polysurfaces, so _Smooth
unselects the cylinder and asks to select a different object, where you again pass various command options.
c.
Man, good catch! I converted to a mesh and retried my scenario. I think something about the syntax has changed in the latest Rhino release. Even though I forgot to make a mesh object in my original post, the commands in the original post are cut/pasted from code that’s been working for months. That being said, I managed to fiddle around until I got it working, and I pasted the working script below. Several things I changed were:
- If I passed SelID, I had to deselect all of the meshes, otherwise command tried to use SelID as the next argument and bombed.
- When I used _SelID, I moved an _Enter between it and the following argument, and that seemed to fix a problem with skipping args.
- I removed all of the equal (=) signs.
- I changed all the dashes (-) to underscore (_).
Thanks so much for the help!
Craig
import rhinoscriptsyntax as rs
def main():
Clean up the screen
rs.DeleteObjects(rs.AllObjects())
Make a test shape
cylinder = rs.AddCylinder([0,0,0],20,20)
rs.SelectObject(cylinder)
rs.Command("-Mesh -Enter")
shape = rs.LastCreatedObjects()[0]
rs.DeleteObject(cylinder)
Commands using previously selected objects
print “111111111111111111111111111111111111111111111111111111111111"
rs.SelectObject(shape)
rs.Command(”-ReduceMesh _ReductionPercentage 20 _Enter")
print “222222222222222222222222222222222222222222222222222222222222"
rs.SelectObject(shape)
rs.Command(”-Smooth _SmoothFactor 0.5 _Enter");
Commands using SelID and the object ID
print “333333333333333333333333333333333333333333333333333333333333"
rs.Command(”-SelNone _Enter")
rs.Command("-ReduceMesh _SelID " + str(shape) + " _Enter _ReductionPercentage 20 _Enter")
print “444444444444444444444444444444444444444444444444444444444444"
rs.Command(”-SelNone _Enter")
rs.Command("-Smooth _SelID " + str(shape) + " _Enter _SmoothFactor 0.5 _Enter");
return
main()