FreeCAD 0.21 release is coming soon, which means all feature requests are now frozen and no new features would be add till the next release.
For now FreeCAD has no implemented materials yet, but its already possible to add material manually "by hands".
In this tutorial I will show You how to solve this missing feature issue with a workaround trick.
Material, in the means of physical properties, defines Color, Volume, Density, Mass of the physical object (in the CAD apps its called as Solid Part or Solid Body), where:
Every object in FreeCAD has a set of properties of various types, which could be called using internal API.
Any Property could be used in value inputs fields in a form of Expressions.
Base solid object in FreeCAD is the PartDesign Body (aka Body, which Shape
defined with one or a set of PartDesign Features).
Latest FreeCAD 0.21 weekly builds (test builds) already has a property to calculate and return volume of shapes in cubic millimeters (FreeCAD internally uses mm as length units, mm^2 as area units, mm^3 for volume and g units for mass) as next:
(where Body
is a Label
name, UID of any object inside project tree)
For calculating the Mass its just need to know Density value of the Material of the Body — the rest could be solved with Expressions inside Property Value.
So, the first thing to do is define Material
of the body — for that it would be nice to has a list of materials. How to do that?
Lets start with creating custom Property
in Property editor:
Body
object in the "Model" tab of Combo view panel (for create bodies use PartDesign Workbench);Propery
(first column), open context menu again (it also has listed more options now) and click on "Add property";Type
as:Set Group
name (e.g. Physical
, or use any other name) that would be a separator in Property
table;
SetName
as Material
and click OK. Now there is new entry in the table
Material
row also has a collapsable sub-row Enum
— fill it with a list of possible materials. Click in on its Value cell and on the right click ...
(tripple dot) button — You would see a text editor with numbered lines. Input a list of possible materials names, for example here are three materials designed part might be made from:
Material
row there would be a drop-down list with the listed materials:Density
(see previous steps), but use next Type
:Density
property would be created click on its Value
char and press "f(x)" (blue circle button on the right of entry field) or type =
(equal key) to open "Formula editor" (alternatively open it with move pointer directly on the Density
property name on the left in a a row, open context menu and click "Expression..."). In "Formula editor" type next expression:Physical_Material
is a variable of Material
property from Physical
group;==
(double equal) is an "IF EQUAL" operator to check active list ID, here for App::PropertyEnumeration
numbering starts with 0
(zero) for first list entry;?
(question mark) is an "THEN" operator used to otput "TRUE" and "FALSE", where "FALSE" value is coming after "TRUE" value and separated with :
(colon) symbol (read more about Conditional expressions on FreeCAD wiki);2700
, 1020
and 7800
are possible values of the Density
(in kg/m^3) of the first (i.e. 1060 Aluminium Alloy
), the second (i.e. ABS
) and the third (i.e. Plain Carbon Steel
) materials on the Material
property list accordingly;* 1 kg/m^3
(multiply by one kilogram ) is used to set units of Density
input value as kg/m^3 (as said, FreeCAD internally uses g/mm^3 units for App::PropertyDensity
, so this part of the expression is used just for simplify entering real density values listed in catalogs in kg/m^3).Volume
(see previous steps), but for this time use next Type
:Volume
property set the next expression:.Shape.Volume
("dot" means a reference link) without defining Label
of the Body
, because we call it from the actual object, so it is relative reference value (for object with the label Body
both Body.Shape.Volume
and .Shape.Volume
are equal calls for referencing);Mass
(see previous steps), but for this use next Type
:Mass
property set the next expression:Density
, Volume
and Mass
as a "Read-only" properties to not mistakenly modify it in the future. To do that move pointer on each property and in context menu set "Read-only" and finally uncheck "Show all".Since now your FreeCAD project file would include Body
with defined Material
and Density
, and its Volume
and Mass
would be auto-calculated and re-calculated if choose another material from a drop-down list of available materials in Material
property.
FCStd-file for FreeCAD 0.21 available for free: patreon.com/posts/85447291
Thank You all for your support! buymeacoffee.com/app4soft
There are plenty of addons for FreeCAD that may help to calculate physical properties (e.g. Arch Survey, Macro FCInfo, etc.), but most of them are just calculators that does not store physical properties in the project file.
Actual tutorial has been designed to show how to make storable physical properties in FreeCAD 0.21 without installing any 3rd-party addons.