Saving volume color to GDML with g4py environment

Is it possible to save the color of a logical volume to the GDML file when using the g4py environment? I would like the colors to be preserved when reading the GDML file in another C++ geant application. I’m doing the following:

# Export geometry to GDML file
from Geant4 import G4GDMLParser

gdml_parser = G4GDMLParser()
gdml_parser.Write('output/detector.gdml', detector.physical)

Then the GDML file contains the geometry and materials, but no colors or other auxiliary information:

<structure>
    <volume name="layer_00x7fe6cc741260">
      <materialref ref="G4_Cu0x7fe6cc737e70"/>
      <solidref ref="layer0x7fe6cc7411d0"/>
    </volume>
...
</structure>

For reference, I’m using Geant4.10.{5,6}.p0 on Mac OSX

1 Like

For other people who may be searching this question in the future.

Looks like it requires extending the GDML schema and adding special reader/writer for color attributes, like in the extended/persistency/gdml/G03 example.