SkillAgentSearch skills...

GDML

FreeCAD GDML Workbench - AddonManager Installable

Install / Use

/learn @KeithSloan/GDML
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

FreeCAD GDML Workbench

Introduction

FreeCAD is a Free Libre Open Source multi-platform CAD/CAM/FEM suite. GDML stands for Geometry Description Markup Language and is an application-indepedent geometry description format based on XML. It can be used as the primary geometry implementation language as well providing a geometry data exchange format for existing applications.

The main use of GDML is with Nuclear Physics MonteCarlo Simulation programs GEANT4 and ROOT

The FreeCAD GDML Workbench can be used for:

  • Viewing
  • Creation
  • Modification

of GDML models.

Screenshots

Viewing CERN's LHCBVelo.gdml using the experimental FreeCAD LinkStage3 Daily branch:

LHCB1 LHCB2 LHCB3

Important Noticies

Import of OBJ file now use FC Mesh facility to create a GDMLMesh

  • See : https://github.com/KeithSloan/GDML/wiki/Import-of-OBJ-file.

Munthers presentation prepared for the 15th GEANT4 Space Users Workshop - NASA Pasadena

  • Video : https://www.youtube.com/watch?v=VrcFnbr1HLQ
  • PDF : https://github.com/KeithSloan/GDML/blob/Main/Presentation/GDML_Workbench_Pasadena_without_animation.pdf

New Gmsh facility - (12/22) Gmsh Min Tessellate

Uses a recent facility in Gmsh to Tessellate and then recombine facets, reducing the complexity of the mesh. Trivial example is that a cube will be 6 Quad Facets, rather than 12 Triangular Facets.

New branch loops

Munther has created a new branch which adds support for importing GDML files with loops. We would welcome feedback on any success or issues.

FreeCAD 0.20

Now FreeCAD 0.20 has been released.

The Default branch is now Main rather than master. Users should delete the GDML workbench and reinstall via the Addon manager

The Addon manager with FreeCAD 0.20 has the facility to select and change branches, so if you want to go back you can use this facility to select master

Use with Realthunders LinkDaily branch

  • You should also see a dramatic improvement especially with LinkDaily in import times with these builds.

