OpenGATE / opengate

Gate 10 (beta)
http://www.opengatecollaboration.org
GNU Lesser General Public License v3.0
42 stars 38 forks source link

Is there any way to use the default `opengate/contrib/GateMaterials.db` in my simulation? #337

Open nkrah opened 7 months ago

nkrah commented 7 months ago
          Is there any way to use the default `opengate/contrib/GateMaterials.db` in my simulation? 

I wrote a custom function add_default_material_database(sim) in opengate/contrib/__init__.py in my local installation of opengate. Is there a better way to use the default GateMaterials?

Function add_default_material_database(sim)
import pathlib
def add_default_material_database(sim):

    # Assuming your base directory is where your script or application is located
    base_directory = pathlib.Path(__file__).resolve().parent

    # Define the path to the "opengate.contrib" folder
    opengate_contrib_folder = base_directory / "opengate.contrib"

    sim.volume_manager.add_material_database(pathlib.Path(__file__).resolve().parent / "GateMaterials.db")

Originally posted by @franky180 in https://github.com/OpenGATE/opengate/issues/325#issuecomment-1892288031