Python scrpting and solids

Hi, I am new to Rhino scripting, was not able to find a way to extrude solids (i.e. from planar curves) like I can from menus. Is it possible?
In general, can I expect that anything possible from UI should be possible from python script?

What you will find is that the “native” rhinoscriptsyntax methods are more basic than the commands available via the main Rhino interface like Extrude. In order to get the same functionality, you will often need to code more than just one function. Concerning Extrude, for curves, you have ExtrudeCurve() which takes a path curve for the extrusion, and ExtrudeCurveStraight() which takes a direction vector. Neither one will make a “solid”, if the input curves are planar, you can use CapPlanarHoles() on the result of the extrusion. Otherwise, there is ExtrudeSurface(), this is the only method that has the direct possibility to cap or not, but you need to start with a surface, not a curve.

The answer is yes and no… You can script pretty much any regular Rhino command as if you were typing it at the command line with rs.Command("command string") - the command string being whatever you might input on the command line with all the appropriate options etc. You can even run your script and call an rs.Command() somewhere inside which will temporarily return you to the normal Rhino environment and allow you to interactively do something like extrude an object, then return to executing the rest of the script.

If you stick to “native” rhinoscript methods, you can still do pretty much anything, but generally you have to build your script out of smaller, lower-level building blocks. Rhinoscriptsyntax methods also lack much of the graphic UI built-in to normal Rhino commands, in general you only have UI for things like picking objects, etc.

Hope this answers your question…


1 Like

Here’s an example of how to use rs.Command to make an extrusion, this extrudes 2 closed curves into a solid.

                        rs.Command('NoEcho _ExtrudeCrv _selid ' + str(Gear[0]) +
                        ' _selid ' + str(Gear[1]) +
                        ' _Cap=_Yes _Enter ' + str(GearSpecs['Thickness']) + ' _Enter')

The 2 curves are selected with _selid ’ + str(crv)

While debugging you might want to remove the NoEcho so you can see what’s going on.


You can also use the optional second argument in rs.Command() to turn off the “echo” -

rs.Command("Command string", False)

True(or no argument)=Echo, False=NoEcho


Thanks Mitch, that’s a lot more useful way.


Thanks, guys, this is great info.
I use Rhino for organic modeling, and OpenScad for parametric design. Was hoping to just use the Rhino in my workflow, but I must admit, Rhino scripting ‘philosophy’ feels more like a way to automate some repetitive tasks or make parts like gears, not to model end to end.

Have you looked at Grasshopper?


That is essentially correct. You can’t really “model” with scripts, they simply are ways to create custom specialized tools to automate or extend Rhino’s normal modeling capabilities. I guess I shouldn’t say “can’t”, there are people out there that are creating entire buildings and other things via scripting and Grasshopper (visual scripting), but that requires a lot of time and effort acquiring the skills to do so… Grasshopper can make Rhino modeling somewhat “parametric”, but it’s not a direct interface, you’re still doing a form of programming…


Hi Mitch FYI OpenSCAD is not at all like Solidworks or any other solid modeler.
Take a look at this

Ahh, OK, looks like a scripting interface as well, maybe just that it updates in real-time like Processing. In which case I think Grasshopper would be a much more interesting way of working.

Thanks Mark, --Mitch

1 Like