Enhanced Rendering (on Realthunder's LinkDaily branch)

There is also the option to use enhanced rendering which helps with complex models. To enable enhanced rendering in LinkDaily:

FreeCAD > Preferences > Display > Render Cache > Experimental

If you like what you see you might like to thank Lei Zhang by contributing to his FreeCAD Patreon

** Changes to Placement (GDML Position & Rotation) **

Export of GDML objects the Position and Rotation are now a combination of the Placement of the FreeCAD App::Part (GDML Volume) and the Placement of the GDMLObject

** New experimental export for GEMC**

Installation

Prerequisites

  • FreeCAD (https://freecad.org/)
  • lxml (bundled in to FreeCAD v0.19)
  • gmsh python library

gmsh python library

The workbench uses the gmsh python library and must be installed in a location that FreeCAD sees The python version of the library needs to match the one being used by Python

To check path FreeCAD uses from a command line/window.

freecad -c
import sys
print(sys.path)

In a command window / line

pip install --upgrade --target <Full path to directory> gmsh

Windows: if no --target option upgrade pip

Sucessful installation on MacOS for FreeCAD 1.0.0

As FreeCAD 1.0.0 is using python3.11.10

Install python3.11 on Mac using

homebrew python@3.11

Then installed rhino3dm

pip install rhino3dm

Then in FreeCAD path with the --no-cache option

python3.11 -m pip install rhino3dm --upgrade -t'/Applications/FreeCAD 1.0.0.app/Contents/Resources/lib/python3.11/site-packages' --no-cache
Collecting rhino3dm
  Downloading rhino3dm-8.9.0-cp311-cp311-macosx_14_0_universal2.whl.metadata (1.3 kB)
Downloading rhino3dm-8.9.0-cp311-cp311-macosx_14_0_universal2.whl (8.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.4/8.4 MB 4.3 MB/s eta 0:00:00
Installing collected packages: rhino3dm
Successfully installed rhino3dm-8.9.0

Successful installation of workbench & gmsh on Windows.

User @poroserv reports successful installation as follows

"today I installed the new GDML Workbench 2.0.0 without any problem."

Below I have compiled a sequence of magic spells to get a working version FreeCAD/GDML/GMSH for Windows:

Install "only for me" to "D:\FreeCAD 0.20" to prevent any file/folder access problems.

Upgrade/Install additional python modules:

D:\FreeCAD 0.20\bin\python -m pip install --upgrade pip
D:\FreeCAD 0.20\bin\python -m pip install --target="D:\FreeCAD 0.20\bin\Lib\site-packages" --upgrade lxml
D:\FreeCAD 0.20\bin\python -m pip install --target="D:\FreeCAD 0.20\bin\Lib\site-packages" --upgrade gmsh
D:\FreeCAD 0.20\bin\python -m pip install -i https://gmsh.info/python-packages --force-reinstall --no-cache-dir --upgrade --target="D:\FreeCAD 0.20\bin\Lib\site-packages" gmsh-dev

Download the Software Development Kit (SDK) for Windows of GMSH from https://gmsh.info/bin/Windows/gmsh-4.10.5-Windows64-sdk.zip , unpack it and copy:

..\bin to "D:\FreeCAD 0.20\bin\Lib\site-packages\bin"

..\include to "D:\FreeCAD 0.20\bin\Lib\site-packages\include"

..\lib to "D:\FreeCAD 0.20\bin\Lib\site-packages"

to add the missed "gmsh.exe", "gmsh-4.10.dll" and update "gmsh.py".

install GDML workbench.

Install via the Addon Manager

The GDML workbench can be installed via the Addon Manager

  1. Start FreeCAD
  2. Click the ToolsAddon manager dropdown menu
  3. Browse through the list of workbench and look for GDML

Prerequisite 3rd party Python libraries

<details> <summary>Click to expand!</summary>

Currently there are two 3rd party libraries that are necessary for the GDML workbench to function: lxml and gmsh.

lxml

lxml is a Python library that processes XML and HTML. Starting with the below versions of FreeCAD, lxml should be auto-bundled as part of the installation:

  • FreeCAD_0.19.19424 and above
  • FreeCAD_0.19.19409_x64_Conda_Py3QT5-WinVS2015.7z and above.
Checking if lxml is installed

To discover if lxml is installed and accessible by FreeCAD:

  1. Open the CLI
  2. Invoke the following:
    freecad -c
    import sys
    print(sys.path)
    
    Result:

Note: To check if lxml is installed correctly:

freecad -c
import lxml
from lxml import etree
print(etree.LXML_VERSION)
Manual install of lxml

In case there is a need to manually install lxml:

pip3 install lxml -t < directory >

Gmsh

Gmsh is an open source 3D finite element mesh generator. FreeCAD & Gmsh should both be using the same version of OCC (OpenCasCade), the underlying CAD kernel that FreeCAD uses.

| OCC | FreeCAD | gmsh | |---------|-------------|---------------| | 7.4 | 0.19.1 |4.7.0 - 4.7.1| | 7.6 | |4.8.0 - 4.8.4|

At the time of writing a prebuilt version of FreeCAD with OCC 7.6 is not available

Note: The version of OCC with FreeCAD 0.19.2 has a regression with STEP functionality

You can check the version FreeCAD is using with About FreeCAD, copy to clipboard, paste.

Checking what version of Gmsh is installed

To ascertain the Gmsh version, paste the following in to the python console

import gmsh
gmsh.initialize()
print(gmsh.option.getString("General.BuildInfo"))
gmsh.finalize()

Check the Gmsh version using gmshVer.py

It is also possible to run the gmshVer.py script (available in this workbench's Utils directory). To see what versions of Gmsh are available to install, open the CLI and type:

pip install gmsh==

Note: Gmsh must be installed in a location that FreeCAD can access. To check the path FreeCAD uses, open the CLI and type:

freecad -c
import sys
print(sys.path)

In a command window / line

pip install --upgrade --target <Full path to directory> gmsh=='version'

Windows: if no --target option upgrade pip

python -m pip install -U pip
    

For example on Windows system where FreeCAD is installed on the D drive

pip install --target="D:\FreeCAD 0.19\FreeCAD_0.19\bin\Lib\site-packages" gmsh

will create

D:\FreeCAD 0.19\FreeCAD_0.19\bin\Lib\site-packages\gmsh-4.6.0-py3.8.egg-info
D:\FreeCAD 0.19\FreeCAD_0.19\bin\Lib\site-packages\Lib\site-packages\gmsh-4.6.0-Windows64-sdk
</details>

Usage

<details> <summary>FOLLOWING TO BE MOVED TO WIKI</summary>

Create a new GDML design

  1. Start FreeCAD
  2. Select the GDML workbench from the workbench dropdown menu.
  3. Select File > New
    Result: This will load the default GDML
View on GitHub
GitHub Stars70
CategoryDevelopment
Updated19d ago
Forks18

Languages

Python

Security Score

80/100

Audited on Mar 14, 2026

No findings