How to import a block object

Hi all,

i try to import a block object from one 3dm file to another via rhino api but i had no success.

has anyone any tip how i get accsess not only to the block but also to the geometry inside the block.

The

Rhino.FileIO.File3dm.InstanceDefinitions 

have no option to access the geometry

The

Rhino.FileIO.File3dm.Objects

Have no option to get block properties like block.names

Any tip is always welcome
Thanks in advanced

Cant test it right now, but:

        foreach(var id in file.AllInstanceDefinitions)
        {
            var guids =  id.GetObjectIds();

            foreach(var guid in guids)
            {
                var obj = file.Objects.FindId(guid);
            }
        }

you should be able to get the geometry from obj via obj.Geometry.

rgr thanks for the tip, will check that out

Ok how the hell do you know this

id.GetObjectIds()

because in the InstanceDefinitionTable Class is nothing about that.

File = rh.FileIO.File3dm.Read(x)
for i in File.AllInstanceDefinitions:
    ObjId = i.GetObjectIds()
    for o in ObjId:
        File.Objects.FindId(o)

Thanks a lot for your example works like a charm.

Visual Studio has some nice features :wink: