Macro CenterOfMass

Macro CenterOfMass

Description
Compute and show the center of mass for multiple solids.

Macro version: 0.8.3
Last modified: 2025-01-21
FreeCAD version: 0.20 and above
Author: Schupins, SyProLei, s-quirin, farahats9
Author
Schupins, SyProLei, s-quirin, farahats9
Download
None
Links
Macro Version
0.8.3
Date last modified
2025-01-21
FreeCAD Version(s)
0.20 and above
Default shortcut
None
See also
None

Description

Gives the total mass and the location of the center of mass of selected objects. Different densities can be chosen for each object.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://raw.githubusercontent.com/FreeCAD/FreeCAD-macros/master/Information/CenterOfMass.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://raw.githubusercontent.com/FreeCAD/FreeCAD-macros/master/Information/CenterOfMass.FCMacro")
<class="rawcodeurl"><a href="https://raw.githubusercontent.com/FreeCAD/FreeCAD-macros/master/Information/CenterOfMass.FCMacro">raw code</a>


Usage

  1. Select one or more solids.
  2. Launch the macro.
  3. You'll have a window listing the solids. You can specify the density of your material in different unit systems or choose from predefined materials.

Available Options

Script

You can download the macro from GitHub: Macro CenterOfMass.FCMacro

You can use this icon file as a toolbar icon:

Link

The forum discussion: Macro to compute center of mass

Version

Version / Date of merge

0.8.3 / 2025-01-23:

0.8.0 / 2025-01-06: Thanks to farahats9 for the contribution

0.7.6 / 2024-08-01: Prepare for major FreeCAD release

0.7.3 / 2023-09-11:

0.7.0 / 2023-02-13:

0.6.0 / 2022-08-27:

0.5.8 / 2022-05-31:

0.5.0 / 2022-04-07: complete rewrite by s-quirin (SyProLei project at Saarland University)

0.4.1 / 2019-05-25: Last update with old requirements and GUI available in official repository

0.1.2 / 2018-11-10: Initial version from chupins merged in official repository