FreeCAD / FreeCAD-macros

A repository for FreeCAD macros
https://freecad.org/wiki/Macros_recipes
145 stars 134 forks source link

[CenterOfMass] Added support to enter a mass explicitly #130

Closed nexx512 closed 2 years ago

nexx512 commented 2 years ago

Thank you for creating a pull request to contribute to FreeCAD-macros! To integrate your macro please make sure the following steps are complete:

And please remember to update the Wiki with the features added or changed once this PR is merged.
Note: If you don't have wiki access, then please mention your contribution on the 0.19 Changelog Forum Thread.


nexx512 commented 2 years ago

Sometimes it might be helpful to enter the mass of an object directly. This can be the case if the material is unknown but you know the mass i.e. when reverse engineering parts. Also it is possible to set the mass to zero to ignore certain parts.

I added a checkbox close the the mass input field that ca be checked when the mass should be entered explicitly. In this case the material an density are removed from the body but a Mass property is set.

I also renamed the save button to "Transfer" and edited the tooltip because to me it was very misleading that "Save" stores the properties on the bodies and also opens a save Dialog that I have to close again. From a UI perspective I didn't save anything but something (updating the properties) happened in the background.

s-quirin commented 2 years ago

The idea sounds good! In fact, I shied away from implementing it myself because the dependencies seemed cumbersome to me. Unfortunately I can't even start your macro yet:

self.init_spinMass(self.spinMass, Units.Quantity(g_sel[sol].Mass), parent.unitForM) <class 'AttributeError'>: 'PartDesign.Body' object has no attribute 'Mass'

nexx512 commented 2 years ago

Thanks for you comments. I change the source branch in my fork an had to create a new pull request. So I close this pr as it is now superseded by #133