I have 2 ghpython, I hope they can work together after compile. Tried to get the object’s name in RhinoDoc.
No error before I compile it.
But after compile into component it get error: Solution exception: global name “ghdoc” is not defined.
It seems that can’t recognize ghdoc after compile.
Here’s the code and original file.
GHpython 1:
class MyComponent(component):
def RunScript(self, ):
def getIDName(ID):
sc.doc = Rhino.RhinoDoc.ActiveDoc
try:
obj = sc.doc.Objects.Find(ID)
name = obj.Attributes.Name
sc.doc = ghdoc
return name
except:
sc.doc = ghdoc
return None
sc.sticky["getIDName"] = getIDName
return
GHpython 2:
class MyComponent(component):
def RunScript(self, x, y):
a = sc.sticky["getIDName"](x)
return a
ObjectName.3dm (55.4 KB)
ObjectName.gh (8.3 KB)