Hello
When i use rs.Add… everything baked and added to Rhino , how to solve that?
helix.gh (8.6 KB)
switch back to grasshopper document before you call the “add” methods
try something like sc.doc = ghdoc
Thank you work fine, i will test it with hatch
Sadly when compile to ghpy component there is a problem with ghdoc and ghenv
I choose rhino geo to create the spiral
in the python dev mode you can switch back and forth with the following
I did these in the beginning:
import Rhino as rh
import scriptcontext as sc
in case you wonder what those are
Thanks i will try this
Yes i know
I don’t know what you are running though. What are you doing with the x, y and z?
That is a generic error when you have variables point to things non-existing.
X,Y,Z have no relation with this, ghdoc and RhinoDoc works fine, if you print ghdoc and GhPython.DocR…
You can see that they are not the same.
Did you try it and worked for you?
X is curve
Y is point
Z is float
What I meant was there might be something else in your code that’s causing the error. I couldn’t see how you are calling those variables. Please post a snippet.
if you just need to make a component that creates spirals you can do this without all the doc switching
class Spiral(component):
def RunScript(self, P, D, S, T,R0, R1):
if not P: P = (0,0,0)
if not D: D = (0,0,1)
if not S: S = 1
if not T: T = 1
if not R0: R0 = 1
if not R1: R1 = 1
c = rs.AddSpiral(P,D,S,T,R0,R1)
return c
make sure you are in the SDK dev mode
As i posted before i find another way because rs.Add… always bake curves or solids … if sc.doc used in any different script even if it is compiled to ghpy.
But if i find another solutions this will be always good
and the code is very simple
test.gh (6.4 KB)
I don’t quite follow.
In general, yes, you’d want to be careful changing the scope of the script. Whenever you do sc.doc=
it should be flagged as a potential “loose end”.
Better suggestion is to use RhinoCommon directly
For example rs.OffsetCurve
has its equivalent here
rs.coercecurve
because the method is called from a Curve
object
Thanks , yes that what i did and if ghenv and ghdoc can compiled this will be better