Can i run a GDML file that contains gdml file names of other detector part?

Hello Experts,
I have a object and it have 3-4 sub-part. all sub-parts are in the 3-4 different STL files and using this GitHub - tihonav/cad-to-geant4-converter: A light-weight tool for converting CAD drawings into the GDML format. i have converted all the stl files into gdml files that gives me a gdml file (including all gdml files of sub part of the object).
but when i compile the final file in geant4 to visualize it, it is not compiling.
actually i am trying to visualize the example given on this link in geant4 after changing them (from stl to gdml )but not able to do this why or is there any way to compile these type of examples in geant4 ?
Can anyone please tell me the reason behind this. i will be very grateful for this help.
Thanks in advance!

Can you post the final GDML file that does not compile? Or share via Dropbox or A.N.O

Thank you @KeithSloan for your reply!
actually i am trying to compile the example given on this link after changing those stl files into gdml files using the method given on this link.
can you please check on this link below-
GitHub - tihonav/cad-to-geant4-converter: A light-weight tool for converting CAD drawings into the GDML format.
DAM_EQM_CornerPlastic.gdml.txt (1.3 MB)
DAM_EQM_CornerPlastic.gdml.txt (1.3 MB)
DAM_EQM_INSERT_Aluminum.gdml.txt (3.9 MB)
test_model.gdml.txt (20.5 KB)
DAM_EQM_LshapeSIMPL_CarbonFibre.gdml.txt (2.5 MB)

since, i am able to compile these gdml files separately by including world definition and material but i am not able to see the below geometry completely.
how can i get this ?

Sorry for the delay in getting back to you.

Does not look like your screen shot but would your model look anything like

When you say it does not compile, do you get any error/warning messages or does it just appear to be looping, just wondering if you need to give it more time.

Need to work on the workflow, but I used my FreeCAD GDML workbench to import your files separately and then export as single GDML file, you could give it a try, but as you are dealing with a lot of tessellations I suspect that you might need to consume a number or tea/coffees.

Files are too large for this forum so here is a link to them on Dropbox Dropbox - For_Priyanshu - Simplify your life
Should find a single combined GDML file and a saved FreeCAD version.
Let me know if you have any luck.

Your test_model.gdml refers to DAM_EQM_CornerAluminum.gdml but you did not upload this file, but you did upload CornerPlastic twice

The GDML manual

Page 39 describes Multiple files.

I note that you have structure and setup defined in your child files, don’t know if that is an issue or not,
might be worth trying with the structure as per page 39

Latest version of FreeCAD GDML workbench should load your multiple files all be it very slowly. You can then always export as a single GDML file. Then you can test if it is something in your file structure that is causing an issue or your model.

yes, it gives me this error

yes,as you shared the combined file, i will run it in Geant then result will let you know, thank you for this .

oh yes, actually, there are so many files in my system, i didn’t see, BTW i am sharing it now. please find below:-

sure, i will look into this, thanks for sharing this.


Might be wrong but I think you are getting the error because you have multiple Setup’s i.e. one in test_model.gdml and one in each of the files included by <physvol file …>

means i have to remove "setup"from all the child files ?
and put only this test_model.gdml file, is it ?

I believe that is correct.

Or you could just load into FreeCAD GDML workbench, it ignores any Setup in child files and then export, which will create a single file, with just the one Setup.

Your model with the missing file

And exported as a single gdml file Dropbox - test_model-world.gdml - Simplify your life

yes, i run this combined gdml file in the geant but it gives me so many many validation errors!
see some attached screenshots below-

Thanks - Something weird is going on it barfs about attribute not declared element not declared but If I check the line numbers with an editor the GDML looks fine

yes, i also don’t understand what’s going on with this really !
BTW Thank you for giving your precious time on this.

The gdml.xsd is required for the validation. “G4GDML : Validation”
In this case, the link to that file doesn’t work.
You can add this file in the same directory as an easy workpass
gdml.xsd is in geant4 distribution: /source/persistency/gdml/schema
Could you try ?


Thanks for your reply!
i have just copy-paste this gdml.xsd file in my build directory (where i am working) and run my combined file after putting this there, it is giving me same results as earlier i showed to @KeithSloan
are you saying the same what i have done, right ? or please correct me if i have done wrong.

Damian Ask me to reply, he is suggesting


put all xsd file into your repository:


replace the beginning of your gdml file by:

  "<?xml version="1.0" encoding="UTF-8"?>
  <gdml xmlns:gdml=""

Now you should have “new” errors due to the check of the gdml file.


you should corrected your material definition.

The materials need to be defined by their formula (cf. Example geometry file)

For example, for the air material:

  "<element name="Oxygen" formula="O" Z="8."> <atom value="16.0"/>
   <element name="Nitrogen" formula="N" Z="7."> <atom value="14.01"/>
   <material name="Air">
   <D value="1.290" unit="mg/cm3"/>
   <fraction n="0.7" ref="Nitrogen"/>
   <fraction n="0.3" ref="Oxygen"/>

Is it better ?