Simply looking for a quick way to bake active dimension and text components. Found an example, but cannot get it to work.
The error i’m getting is:
Error: Runtime error (UnboundNameException): name ‘Comp_type’ is not defined
line 32
#imports
import Grasshopper as gh
import Rhino as rc
import ghpythonlib.components as comp
from System import *
from System.Collections.Generic import *
import System.Collections
if active == True:
#Active Rhinodoc
rcdoc = rc.RhinoDoc.ActiveDoc
#Active GH document
my_ghdoc = ghenv.Component.OnPingDocument()
attr =rc.DocObjects.ObjectAttributes()
# Bake the dimensions in the specified layer called Dimensions
#if it doesn't exist it used the default
attr.LayerIndex = rcdoc.Layers.Find(L,True)
# Iterate the active objects in the current GH file and find the one of the specific type
#if there are many look for the one with the name
objs = []
obj_types = []
for obj in my_ghdoc.ActiveObjects():
my_type = obj.GetType()
obj_types.append(my_type)
#uncomment the next line if you want to see all the component types in the document
if str(my_type) == Comp_type:
if Comp_name == None:
objs.append(obj)
print("found it")
else:
if obj.NickName == Comp_name:
objs.append(obj)
print("found it")
#bake the component
if Bake == True:
for obj in objs:
#create an empty GUID list
ids = List[Guid]()
obj.BakeGeometry(rcdoc,attr,ids)
print("baked the dimension elements")
doc_components = obj_types