Import .stp files in geant4

Hello, I’ve .stp files of detectors geometry.
Is it possible to import them in the detector construction to avoid to write all the c++ code?
I read I should convert the stp file to gdml one by GUIMesh…is it right?

Hello there,

There is something called “CADMesh”, which is a header file that lets you import .ply, .stl and .obj files as tesselated solids into your detector construction. I think importing a step-file is not part of Geant4 by default yet…

Take a look at this Gitrepo:
christopherpoole/CADMesh: A CAD file interface for GEANT4 (

It comes with examples, which show you how to import stuff.

BUT: As far as i know, you can NOT specify a material in a .stl-file so you import the geometry and then have to set a material in the Geant4 code. This could also slow down your simulation depending on how complex your geometry is.

This is where GDML comes in handy because it can have material properties.


Hi thank you MaxLoep.
Anyway, the experiment leader also found the gdml of the detectors. Then I will try to directly use them.

I worked with CADMesh for a recent project, and it worked quite well. I had to do that portion of the model in C++. I was able to combine the STL geometry with other elements coming from a GDML file.

It is possible to extend the capabilities of GDML by writing a custom schema file. It seems like it would be feasible to create a new type of solid that would take an STL file name for its geometry. But I have not done much with XML schemas, and did not have time to tackle such a feature.