Solid.Centroid Returns Point at Origin

Hi all!

So whenever I perform Solid.Centroid on a list of Solids (Masses) imported from Revit, Dynamo returns the origin as centroid for some of them (see highlighted element in the screenshot below).

Dynamo screenshot:

Revit screenshot:

Attached is:

I played a bit with your files, but I couldn’t find a proper solution.

Things I found:

  • It returns the origin only, if the X value is positive. That’s why two of them shows up correctly, the other ones don’t. If I move the failing masses to the other side of the origin they show up correctly. I tried with spheres in a generic model family, the result is the same. At some positions it returns a null value.
  • I replaced the spheres with cubes and it showed the correct centroids, so the main bug is that they are spheres, and centroid calculation fails on them for some reason.
  • I could also reproduce a similar bug in a new empty file, spheres sometimes add null values even with mass or generic model spheres. Cubes never fail.

I guess it’s a bug in the centroid calculation of dynamo.

A workaround would be to use the Element.Getlocation node, it doesn’t fail, and extracts the same coordinates, if you have to use spheres.

1 Like

Thank you very much for taking the time! I will use Element.Getlocation then. It is odd though that the centroid calc. fails on those cases.

Got the same bug…

Try with Code Block t1 = Autodesk.Solid.Centroid(solid1)

doesn’t seem to work either…

you’re trying like this

yep, exactly, im trying to do that. Get the centroid of an intersection.

Try like this

…

So I found out, the “Geometry Scaling” set to “extra large” or “large” causes this bug…

1 Like