algorithmic modeling for Rhino
Dear Grasshoppers,
I would like to determine the area centroid of a surface.
import rhinoscriptsyntax as rs
obj = rs.GetObject("select object", rs.filter.surface)
print(rs.SurfaceAreaCentroid(obj))
However, when instead of selecting the surface in Rhino, I reference the same surface in Grasshopper, suddenly the component does not work anymore. The object_id becomes different, but apparently I cannot determine the area centroid anymore.
rs.IsObject(obj) also returns false.
If I understood the answer here correctly, the rs module only works on 'real' objects in the Rhino session? So how do I refer to the actual grasshopper object?
http://www.grasshopper3d.com/forum/topics/general-python-questions
Again, thank you for the support!
Tags:
Hi Bart,
Grasshopper has no "picking" logic, therefore you are unable to "pick" Grasshopper geometry.
Instead, you simply pass the geometry that you need into the Python component, and it gets automatically transformed into a Guid (ID) that is usable in RhinoScript. This means that you can run the call like this:
import rhinoscriptsyntax as rs
area_centroid_info = rs.SurfaceAreaCentroid(x)
a = area_centroid_info[0] #centroid, [1] is error
I hope this helps,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Dear Giulio,
Great! I've got it also working in combination with a DataTree, where I started with in the first place.
Thank you for the support!
Best regards,
Bart
This script as it stands does not need a DataTree-based approach. Were you adding other logic, too?
Yes, I wanted to make an alternative component to the deconstruct Brep, where two inputs are given: a reference and a variant closed polysurface.
The deconstruct Brep does not always give the same list order of surfaces after exploding the polysurface. which resulted in errors further down the grasshopper script.
So my goal was to determine the centroids to see which surfaces corresponded to eachother, to make sure that after deforming the reference polysurface, the deformed polysurface would be deconstructed in the same order.
Hopefully this was clear explanation ^_^.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by