Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5750

How can I replace a nested "Instance Definition" Object in C#?

$
0
0

I have library of blocks and inside my blocks I have others (a few hundred).

I’d like to add something to a C# script I’m already running on the Instance Definitions, to swap out the nested blocks with other nested blocks. Unconventional, but there is no other work-around because I’m pulling the blocks from an external file and that’s by design.

Right now I am able to find the object I want no problem ( InstanceDefinition.Object(i) or just the var “obj”).

var libraryInstanceDefinition = libraryDoc.InstanceDefinitions.Find(libDefName);
var obj = libraryInstanceDefinition.Object(i);

I know the block name for my chosen block for replacement and want to do something like this:

obj = (rhinodoc.InstanceDefinitions.Find(theDesiredBlock.Name) as RhinoObject);

But I can’t think of what I’d need to do to cast it corrrectly. Anybody have any thoughts?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5750

Trending Articles