Macro CenterOfMass: Difference between revisions

From FreeCAD Documentation
m (modify link Codeextralink to "https://raw.githubusercontent.com/chupins/FreeCAD-macros/SC_Branch/Information/CenterOfMass.FCMacro")
mNo edit summary
 
(49 intermediate revisions by 8 users not shown)
Line 3: Line 3:


<!--T:5-->
<!--T:5-->
{{Macro
{{Macro|Icon=Centomass|Name=Macro CenterOfMass|Description=Gives the Center of mass multiple of multiple objects selected.|Author=schupin|Version=0.1.2|Date=2018-11-10}}
|Name=Macro CenterOfMass
|Description=Compute and show the center of mass for multiple solids.
|Author=Schupins, SyProLei
|Version=0.7.3
|Date=2023-09-07
|FCVersion=0.19 and above
}}


==Description== <!--T:6-->
==Description== <!--T:6-->


<!--T:7-->
<!--T:7-->
Gives the total mass and the location of the center of mass resulting of multiple objects selected. Different densities could be chosen for each object.
Gives the total mass and the location of the center of mass of selected objects. Different densities can be chosen for each object.

</translate>
</translate>
{{Codeextralink|https://raw.githubusercontent.com/chupins/FreeCAD-macros/SC_Branch/Information/CenterOfMass.FCMacro}}
{{Codeextralink|https://raw.githubusercontent.com/FreeCAD/FreeCAD-macros/master/Information/CenterOfMass.FCMacro}}


[[File:Macro CenterOfMass 01.png|left]]
[[File:CenterOfMass_exemple.png|600px]]
{{clear}}
<translate>
<translate>


<!--T:8-->
==Usage== <!--T:4-->
The values (mass and center of mass) results can be saved in a spreadsheet
</translate>
[[File:Macro CenterOfMass 02.png|left]]
{{clear}}
<translate>

==How to use== <!--T:4-->


<!--T:9-->
<!--T:9-->
Select the object(s)
# Select one or more solids.
# Launch the macro.
# 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.


<!--T:10-->
===Available Options=== <!--T:29-->

Run the macro
<!--T:30-->
* 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 {{FileName|.csv}} file from the macro, but columns must be named accordingly).
* Save densities in the document (remove them again when setting material to {{ComboBox|default}}).
* You can change some preferences at {{MenuCommand|Tools → Edit parameters → Preferences → Macros}}.


==Script== <!--T:11-->
==Script== <!--T:11-->


<!--T:13-->
You can download the macro from GitHub:
</translate>
[https://github.com/FreeCAD/FreeCAD-macros/blob/master/Information/CenterOfMass.FCMacro Macro CenterOfMass.FCMacro]
<translate>


<!--T:12-->
<!--T:12-->
You can use this icon file as a toolbar icon:
icon file download and paste in a sub directory named CenterOfMass in the macro directory

<!--T:18-->
toolBar icon
</translate>
</translate>
[[File:Macro_CenterOfMass.svg]]
<translate>


==Link== <!--T:14-->
[[File:Centomass.png]]
{{clear}}


<!--T:15-->
The forum discussion: [https://forum.freecad.org/viewtopic.php?f=24&t=31883 Macro to compute center of mass]


==Version== <!--T:16-->
[[File:SaveIcon.png]] [[File:CdgIcon.png]] [[File:ComputeIcon.png]] [[File:ImportIcon.png]] [[File:MaterialIcon.png]]
{{clear}}


<!--T:31-->
'''Macro CenterOfMass.FCMacro'''
Version / Date of merge
<translate>
<!--T:13-->
Download in Github


<!--T:36-->
</translate>
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


<!--T:32-->
[https://raw.githubusercontent.com/FreeCAD/FreeCAD-macros/master/Information/CenterOfMass.FCMacro Macro CenterOfMass.FCMacro]
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


<!--T:33-->
<translate>
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


==Link== <!--T:14-->
<!--T:34-->
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


<!--T:15-->
<!--T:35-->
0.5.0 / 2022-04-07: complete rewrite by s-quirin (SyProLei project at Saarland University)
the forum discussion [https://forum.freecadweb.org/viewtopic.php?f=24&t=31883 Macro to compute center of mass]
* 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.


==Version== <!--T:16-->
<!--T:27-->
0.4.1 / 2019-05-25: Last update with old requirements and GUI available in official repository

<!--T:20-->
0.1.2 / 2018-11-10: Initial version from chupins merged in official repository


<!--T:17-->
0.1.2 / 2018-11-10 : xx
</translate>
</translate>

Latest revision as of 14:10, 22 December 2023

Macro CenterOfMass

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

Macro version: 0.7.3
Last modified: 2023-09-07
FreeCAD version: 0.19 and above
Author: Schupins, SyProLei
Author
Schupins, SyProLei
Download
None
Links
Macro Version
0.7.3
Date last modified
2023-09-07
FreeCAD Version(s)
0.19 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")


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.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