Preferably with Python
if you need a proper volume centroid, use AreaMassProperties:
Or if it doesn’t have to be the centroid exactly, just a point near the center, use the faster
(x is the Brep)
I was looking at this namespace expecting to see `Rhino.Geometry.AreaMassProperties.Centroid(x)
How did you know you have to place Centroid after Compute?
It is so intuitive right?
Per the documentation, it is a property of the return value, which is an object of type AreaMassProperties:
If it is your first visit to MassAreaProperties class in the API documentation. And you do not look into the Compute method the intuition tells you to get the centroid by Rhino.Geometry.MassAreaProperties.Centroid.
It is how we (noobs) think because it is there in the autocompletion. There has to be perhaps some help when you type this that you have to call the Compute method. Or maybe MassAreaProperties.Centroid should be a method instead of a property.
Yeah, but autocomplete is only dealing with syntax, not semantics. for the latter you have to RTFM.
Assuming I’m smart enough to find the MassAreaProperties class in the API (a big ask), then I want to know how to associate an instance with my Brep instance. I start by looking at the Constructors: uh, there isn’t one, so I probably nip off to the Brep class to see if M-A-P is one of its properties. Uh-uh, so back to M-A-P and look at the methods to find a way of making the association. Compute(Brep) looks promising (because there are lots of Compute overloads, so it’s probably pretty important): yep, I’m hot on the trail now. And that brings me to the point where I posted.
I admire your intent to use RhinoCommon, rather than RhinoScript. But by moving further away from the actual Rhino commands, intuition becomes weaker. Then you need to have an examining mindset.
(Oh, and a centroid is a property of an area or volume, and giving a method a property name is counter-intuitive - getCentroid() maybe.)
Yes, now, this I call intuitive having getCentroid() method but not inside the M-A-P class but rather the appropriate Rhino.Geometry.someBrep(or surface).getCentroid()
@Helvetosaur flag? It’s impolite!
“Read the flippin’ manual”, nothing wrong with that
But an a M-A-P object could relate to all sorts of things (look at all the Compute overloads). You would have to scatter the method across all of them. By making it the responsibility of the M-A-P, you avoid that duplication and your code is easier to maintain.
Mitch knows exactly why I do this. I hope he learns his lesson. I didn’t flag, I don’t flag figures of speech. Or taking a word out of context, thus helping remove/hide a post. This is normal and if it is a targeted insult then it should be removed.
Yeah, you’re probably right, I don’t argue, just for a novice programmer it is difficult to comprehend and counter-intuitive.
Do you also know how to get the lengths of the edges of a brep?
You don’t use Compute for that, just get the edges and
At least that’s what I would do
What can I do? Compute?
I have a rotated brep from which, starting from the middle, I want to make a point grid.
First, I need to know what the dimensions and the orientation of the brep are, then I can make the point grid.
try this. it is untested
my_brep = ? list_of_edges = my_brep.Edges for my_edge in list_of_edges: print my_edge.GetLength()
Do you might know how to determine which edge is x,y, and z.?
With that, I know what direction is which length.