KeithSloan / GDML

FreeCAD GDML Workbench - AddonManager Installable
Other
50 stars 17 forks source link

improvement in setMaterial #7

Closed lambdam94 closed 4 years ago

lambdam94 commented 4 years ago

Hello Keith

in def setMaterial(obj, m) in GDMLObject, could you please replace "if len(MaterialsList)>0" by " if (MaterialsList != []) and (MaterialsList != None):" Thanks!

In https://gitlab.cern.ch/VecGeom/VecGeom/tree/master/persistency/gdml/gdmls, there are some pb in the gdml test files without material.

Regards Damien

KeithSloan commented 4 years ago

Many Thanks - Please can you let me know one of the examples without materials so I can test

Thanks for the suggested code, wondering if obj.materials has to be set even if not in file.

So thinking of this coding

     def setMaterial(obj, m)
         #print('setMaterial')
         if MaterialsList != None :
             obj.material = MaterialsList
             obj.material = 0
             if len(MaterialsList) > 0 :
                  if not ( m == 0 or m == None ) :
                      obj.material = MaterialsList.index(m)
         else :
             obj.Material = 0

What do you think?

lambdam94 commented 4 years ago

Hello Keith

https://gitlab.cern.ch/VecGeom/VecGeom/-/blob/master/persistency/gdml/gdmls/oneSphere.gdml has not material It is only a test file

Regards Dam

Le ven. 24 avr. 2020 à 16:02, Keith Sloan notifications@github.com a écrit :

Many Thanks - Please can you let me know one of the examples without materials.

Thanks for the suggested code, wondering if obj.materials has to be set even if not in file.

So thinking of this coding `` def setMaterial(obj, m) :

print('setMaterial')

if MaterialsList != None : obj.material = MaterialsList obj.material = 0 if len(MaterialsList) > 0 : if not ( m == 0 or m == None ) : obj.material = MaterialsList.index(m) else : obj.Material = 0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KeithSloan/GDML/issues/7#issuecomment-619029319, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAHWHFO5OUOC4UVHXHKHQ3ROGLXPANCNFSM4MQDUSBA .

lambdam94 commented 4 years ago

In this case, MaterialsList == [], you should probably test "[]" and "none" cases, Regards Dam

lambdam94 commented 4 years ago

Ok with the last upgrade