How to export with different units?

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
DarkwingDuck
Posts: 2
Joined: Sun Oct 23, 2022 6:51 pm

How to export with different units?

Post by DarkwingDuck »

I'm using FreeCAD V0.20 for creating geometry for FEA. My workflow now is to use FreeCAD to create the geometry and then I export to BREP format. I then read in the file and create the mesh using Gmsh. The mesh is then imported and used by the FEA software. The issue that I've encountered is that the length units for the FEA software are "m". Gmsh does not have units so it does nothing to the scaling of geometry. FreeCAD seems to be exporting everything in the default units of "mm". So far I haven't found a way for this workflow to get the right FEA units without making the incorrect geometry in FreeCAD first (I have to scale everything down by a factor of 1000 in order to get the right exported geometry so something that is 1 m in my geometry would have to be created as 1 mm in FreeCAD).

I've searched to see if there are solutions to this but so far I haven't found any. Changing the document units in preferences doesn't seem to change the export units. I'm wondering if I've missed something? Is there a workflow where I can create the correct geometry in FreeCAD and get an export in units of "m"? Thanks.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: How to export with different units?

Post by Kunda1 »

Mod edit: Moved to FEM subforum
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
NewJoker
Veteran
Posts: 3018
Joined: Sun Oct 11, 2020 7:49 pm

Re: How to export with different units?

Post by NewJoker »

Try changing the "Units for export of STEP" (assuming that you will use this most common universal CAD format) in Preferences —> Import-Export.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: How to export with different units?

Post by bernd »

In STEP this seam to work, but with STEP you might loose information. AFAIK STEP does not support CompSolids. For BREP export I am not aware of a solution in the gui.

But with python it should be just a few lines of code to scale and export a objekt. This could be copied in a macro and given an icon and you are fine ...
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: How to export with different units?

Post by bernd »

Code: Select all

# create some geometry to have something to export
import Part
box = Part.makeBox(10,10,10)
#
from os.path import join
the_path = "C:/Users/BHA/Desktop"
#
box.exportBrep(join(the_path, "box_mm.brep"))
box.scale(1000).exportBrep(join(the_path, "box_m.brep"))
DarkwingDuck
Posts: 2
Joined: Sun Oct 23, 2022 6:51 pm

Re: How to export with different units?

Post by DarkwingDuck »

NewJoker wrote: Sun Oct 23, 2022 8:56 pm Try changing the "Units for export of STEP" (assuming that you will use this most common universal CAD format) in Preferences —> Import-Export.
Thanks. I had previously tried this setting and generated STEP files for importing to Gmsh. When I tried this out I had found that the units setting for STEP export was not having any impact on the resulting geometry imported into Gmsh. At the time I was under the impression that Gmsh was unit-less in the treatment of geometry but, after reviewing the generated STEP files, it seems that they are indeed different when created with the different export options and that Gmsh is doing some conversion on import depending on the unit description in the STEP files. So I think the STEP file with the "m" export option will work for me after I set the correct Gmsh option. Thanks very much.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: How to export with different units?

Post by bernd »

Keep in mind ... Step does not support compsolids
Post Reply