Macro to compute center of mass
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Macro to compute center of mass
Hi all,
I just created my first macro for FreeCAD !
It's a small macro to compute the weight of multiple solids and the center of mass of the "assembly".
You have to select one or multiple solids and then you launch the macro.
You'll have a window listing the solids. You can put the density of your material or choose in a huge list of predefined materials (I took the values here)
If you know your densities in another unit system, I used FreeCAD convert system to propose differents units.
You can also display where is the center of mass :
You can save the computed information in a csv file :
A import button allows you to quickly loaded saved densities (even if it's not a .csv file with the macro, as soon as there is a column named "Density" it will be loaded.)
If anyone want to test or have any suggestion to improve it, here is the file :
Files are here : https://github.com/chupins/FreeCAD-macr ... nformation
PS : the design is from here : planosconciri
Icon pack :
I just created my first macro for FreeCAD !
It's a small macro to compute the weight of multiple solids and the center of mass of the "assembly".
You have to select one or multiple solids and then you launch the macro.
You'll have a window listing the solids. You can put the density of your material or choose in a huge list of predefined materials (I took the values here)
If you know your densities in another unit system, I used FreeCAD convert system to propose differents units.
You can also display where is the center of mass :
You can save the computed information in a csv file :
A import button allows you to quickly loaded saved densities (even if it's not a .csv file with the macro, as soon as there is a column named "Density" it will be loaded.)
If anyone want to test or have any suggestion to improve it, here is the file :
Files are here : https://github.com/chupins/FreeCAD-macr ... nformation
PS : the design is from here : planosconciri
Icon pack :
- Attachments
-
- CenterOfMass_cionPack.zip
- (16.3 KiB) Downloaded 190 times
-
- Interface_ShowCdG.png (263.11 KiB) Viewed 16427 times
Last edited by schupin on Thu May 23, 2019 6:59 am, edited 11 times in total.
-
- Veteran
- Posts: 3156
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: Macro to compute center of mass
Nice tool!
It is easy to generate a material list.
Can you extend the macro for rebars (=arch-structure object)?
It is easy to generate a material list.
Can you extend the macro for rebars (=arch-structure object)?
Re: Macro to compute center of mass
why not choose the material out of the FreeCAD materials. They have density too.
Re: Macro to compute center of mass
I'll look at it. I'never work with arch, but it might be possiblethschrader wrote: ↑Mon Oct 29, 2018 1:54 pm Nice tool!
It is easy to generate a material list.
Can you extend the macro for rebars (=arch-structure object)?
It's my first macro and i didn't dive deeply into freecad API.
It was easier to start with this dictionnary. I guess i will easily change it to freecad's material list.
I'll try it soon
Re: Macro to compute center of mass
That's done !thschrader wrote: ↑Mon Oct 29, 2018 1:54 pm Can you extend the macro for rebars (=arch-structure object)?
I also add some lines to make it work with arrays (and arrays of rebars).
If you know some other structures of this kind, let me know !
(I also have to add the pathArray support)
I now use FreeCAD's material list and editor.
I'm not fully convinced since there is not a lot materials within the freeCAD installation files (except if you work with any kind of steel ).
But it's definitely better when you have already made a database.
I also change the button to icons to save place in the interface.
Here is the new version and the icons
-
- Posts: 436
- Joined: Wed Sep 15, 2010 9:38 am
Re: Macro to compute center of mass
It looks like a great macro. Can I put it on the official macro repositories (i.e. do you accept that other people can modify your macro)? What license do you want? I suggest the same as FreeCAD itself.
Thanks,
Gaël
Thanks,
Gaël
Re: Macro to compute center of mass
I'll be glad you add it in the official repo !galou_breizh wrote: ↑Sat Nov 10, 2018 6:40 am It looks like a great macro. Can I put it on the official macro repositories (i.e. do you accept that other people can modify your macro)? What license do you want? I suggest the same as FreeCAD itself.
The same licence as FreeCAD is ok for me, but I'm not sure the icons I took are compatible with this licence ? (I took them from freepik) It's on CC 3.0 licence.
-
- Veteran
- Posts: 3156
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: Macro to compute center of mass
Hi schupin,
macro and export to csv works for rebars.
But there is something wrong with the values (970 gramms total for the stirrups?)
Can you have a look at this? Thanks. I am running on
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15072 (Git)
Build type: Release
Branch: master
Hash: e517c00d9b3da3d1dbe5d5b0159ac5fa95790a8f
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)
macro and export to csv works for rebars.
But there is something wrong with the values (970 gramms total for the stirrups?)
Can you have a look at this? Thanks. I am running on
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15072 (Git)
Build type: Release
Branch: master
Hash: e517c00d9b3da3d1dbe5d5b0159ac5fa95790a8f
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)
Re: Macro to compute center of mass
You're right, It took the volume of only one element of the rebar.thschrader wrote: ↑Sat Nov 10, 2018 12:26 pm Hi schupin,
macro and export to csv works for rebars.
But there is something wrong with the values (970 gramms total for the stirrups?)
Can you have a look at this? Thanks.
It's corrected !
For your file it gives that :
I also corrected the units in the export data sheet (everything was in mm in the previous version)