How can I extract the location (x,y,z) of a block with respect to the origin (0,0,0) with grasshopper?
This seems to work in plain Rhino, maybe it helps: (Python code)
import Rhino
from Rhino.Geometry import *
import rhinoscriptsyntax as rs
def get_location():
o = rs.GetObject()
if not o:
return
b = rs.coercerhinoobject(o)
if not type(b) == Rhino.DocObjects.InstanceObject:
return
tf = b.InstanceXform
pt = Point3d(tf.M03,tf.M13, tf.M23)
return pt
print get_location()
Here’s an example using the Elefront 4.3 Plugin, which has an option to get nested blocks as well.
re_blockDeconstruct.gh (10.1 KB)
The Rhino 8 WIP has new block components, too.
@miguelayora3 Correct. Following up on @Japhy’s post, here is a way you could do this using Rhino 8’s new Block components. Basically, my nested block assembly is called “Door Assembly” and it’s made up of other block instances (ie. hinges, handle, etc.). So, I use the Query Model Objects component to bring the blocks from the Rhino document into the Grasshopper model. From there, I can deconstruct the block instance and get access to the plane transformation being used for the root node (the Door Assembly block). I can then deconstruct the Block Definition that makes up the Door Assembly and get access to all the sub-instances (ie. hinge, handle, etc.). So, you can basically keep deconstructing the block instance, and then the block definition, all the way down the nested structure to get access to whatever it is you’re looking for. Hope that helps.
My Deconstruct Block is not working this time, I can’t find a reason.
The warning is
-
- Data conversion failed from Block to Block
But I find an alternative solution with Explode Block
Hi C Zou, It looks like you are mixing Elefront 4.x components with 5.x (which aren’t compatible)
Exactly ! I just discovered that I have both of them.
hi, my rhino version is Rhino8_SR5
i found the lastest component change the output.
i could not get the original plane after use the block definition.
Did I lose some component info?
i add the capture here.
i found a little different logic when i use th GH for rhino8 block serise component,
It looks like you got this working, but if not can you please clarify what your issue is?
Hello @Andy and @Japhy, I wonder if this has changed in recent versions, as the plane output is no longer in the model block instance component. My build is Rhino 8 SR12 2024-10-8 (Rhino 8, 8.12.24282.07001)
My workaround was to append a plane and then point to the block instance reference, which did the trick, but I wonder if I am missing something else.
Many thanks for your support.
Chris.
Nothing has changed but you can cast the transform output into a plane and that should work just fine