## General Mechanical

#### Automatically Extract Location of Center of Mass (X, Y, Z)

• yc2647
Subscriber

Hi guys,

I know that we can get the center of mass for the geometry in Solution Infomation (or in geometry->properties). But I am wondering can we set it as a parameter for parameter optimization? Or automatically return the center of mass?

I would like to vary one of the length of my geometry while observing the changes of the center of mass?

Would there be any possibilities?

• Erik Kostson
Ansys Employee

Perhaps the *get command (on all elements) can help (have it as a snippet in the results section and that will give parameter named below my_cenx, etc):

/SOLU
*GET,my_cenx, ELEM, 0,MC, X,
*GET,my_ceny, ELEM, 0,MC, Y,
*GET,my_cenz, ELEM, 0,MC, Z,
/POST1

Also perhaps ACT can be used and the property

``CentroidX, Y, Z`And then create parameters of those.`

All the best

Erik

` `

• yc2647
Subscriber

Hi Erik, thanks for your reply. I tried to read through MAPDL tutorial, and found this web (https://mapdl.docs.pyansys.com/examples/gallery_examples/00-mapdl-examples/2d_plate_with_a_hole.html?highlight=center+mass).

Is there a way that I can extract center of mass "XC", "YC", "ZC" through mapdl.solve()? That is, to extract only the information of XC, YC, ZC?

Thank you!

• Erik Kostson
Ansys Employee

Hi

That is just in the solve.out.

Need to use *GET,my_cenx, ELEM, 0,MC, X,

in pyMAPDL it is:

mapdl.get('val', 'elem', '', 'MC', 'X')

for more help on that see:

get_value — PyMAPDL (pyansys.com)

get — PyMAPDL (pyansys.com)

Thank you