generative modeling for Rhino
Hi,
Can I use grasshopper to instance blocks that are defined in Rhino ?
It would be totally awesome if it could be possible, I want to use it to place placeholders that can be refined later on.
thx
sb
Tags:
Hoi Sander,
Currently thats not possible in grasshopper but you can use the SDK to do it.
Just copy this function into the "custom additional code" body of a vb component and call it from the main subroutine:
Function InsertBlock(BlockName As String, insPt As Point3d, dblScale As Double, dblRotation As Double) As Guid
Dim blockTable As docobjects.Tables.InstanceDefinitionTable = doc.InstanceDefinitions
Dim block As docObjects.InstanceDefinition = blockTable.Find(BlockName, True)
Dim move As Transform = Transform.Translation(New Vector3d(insPt))
Dim scale As Transform = Transform.Scale(point3d.Origin, dblScale)
Dim rotate As Transform = Transform.Rotation(math.PI * dblRotation / 180, point3d.Origin)
Dim xform As Transform = move * scale * rotate
insertBlock = doc.Objects.AddInstanceObject(block.Index, xform)
End Function
On calling it adds the block to your scene directly. To be able to keep track of all the inserted blocks I usually collect the guid's in a global variable.
Hope that this helps you out,
Marc
Permalink Reply by Sander Boer on February 3, 2011 at 7:39am Dag Marc,
I've been looking into using the SDK and got stuck, you just unstuck it!
Thanks a bundle !
gr
S
Permalink Reply by lmnts on April 21, 2011 at 9:53am Hi Marc,
I'm wondering if you could help me with a similar problem. I'm trying to replace the geometry within an existing block with geometry from grasshopper using VB but so far I've had no luck. Any ideas?
Cheers,
Scott
Permalink Reply by ryles on April 21, 2011 at 11:55am Hey Marc,
Stupid script question, when you say "call it from the main subroutine" how do you do that? It's something I don't quite get with functions yet.
Thanks in advance,
ryan
Permalink Reply by Neil on December 18, 2012 at 3:10pm Hi Marc,
I am a rather new user to VB scripts and would really like to know the answer to Ryan's question as well - any chance you can share?
Thanks!
Neil
Permalink Reply by Chris Chalmers on November 30, 2011 at 1:06am Hi Marc
This is really great - except that it places a new block every time I update settings like a slider value. Can you suggest a way to show the block in GH style preview and bake like other GH data?
Thanks!
Chris
Permalink Reply by Neil on December 18, 2012 at 3:10pm Hi Marc,
I am a rather new user to VB scripts and would really like to know the answer to Ryan's question as well - any chance you can share?
Thanks!
Neil
Permalink Reply by jose salinas on April 3, 2013 at 5:43am VERY GOOD!!!BUT FOR NEW USERS
Dim blockTable As docobjects.Tables.InstanceDefinitionTable = doc.InstanceDefinitions
Dim block As docObjects.InstanceDefinition = blockTable.Find(BlockName, True)
Dim move As Transform = Transform.Translation(New Vector3d(insPt))
Dim scale As Transform = Transform.Scale(point3d.Origin, dblScale)
Dim rotate As Transform = Transform.Rotation(math.PI * dblRotation / 180, point3d.Origin)
Dim xform As Transform = move * scale * rotate
A = doc.Objects.AddInstanceObject(block.Index, xform)
Hi guys,
You might read this post...there you find a complete solution to this inserting block. I've posted a version Preview blocks and bake them...
The script also get's sure the block is updated each time the geometry changes and is suppressing the annoying prompt from rhino when a block already exists.
Best regards
FF
Added by David Stasiuk 8 Comments 24 Likes
Added by stefano 5 Comments 8 Likes
© 2013 Created by Scott Davidson.
Powered by