algorithmic modeling for Rhino
I am very new at this, so please be gentle... ;)
I have created a GH definition which is basically just a series of extrusions and boolDiffs. What I'd like to do is create a button on my toolbar that prompts me to "Select First Curve," "Select Second Curve," etc.
I have created the following Python script inside the Python GH component:
*****
import rhinoscriptsyntax as rs
# Boolean Genie
left = rs.GetCurveObject("Select Left Hole")
right = rs.GetCurveObject("Select Right Hole")
outside = rs.GetCurveObject("Select Outside")
print left[0]
print right[0]
print outside[0]
*****
Which seems to run fine in the Rhino Python editor, but in the GH component I get a Runtime Error (Method or operation is not implemented: line 130, in GetCurveObject...)
Am I going about this correctly? I really just want to automate the first 3 "Set One Curve" operations - maybe I'm over-complicating things?
Thanks in advance...
Declan
Tags:
Hi Declan,
When using Rhino.Python you are targeting either the Rhino document OR the Grasshopper document. The errors you are experiencing are caused by using Rhinoscriptsyntax functions which target the Rhino document inside a Grasshopper component.
Now, you can switch between which document to target by importing the "scriptcontext" and setting this manually (see the attached files and the "Change Script Context" example).
However....
..when using Python inside Grasshopper component you will probably want to input the geometry in the conventional GH style. That is, referencing Rhino geometry using parameters and then feeding that into the component (see the examples "Pick Individual Curves" and "Pick multiple Curves").
It should also be noticed that I passed the geometry along as GUIDS, but you can also set a type hint (right the input -> Type Hint) directly on the inputs which will pass the geometry along a objects instead (curve, mesh, polyline etc.)
Hope that helps.
/Anders
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by