Grasshopper

algorithmic modeling for Rhino

So I have a block in my Rhino Document, and I want to Modify it via grasshopper.   I know how to delete the block, redefine it, and rebake it with a C# script, however this does not replace the existing blocks.  

I COULD manually go through and select all of the existing Base Points (geometries I have already added to the block) and reference them in grasshopper, then use those points to do a Plane2Plane translation and then AddInstance to each Base Point.  Which is what I am doing right now.  But the key word there is MANUALLY, which I would like to eliminate.  

I am looking for a way to provide a block name, and have the c# script go through and find all the instances where it is placed.  then create a list of all the Base Points.  This way once i recreate the block, I have all I have to do is do a Plane2Plane translation, and I am able to re-add the Instances of the block

One solution I think will work is since the block originated from another grasshopper script, I can add an attribute to the original creation of the block, assigning a specific name to the Base Point Geometry.  Then in the new C# script, I can do a .Find() and hopefully reference all the points with that name.  

I was just hoping there was someone out there who can find a better way of doing this.

Views: 5036

Replies to This Discussion

Following the other thread of yours > see this (the 3rd C#).

David of course knows these things far better than I ... but I'm not aware of any method that obtains the InstanceDefinition basePt ( == insertion Pt) - unless it is stored (at creation time) as geo with some special user.attrib.

Attachments:

So lets say when I originally bake the block, I bake it with a point that is Named "RandomBlock01_InsertionPoint", and there are 5 instances of it.  And then another block with a point "RandomBlock02_InsertionPoint" and there are 3 of them.

They have a specific Name Attribute so I should be able to reference them.  How would you suggest I go about doing it?  

Also, where did you get that screenshot?  I feel like that will be very helpful since I am not to experienced with C#

1. Rhino SDK : http://4.rhino3d.com/5/rhinocommon/

2. For GH SDK:

3. Appears that a 4th C# is required (such a simple case ... eh?, he he)

Note: This case makes me re-think/re-evaluate the 10 promised block C# examples > I mean they are written with my needs in mind (never work with Rhino, always export to CATIA/AECOSim/NX blah blah) ... a fact that has very little interest for anyone else.

Moral: redesign the examples > make them as useful as possible for Rhino/GH users

more soon

BTW: With regard that SDK thingy: Roses are not always white, mind

BTW: having spend all my life with assembly/component disciplines (NOT a task for Rhino by any means, mind) I would strongly suggest NOT creating "identical" (as far the geo part) instances that differ only in their insertion point.

It's far better to change the placing "policy" (using a different Plane for the planeToPlane trans) than dealing with a chaotic collection of similar instances .. that ... actually differ.

I agree, my intent is to obtain the basepoint, then delete the existing block, then recreate it, and re-place it at the original basepoints that we just obtained) as well as some new basepoints.  the geometry would also be modified.   

Any suggestion on how to do this?

Please accept my apologies: I've promised to deliver the def with the 4th C# ... but other (ugly) things happened and ...

Anyway I'm starting doing this right now (be The Dark Force with us all)

more soon (I do hope, he he).

It seems like the best way to do this is to bake the Base point into the block.  When I create the block, Ill create the point on layer "Insertion-Point" with the name "Block_01_IP".  

Im looking to write a script that will:

1) Get all the geometries on the layer "Insertion-Point"

2) Compare the geometry's name to the desired name "Block_01_IP"

So I guess my first question is how do I get all the geometries on a specific layer?

This is what I would think should work.  I'm listing the layer table, and this shows that the layer exists and the script can find it, however when the script tries to get geometries on the layer, it outputs nothing

Attachments:

I found out why this is happening.  When a geometry is inside a block. Rhino sees it as an instance, and not separate geometries.  The blocks are located on layer A, and the geometries inside are located on layer B.  When I am trying to get all the geometries on Layer B, none exist because they are within the block.  However if i were to try and select all of the geometries on layer A, I get the instance definitions for the blocks.

Sorry for a later answer.

I coded a component to retrieve base point for blocks and it works without a manually-set base point inside the block.

It works based on a fact that the insertion point in the relative coordinates inside a block is (0,0,0), so you only need to extract Xform parameter of a block instance.

Some code is applied to support both Elefront Block Object (InstanceReferenceGeometry) and GUID-imported blocks (natuve GUID component, leading to RhinoDoc.Objects.Find() => InstanceObject).

Leaving uncrypted, so with some work, it is easy to retrieve the name as well. (InstanceObject.Name or InstanceDefinitions.Find(InstanceReferenceGeometry.Parentfid).Name)

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service