Hi can anyone show me the right method to update Instance References in RhinoDoc.ActiveDoc. I am Currently using the ModifyGeometry method, but the only result I get so far is to empty all the blocks!!
any idea abou the right procedure?
thanks in advance!
import Rhino
import scriptcontext as sc
def TestModifyInstanceDefinition():
# Find the instance definition
idef = sc.doc.InstanceDefinitions.Find("test")
if not idef: return
# Placeholders for new and existing stuff
geometry = []
attributes = []
# Add some new geometry
circle = Rhino.Geometry.Circle(Rhino.Geometry.Plane.WorldXY, 1.0)
curve = Rhino.Geometry.ArcCurve(circle)
geometry.append(curve)
attributes.append(sc.doc.CreateDefaultAttributes())
# Get/copy/add the existing geometry
for rh_obj in idef.GetObjects():
geometry.append(rh_obj.Geometry.Duplicate())
attributes.append(rh_obj.Attributes)
# Modify the instance defintion
sc.doc.InstanceDefinitions.ModifyGeometry(idef.Index, geometry, attributes)
sc.doc.Views.Redraw()
TestModifyInstanceDefinition()
all right! its works perfectly, using GH python I had just to replace the sc.doc. with Rhino.RhinoDoc.ActiveDoc . Now I am trying to retrieve the existing elements in the idef, and perform a certain operation on the rh_obj according to the type of geometry and layer name. What should i do next?
I don´t really know this part of the library, and working with the active doc is even more confusing. My only problem is not I am not able to perfom any operation that I normally do with the Rhino.Geometry. I am not any more in gh geometry let`s say, but on the active doc right? if I get the type of the rh_obj in the InstanceDefinition, after the GetObjects, I get ‘CurvedObject’ ( the circle you created) and ‘ExtrusionObject’ (my “test” block is a cube).what objects these are? What is this part of the library?
I am not sure how to retrieve the layer attributes from the rh_obj to create an if condition ( for example) and perfom geometric operation ( get one side of the box in the block and extrude it, for example) on it. Do I need to bring the rh_obj to the Rhino.Geonmetry ?