I am having lots of trouble converting grasshopper functions into python scripts. I am using the python script module in grasshopper, and I am confused about whether to use rhinoscriptsyntax or RhinoCommon. For instance, I use silhouette = meshIn.GetOutlines(viewPort) to get a “silhouette” polyline curve. From there, I want to divide that curve. However I can’t do points = rs.DivideCurve(silhouette, segments), because I get an error that says "Parameter must be a Guid or string representing a Guid).
The problem with RhinoCommon is different but equally problematic. First off, the .GetOutlines command returns an object called Array[Polyline] which makes it seem as though I cannot do any of the RhinoCommon commands, include Polyline.GetSegments(silhouette). However if I just plug the output of my python script (silhouette) into the divide curve module in grasshopper, it works fine! So what am I doing wrong here? How do I turn the following grasshopper workflow:
How do I initialize the Rhino.Rhinodoc.Activedoc script context? I start my python scripts with:
from Rhino.Geometry import *
from Rhino.Input import RhinoGet
from Rhino.Commands import Result
from Rhino.DocObjects import ObjectType
import rhinoscriptsyntax as rs
from scriptcontext import doc
I wrote " import scriptcontext as sc " and then “sc.doc = Rhino.RhinoDoc.ActiveDoc
for poly in Silhouette:
parameters = poly.ToNurbsCurve().DividebyCount(30,True)”
But now some of my previous functions are not working. For instance I used to have a line that said “silhouette = meshIn.GetOutlines(viewPort)” and worked fine. Now I get an error on that line saying object has no attribute GetOutlines. So I can’t simply switch back and forth?
I print the variable “silhouette” and the output is Array[Polyline]. But then I put that output into the script on the right and when I print silhouette, I get a Guid!!! From there I can modify points using functions like rs.DivideCurve(), but all the points from that function print out as Rhino.Geometry.Point3d when I just want a Guid to be printed. Am I completely off the mark here? How do I keep the format of objects as guid’s so that I can just use rhinoscriptsyntax the whole time?