Grasshopper

algorithmic modeling for Rhino

Grasshopper community,

I am trying to figure out how to create a C# component that bakes identical geometry as a series of duplicate blocks.

Basically, I am using an existing C# component that bakes things as blocks, but no matter what, the blocks will always be different. So if I had 3 identical rectangles plugged into the script, its result would be three blocks that look the same, but have different block definitions.

I would like to modify this C# component to take identical geometries (maybe the restriction is that it can only accept incoming data if it is the same geometry, just in different positions) and bake them as instances of the same block. This way, when I bake  the script, the three identical geometries are translated as three duplicates of the same block, and when I edit one, the rest edit as well.

Any help would be appreciated.

Views: 1877

Replies to This Discussion

if you don't need to do it within a script, the Human plug-in enables this.

Otherwise you'll need something involving:

Rhino.DocObjects.InstanceDefinition def = doc.InstanceDefinitions.Find(blockName, true);
if (def !=null){
instanceInd = def.Index;
}

RhinoDocument.Objects.AddInstanceObject(instanceInd, transform, attributes);

I didn't know about your plugin Andrew, it looks incredible and is exactly what I need. I just assumed there was nothing out there and I'd have to invent a C# script. I think you solved my problem, I'll check out Human very soon.

Nice work.

Great, glad to hear it! Let me know if you need any help setting it up to do what you need.

Hi Andrew, I do need help figuring out how to take identical geometries from Grasshopper and bake them as blocks in Rhino. I have installed your plugin but am not sure exactly how to accomplish this. Thanks!

Hi Josh - 

I've attached a file that shows two examples of how to use Human to create multiple instances of identical geometry types. The first assumes that the blocks have already been defined in the Rhino Document; the second adds the blocks to the document automatically via a script (this functionality will likely be added to a future release of Human directly). 

I've tried to annotate the files, so I hope they are clear, but please feel free to follow up with any additional questions you may have. 

Attachments:

Andrew, thank you very much. I had actually figured a lot of it out on my own, but that C# script you have in there that creates the block of the correct name is key to my efforts.

Question: is there a way to create something that would tell you whether a block of the same name already exists? I tried to create a block in a name that was already taken and it warned me, then it completely crippled the GH interface and I had to restart Rhino. It would be nice if there was an indicator of some sort so I wouldn't be tempted to redefine an existing block, which seems to cause software issues.

Nice work and thanks for your thorough response.

Hi Josh - this is a great question. I've attached an updated version of the previous definition that includes a check to make sure the block is not already defined. It also has an option to overwrite that existing definition with new geometry if desired. This last piece may not always work 100% - it's functionality I haven't experimented with too much, but in my tests seemed to work nicely. Give it a try and let me know if you run into any issues. 

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service