FreeCAD Logo FreeCAD 1.0
  • angielski afrykanerski arabski białoruski kataloński czeski niemiecki grecki hiszpański hiszpański baskijski fiński filipiński francuski galicyjski chorwacki węgierski Indonezyjski włoski japoński kabylski koreański litewski duński Norweski Bokmal polski portugalski portugalski rumuński rosyjski słowacki słoweński serbski szwedzki turecki ukraiński walenciański wietnamski chiński chiński
  • Funkcjonalność programu
  • Pobierz
  • Blog
  • Dokumentacja
    Spis dokumentacji Jak zacząć Dokumentacja użytkowników Podręcznik do programu FreeCAD Dokumentacja środowisk pracy Dokumentacja skryptów środowiska Python Dokumentacja kodowania C++ Poradniki Najczęściej zadawane pytania Polityka prywatności O FreeCAD
  • Przyłącz się do projektu
    Jak pomóc Sponsor Zgłoś błąd Utwórz pull request Praca i finansowanie Zasady współpracy Podręcznik dla programistów Tłumaczenia
  • Społeczność
    Kodeks postępowania Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Kalendarz
  • ♥ Donate

Donate

$
Informacje o SEPA
Skonfiguruj przelew bankowy SEPA do:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank: BNP Paribas Fortis
Adres: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Macro CenterOfMass

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

Macro version: 0.8.4
Last modified: 2025-05-23
FreeCAD version: 0.20 and above
Author: Schupins, SyProLei, s-quirin, farahats9
Author
Schupins, SyProLei, s-quirin, farahats9
Download
None
Links
Macros recipes
How to install macros
How to customize toolbars
Macro Version
0.8.4
Date last modified
2025-05-23
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

  • Color the solids according to density.
  • Display the location of the center of mass.
  • Export and import masses, materials and densities (even if it's not a .csv file from the macro, but columns must be named accordingly).
  • Save densities in the document (remove them again when setting material to default ).
  • You can change some preferences at Tools → Edit parameters → Preferences → Macros.

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.4 / 2025-06-10:

  • Fix: Fix macro ceased to work with Qt6 (PR#197)

0.8.3 / 2025-01-23:

  • Fix: Several fixes (PR#191), FreeCAD 0.19 no longer supported

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

  • New: Show Volume and Surface area
  • New: Calculate Moments of Inertia
  • Fix: Macro now works with the Assembly example in FreeCAD 1.0
  • Fix: Automatically select material for solids if it is already assigned by the new material system
  • Minor UI changes

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

  • Fix: Make 0.22.0dev AssemblyExample work
  • Fix: BOM Import containing custom material
  • Fix: Support the new material cards
  • Fix: Changed or missing icons, version checks

0.7.3 / 2023-09-11:

  • New: Added buttons for Copy to clipboard
  • New: Scalable Vector Graphics icon
  • Fix: Compatibility for FreeCAD versions and web

0.7.0 / 2023-02-13:

  • New: Searchbar for solids
  • New: Reworked import function to improve external bill of materials (BOM) import with better input tolerance. Caption "weight" has to be changed to "mass" if you want to import mass from an old file export of the macro.
  • New: Mass can be set zero to exclude solid from calculation and visualization
  • Fix: Behaviour of default value spin and "Apply to all"
  • Fix: Preserve original solids color when "New" button pressed

0.6.0 / 2022-08-27:

  • New: Masses are editable (a highly requested feature)
  • New: Highlights the solid you are working on
  • New: No duplicate entries when container and content selected concurrently
  • New: Pie charts show density relation in combo box
  • New: Legibility of text on colored combo box with WCAG21 1.4.6 Contrast (Enhanced) conformity
  • Fix: A Part used as a container for meshes (e.g. .stl's) is recognized correctly
  • Fix: Fixes for error and language handling, material editing, combo box and GUI size adjustment

0.5.8 / 2022-05-31:

  • Reinserted: Bounding Box
  • New: Setting to color spheres
  • New: Setting to change color maps
  • Rearranged GUI: Update calculation added, Total density added
  • Fix: Message Boxes could not be used when not running FreeCAD on primary screen in a multimonitor setup
  • Fix: More than one Mesh was not calculated correctly

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

  • New: Code base, Requirement raised to Qt5.12+ and Python3 (FreeCAD 0.19).
  • New: Show mass of each solid.
  • New: Start window docked or floating (can be set in Parameter Editor).
  • New: Selection matches up tree view or is sorted by name (can be set in Parameter Editor).
  • New: Option to save densities in document.
  • Improved: FreeCAD alike Gui look and feel.
  • Improved: Scaled color palette (from green to red) to colorify shapes.
  • Improved: Visualising the displacement of centre of mass to the geometry.
  • Improved: Internal tracking of units.
  • Fix: Handling of groups and group objects.
  • Fix: Handling of App::Link.
  • Fix: Replaced deprecated Qt class.

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

Ta strona pochodzi z https://wiki.freecad.org/Macro_CenterOfMass

Bądźmy w kontakcie!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© Załoga FreeCAD. Autorami grafiki na stronie głównej (od góry do dołu) są: ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Ten projekt jest wspierany przez: , KiCad Services Corp. oraz pozostałych sponsorów

GitHubUlepsz tę stronę na GitHub