Hello,
I have an issue simply trying to offset a curve in Python. It seems al right, but I can’t see or bake the result. I link the gh file.
Thanks for helping,
Roy
python offset a curve issue.gh (6.0 KB)
Hello,
I have an issue simply trying to offset a curve in Python. It seems al right, but I can’t see or bake the result. I link the gh file.
Thanks for helping,
Roy
python offset a curve issue.gh (6.0 KB)
Thanks a lot!
May I ask You to elaborate a little bit on why I need to add that line and why I can’t find it in RhinoScriptSyntax?
rhinoscriptsyntax
is meant to be used in Rhino. It’s basically a wrapper library for RhinoCommon. It is meant to make scripting in Rhino easier with a functional programming approach, instead of an object oriented one, but when used in Grasshopper, introduces a couple of inconveniences, like the one you encountered.
rs.OffsetCurve
returns a reference - a unique identifier or GUID - to a geometry object in the Rhino viewport, here an offset curve. These unique identifiers are how rhinoscriptsyntax
passes data around without having to make copies for everything all the time and keeps track of what’s been created, but Grasshopper doesn’t necessarily know how to handle this reference.
In Grasshopper, it’s best to familiarize yourself with RhinoCommon
and object oriented programming:
import Rhino.Geometry as rg
a = x.Offset(rg.Plane.WorldXY, 100, 0.001, rg.CurveOffsetCornerStyle.Smooth)
For this to work, you need to set the Type hint of your x input to Curve. You’re thus declaring to input an object of type Rhino.Geometry.Curve, which is what object oriented programming is about.
Thanks again!
I’ve tried your method, but it seems there is the same issue (it works, but I can’t see the result in Rhino)
I’ve tested the code before posting it and it worked fine in Rhino 7. I can’t really inspect you file, because I haven’t upgraded to Rhino 8 yet.
ok, thanks anyway