Can I edit block in grasshopper or in ghpython?

ghpython
grasshopper

#1

I can add block in grasshopper using the plug-in named “elefront” and ID component. But I wonder if I can edit the Block in grasshopper or in ghpy.


(Giulio Piacentino) #3

Hi @RetroPost.LT

Grasshopper, as you probably were sensing when installing Elefront, has no “Rhino Block” support. There are groups, but they are meant for a different usage in Grasshopper. RhinoCommon and rhinoscriptsyntax (http://developer.rhino3d.com/api/RhinoScriptSyntax/win/#block) have methods to change blocks. But if your goal is editing, why not create the right block definition in the first place? Instantiation, on the other hand, is easier with InsertBlock (http://developer.rhino3d.com/api/RhinoScriptSyntax/win/#block-InsertBlock). If you attempt this from GhPython, rather than Rhino (_EditPythonScriptEditor), you will have to let GhPython know that you mean to target the Rhino document. See "ghdoc" information for more.

Please let me know if you need more hints,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#4

Hi Giulio,

Elefront and Human allow to reference block instances in Grasshopper.
They make it possible to get lots of data from blocks :

That data can be used to do almost anything…except update the block definition and/or block instances.

Namely :
-Modify the geometry contained in the blocks
-Modify the properties of geometry contained in the blocks
-Modify the properties of the blocks instances themselves
-Add User text to the block definition or the geometry within

This is a huge bummer for people working with blocks and looking for ways to automate actions on blocks.


(Giulio Piacentino) #5

@osuire Technically there isn’t any reason why plug-ins would not be able to edit the InstanceDefinition table. They can. Probably though, this type of operation is not well-suited for a visual programming language. Again, you can do that in scripting… targeting the Rhino document.

You can ask @DavidRutten for plans on block inclusion in Grasshopper 2.


(David Rutten) #6

It is a problem because the actual block definition resides inside the Rhino 3dm file and as such cannot easily be extracted and used as a thing an-sich in Grasshopper. It’s all very complicated and I haven’t given it a lot of thought. If the only purpose of blocks in GH is to preview and bake them as instances, then addressing them by Rhino name may work. If you also want to measure boundingboxes, closest points, intersections etc. then I have no idea what sort of approach would work any more.


#7

Hi David, I’m not sure that you fully understand my issue.
Human and Elefront allow me to know whatever I want to know about blocks, and extract their innnards, and do whatever I want with that data… except changing the block definition.

There’s two lights at the end of the tunnel, but I haven’t explored them yet :

Elefront’s “Block Bake” (although I don’t know whether it will be able to overwrite an existing block or create a nested block :

Fabtool’s “Creat or Modify Block” (this one has a promissing name) :
Fabtools%20Create%20Or%20Modify%20Block