Define center of Gravity for complicated element

We calculate based on single material assumption and 150 pcf. except for when a panel is insulated. Because there is such a massive weight reduction with insulation, we model those areas as pockets or block-outs, so the area of concrete is displaced accordingly. We do model the whole panel as one entity including the brick and return legs. We do void out areas for openings, reveals and false joints, but that is more for the form work and production more than for weight and CG accountability. When it comes to the reinforcing, which mainly consist of rebar and mesh, we don’t break that down and calculate their actual weights, we just assume the area of the concrete is replaced by the reinforcing and is inclusive in the 150 pcf.

Is there part of your code that you provided to where a total solid can be extracted out? Even though I am getting the centroid, for my other script, I also need to get the whole solid.

No I dont do a total solid in that script - I made it a few years ago because I kept running into cases where trying to generate a merged single solid in Dynamo kept failing (likely because a resultant edge was less than 1/32" or something weird like that - granted most of the time I’m getting C.G.s of 3000+ elements at a time so that might have had something to do with it…).

The method that @c.poupin posted does return a single solid (the last line - mergeSolid.ToProtoType() part is what does that).

I will try adding the last line to your code and see if that works.
Thanks for your help!

no - that wont work - i meant if you use the code @c.poupin wrote, you would get the total solid. to get my code to do that you’d have to do a lot more because i’m not merging the solids at all in my code.

Yeah sorry, I realized that once I got to looking at the code more.
Thanks again!

Thank you guys. I already found other way to define CG with Autocad and it’s correct when I did cross-checking in Revit (with uncomplicated element). It’s easy to solve this issue with Autocad 3D.
Thanks a lot for you guys supports.

Of course you guys @Ben_Osborne and @c.poupin assuming that the elements have same material. The density of materials will change the center of gravity. So you have to use a formal like = ρ*V to get mass.

1 Like

Sorry for digging this thread back up, but my question directly relates to it. My company is now getting into panels that have a steel frame attached. So now we are needing to take the density of the material into account in the center of gravity calc. Below is the code that I am using to get the solid of the list of elements and I need to a section that calcs the density. I am a novice when it comes to python for Dynamo, so would be grateful for any help or advice on what to do. Thanks in advance to any advice provided. I also apologize in advance as I don’t know how to adequately clip code from a node into the thread.

Load the Python Standard and DesignScript Libraries

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

def convert_geometry_instance(geo, elementlist):
for g in geo:
if str(g.GetType()) == ‘Autodesk.Revit.DB.GeometryInstance’:
elementlist = convert_geometry_instance(g.GetInstanceGeometry(), elementlist)
else:
try:
if g.Volume != 0:
elementlist.append(g)
except:
pass
return elementlist

doc = DocumentManager.Instance.CurrentDBDocument
items = UnwrapElement(IN[0])
detail_lvl = ViewDetailLevel.Fine
inc_invis = False
view = None
inserts = True
remove_inserts = False
revitlist = list()
dynlist = list()

TransactionManager.Instance.EnsureInTransaction(doc)

i = 0
for item in items:
geo_options = Options()
geo_options.DetailLevel = detail_lvl
geo_options.IncludeNonVisibleObjects = inc_invis
revitGeo = item.Geometry[geo_options]
try:
revit_geos = convert_geometry_instance(revitGeo, list())
revitlist.append(revit_geos)
except:
revitlist.append(list())
i += 1

TransactionManager.Instance.TransactionTaskDone()

volz=
cent=
for sol in revitlist:
for so in sol:
volz.append(so.Volume)
cent.append(so.ComputeCentroid())
totvol=sum(volz)
xs=
ys=
zs=
for i in range(0,len(volz)):
vol=volz[i]
cen=cent[i]
xs.append(cen.Xvol/totvol)
ys.append(cen.Y
vol/totvol)
zs.append(cen.Z*vol/totvol)

centroidpoint=Point.Create(XYZ(sum(xs),sum(ys),sum(zs))).ToProtoType()

OUT = (totvol,centroidpoint)