InstanceObject.Explode strips user text from object attributes


(Andrew Heumann) #1

This appears to be a problem in both Rhino 5 and 6 - Attributes-Attached User Text is missing - this same data is present in the InstanceDefinition.Objects() Attributes properties.

To reproduce, make a box, assign it attributes user text, make it into a block, and run the following C# script in grasshopper:

private void RunScript(object x, object y, ref object A, ref object B)
    Rhino.DocObjects.InstanceObject block = RhinoDocument.Objects.OfType<Rhino.DocObjects.InstanceObject>().First();

    RhinoObject[] objs;
    ObjectAttributes[] atts;
    Transform[] xforms;
    block.Explode(true, out objs, out atts, out xforms);

    A = atts.SelectMany(a => a.GetUserStrings().AllKeys);
    B = block.InstanceDefinition.GetObjects().SelectMany(o => o.Attributes.GetUserStrings().AllKeys);


You’ll see that the A output is empty, while the B output has the specified user string keys.

Can't retrieve user properties from geometry inside a block
(Dale Fugier) #2

Hi @andheum,

I am able to repeat this - thanks for reporting.

For now, if you don’t care about nested instances, you can use RhinoObject.GetSubObjects.

– Dale