RhinoScriptSyntax in Python
This guide provides an overview of the RhinoScriptSyntax in Python.
The RhinoScriptSyntax methods library contains hundreds of easy-to-use functions that perform a variety of operations on Rhino. The library allows Python to be aware of the Rhino’s:
- Document objects
- Application methods
To make these methods easy-to-use, all RhinoScriptSyntax methods return simple Python variables or Python List-based data structures. Thus, once you are familiar with Python, you will be able to use any and all functions in the RhinoScriptSyntax methods library.
Before using RhinoScriptSyntax a line must be added to the top of each Python file to allow access to the RhinoScriptSyntax:
import rhinoscriptsyntax as rs
import above not only imports the library, but also renames the namespace to
rs.. This is done to just make it easier to type when accessing the methods in RhinoScriptSyntax. Access the methods can now be made by starting methods with ‘rs.’. For example, accessing the
AddCircle() method in the RhinoScriptSyntax namespace can be used to create a circle:
import rhinoscriptsyntax as rs centerpoint = [1, 2, 4] rs.AddCircle( centerpoint, 5.0 )
Rhino is a 3D modeler, therefore creating and modifying geometry is key to developing in Rhino. Here are the primitive geometry types of Rhino:
Creating, accessing and manipulating geometry is one of the first places RhinoScriptSyntax is used. Simple geometry such as points, lines, planes can be described with simple lists in Python. More complicated geometry objects such as NURBS curves, Surfaces and Poly-surfaces can be created by Rhino and referenced by an object ID by RhinoScriptSyntax.