KeithSloan / GDML

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

Can't add any objects, just the world volume gets exported. #11

Closed quantatanu closed 4 years ago

quantatanu commented 4 years ago

Hi,

I am very new to CAD/GDML/Geometry in general. I was able to create and export the WorldVolume but no other objects get saved:

GDMLElTube Object - added Running the Python command 'ElTubeCommand' failed: Traceback (most recent call last): File "/home/me/.FreeCAD/Mod/GDML/freecad/gdml/GDMLCommands.py", line 170, in Activated GDMLElTube(a,10,20,30,"mm",0) File "/home/me/.FreeCAD/Mod/GDML/freecad/gdml/GDMLObjects.py", line 613, in __init__ obj.ViewObject.ShapeColor = colourMaterial(material) File "/home/me/.FreeCAD/Mod/GDML/freecad/gdml/GDMLObjects.py", line 174, in colourMaterial coeffRGB = MaterialsList.index(m)

I was opening the saved GDML using a ROOT macro that opens other complex gdml files that I obtained from experts, I can see detailed structures. But in my case, despite adding objects like spheres, cones, etc inside the box, I just see an opaque box. I will really appreciate any help.

Thanks


Ubuntu 18.04 ROOT 6-20 python3 freecad installed through apt-get from stable ppa

KeithSloan commented 4 years ago

Hi unfortunately my computer had some tea and I have to wait for the end of lockdown to see if it is repairable, so currently high and dry. I have emailed Dam Lamb to ask if he can help. He is user lambdam94.

KeithSloan commented 4 years ago

“But in my case by adding objects I just see opaque box”

Is that box like a bounding box in a world volume?

If so then if you activate the GDML workbench one of the icons is cycle. Select the volume of the box and then click on the cycle icon, will(should) cycle though all objects in the volume , solid to wireframe to no display then back to solid.

KeithSloan commented 4 years ago

Looking at the trace back, think the problem maybe that creation of solid through the GUI, I.e using icons in the the workbench was before material support and colour was added, the problem may well be because there is no material allocated by default.

That is the GDMLEltube(a,10,20,30,”mm”,0). The last variable 0 is from memory the material (0 is supposed to be default. Until we can fix try making sure any object that you add has a valid material before trying to export. Hope that helps

quantatanu commented 4 years ago

Hi,

thank you so much for your prompt response.

I am adding a gif of what is going on with my freecad:

freecad_gdml

The material of the object shows up, by default steel or air, but on the "appearances" I can choose other materials. But ultimately doesn't get drawn.

"the problem may well be because there is no material allocated by default."

How can I add them in that case?

Thanks

KeithSloan commented 4 years ago

Think we need lambdam94 to look at this, especially as the colour code is his. You might try dropping back to a commit prior to colour being added. Sorry I cannot help more as I don’t have access to a unix machine at present

lambdam94 commented 4 years ago

Hello,

I think there are 2 pbs : 1- “But in my case by adding objects I just see opaque box” the opaque world box can be changed in "Display Mode" of the "GDMLBox_WorldBox" replace "Shaded" by "Wireframe" We will fix it in a previous version.

2- Color pb: In ~/FreeCAD/Mod/GDML/freecad/gdml/GDMLObjects.py on line172 please add: elif m not in MaterialsList: return (0.5,0.5,0.5) (be carefull of the good number of spaces before "elif": 7)

Does it fix your pbs? If it is ok, we will fix it for a next release.

Regards, Dam

KeithSloan commented 4 years ago

Have a new machine on order, hope to fix shortly after it gets delivered.

quantatanu commented 4 years ago

As I am like an infant in this whole business, your freecad+gdml is my hope.. thanks to both of you for everything.

So...

the opaque world box can be changed in "Display Mode" of the "GDMLBox_WorldBox" replace "Shaded" by "Wireframe" We will fix it in a previous version.

That's the first thing I did, the opacity is not a problem in the freecad display, on freecad "wireframe" makes the box transparent but when I open the exported GDML using ROOT, it's completely opaque.

And:

image

Now I can add objects to the world, this is how it looks:

image

You can see that it's a "Wireframe"

But, this is how it looks on ROOT...

image

KeithSloan commented 4 years ago

That is correct all boxes/objects in ROOT/Geant4 will display as opaque/solid. It is just that is not very convenient for viewing things that we set the default display of the World GDML object, box or sphere or what ever to wireframe. For checking things I use a program called gdmlview ( need to build from source, think I got it from Jefferson repro) it has a facility to switch from solid to wireframe and does it for the whole model. Remember that you are dealing with Monte Carlo modelling of particles and things like protons and other sub particles that don’t respect boundaries/walls they still go through them

KeithSloan commented 4 years ago

Can I check your scenario.

Am I correct that you are taking an existing file importing that and then adding a few solids and then exporting and that is when you initially hit the problems.

If yes then I think we still have an issue to think about. Adding solids via the GUI assumes that the default gdml is loaded. It contains the stainless steal material definition.

When you loaded your sample file it will have bought in its material definitions which probably don’t contain the stainless steel. You add things via GUI and with Dam’s fix hopefully the model will export, but the exported file may well have an object that references a material that does not exist in the materials section of the file and therefore ROOT/Geant4 will not be happy about this. I think we therefore have some thinking to do.

lambdam94 commented 4 years ago

In your GDMLSphere name, could you add the 'GDMLSphere' prefix? For example 'GDMLSpheremySphere' It seems working for my simple case under freecad and root.

KeithSloan commented 4 years ago

Just as a point of reference, the reason for names in FreeCAD starting with GDML is so that the user can tell that they are GDML solids implemented as FreeCAD objects, rather than FreeCAD box, sphere, etc

lambdam94 commented 4 years ago

With the "GDML" prefix, it seems working well:

image

quantatanu commented 4 years ago

@KeithSloan no I am creating an entirely new file. @lambdam94 it's by default.. names already have that prefix.

By the way, I am facing a new problem, list index out of range, what does that mean? I haven't seen this before! My object is entirely inside the world box, also the material is by default "SSteel" and the world is made of "G4_Air" (there are no other choices though! Unless I go to "appearances", but does that change material though?)

Please check out the attached gif.

freecad_gdml_2020-05-14_15-51

quantatanu commented 4 years ago

By the way, here, the instructions are different, it's an independent installation, while I installed through freecad addon manager. Should I remove the GDML addon and try the git method? Maybe you have a bug-free newer version on git now?

quantatanu commented 4 years ago

Or, do you have a list that of material/objects that I can add to some file, that might fix this list index out of range issue?

KeithSloan commented 4 years ago

By the way, here, the instructions are different, it's an independent installation, while I installed through freecad addon manager. Should I remove the GDML addon and try the git method? Maybe you have a bug-free newer version on git now?

That is the old version of the workbench it is a different repository. It has even more bugs. You are better off with this repro.

KeithSloan commented 4 years ago

@KeithSloan no I am creating an entirely new file. @lambdam94 it's by default.. names already have that prefix.

By the way, I am facing a new problem, list index out of range, what does that mean? I haven't seen this before! My object is entirely inside the world box, also the material is by default "SSteel" and the world is made of "G4_Air" (there are no other choices though! Unless I go to "appearances", but does that change material though?)

Please check out the attached gif.

freecad_gdml_2020-05-14_15-51

This is a bug in that export has changed to remove the leading GDMLname, so that importing and exporting matched. The code to add an item via the GUI does not allow for this and hence the bug, sorry about this. New machine is on its way. Hope to fix shortly after it arrives.

KeithSloan commented 4 years ago

Or, do you have a list that of material/objects that I can add to some file, that might fix this list index out of range issue?

It’s a bug the name created by the GUI should have more info as export now splits off the leading GDMLname

quantatanu commented 4 years ago

And what does Cannot compute Inventor representation for the shape of GDMLSphere mean?

lambdam94 commented 4 years ago

By default the names haven't the full prefix with the "underscore". "underscore" should be added to the prefix. Replace "GDMLTube" by "GDMLTube_mytube01" Replace "GDMLBox" by "GDMLBoxmybox01" etc. Today, only the name part after "" is used in the exported gdml file. exemple

quantatanu commented 4 years ago

I don't know what happened, I just did the following:

  1. Original label was GDMLBox_WorldBox I removed it and renamed it back the same.
  2. Did the same for the part objects, it was GDMLSphere, this time I changed it to GDMLSphere_mySphere

Either both 1 and 2, or one of them solved my problems. This is what I see on ROOT now:

image

quantatanu commented 4 years ago

By default the names haven't the full prefix with the "underscore". "underscore" should be added to the prefix. Replace "GDMLTube" by "GDMLTube_mytube01" Replace "GDMLBox" by "GDMLBoxmybox01" etc. Today, only the name part after "" is used in the exported gdml file. exemple

Ah, I saw your reply only now! But somehow did what you suggested.

quantatanu commented 4 years ago

Let me keep this issue open for a few more days...so that nothing bad pops up.. and maybe in the meanwhile, you might provide a newer and better version.

quantatanu commented 4 years ago

Also, how can we add more materials, currently:

image

KeithSloan commented 4 years ago

Let me keep this issue open for a few more days...so that nothing bad pops up.. and maybe in the meanwhile, you might provide a newer and better version.

Can only update when my new machine arrives. It is on it way

KeithSloan commented 4 years ago

And what does Cannot compute Inventor representation for the shape of GDMLSphere mean?

Means something went wrong with the Code that draws the Sphere

KeithSloan commented 4 years ago

New machine should arrive tomorrow some time. In the mean time I have created a new branch quanta and edited via the web, so untested. Tries to fix name and material not in list. Have to find where World_Box is created in the code. Extra materials etc can be added by editing the Default.gdml file in the Resources directory. Will try and add the facility to import xml file that gets parsed and added to current environment, but that will wait for new machine to arrive. Thank you for your patience and testing

quantatanu commented 4 years ago

Thanks a ton for all the help! I will keep checking for updates...

quantatanu commented 4 years ago

Hi,

2- Color pb: In ~/FreeCAD/Mod/GDML/freecad/gdml/GDMLObjects.py on line172 please add: elif m not in MaterialsList: return (0.5,0.5,0.5) (be carefull of the good number of spaces before "elif": 7)

I just removed and added back GDML through Freecad tools->Addons Manager, and had the problem of 0 not in list and remembered, I had add that line suggested by @lambdam94 , and it fixed the problem. So, this bug is still there or the GDML available through Addons Manager is the old one, and I have to manually git clone the new version?

KeithSloan commented 4 years ago

Hi,

2- Color pb: In ~/FreeCAD/Mod/GDML/freecad/gdml/GDMLObjects.py on line172 please add: elif m not in MaterialsList: return (0.5,0.5,0.5) (be carefull of the good number of spaces before "elif": 7)

I just removed and added back GDML through Freecad tools->Addons Manager, and had the problem of 0 not in list and remembered, I had add that line suggested by @lambdam94 , and it fixed the problem. So, this bug is still there or the GDML available through Addons Manager is the old one, and I have to manually git clone the new version?

The only update I did was via the web to a branch called Quanta - Which had errors.

My new machine has now arrived and I am now able to test changes.

Have pushed updates to master and hopefully things will be better. Still have to fix the worldbox being opaque/Solid, suggest you select and click on cycle icon before adding Part/Volume.

Let me know if there are still problems.

Thanks for your patience, just a bit of bad luck that my machine had died just as you found the bugs.

KeithSloan commented 4 years ago

Okay - latest master should fix the worldbox being shaded. If you could confirm all now fixed so that I can close. Thanks

quantatanu commented 4 years ago

Yes, it's perfect now, thanks! Btw, about the material, when I add an object, in the property section, I see just air and steel like before, but in the appearance section I am able to choose various materials, as I was also able to do this before, I am guessing the choice of materials through the appearance option should work too?

image

KeithSloan commented 4 years ago

Thanks for the heads up on Material. Your scene capture shows the property for selecting a FreeCAD material ( As would be used by FEM etc ) which at the current time is different from GDML material.

I will have to put thinking hat on as to the best way to handle what at the moment are two different definitions of material.

I am currently working on materials, there is now a new branch materials. It is still under active development, but with it you should be able to select the Materials group and export to an XML file. The next step is to be able to import such an XML file. The idea being that you could export the materials from an existing file like one of the CERN examples and use in a new file that you are creating.

KeithSloan commented 4 years ago

The latest version of branch materials allows one to select materials and export an XML file of just material definitions. The XML file can now be imported into an existing file.

quantatanu commented 4 years ago

Thanks a lot. I was unavailable for the past few days and couldn't check your response or apply the solution. I will try it out soon.

KeithSloan commented 2 years ago

For ways to add more materials see issue #73.

lambdam94 commented 2 years ago

Hello keith Sorry for the delay

I think users want to manage a local material database. I.e. one more database. We need to Add and delete materials Delete is already included in Freecad GI. You need to manage the 'add material' based on the G4 single atom for the first step ( it Will complete most ofthe material question). Add material needs: density List of g4 atom and ratio (number or mass)

Regards Dam

Le lun. 28 févr. 2022 à 08:22, Keith Sloan @.***> a écrit :

For ways to add more materials see issue #73 https://github.com/KeithSloan/GDML/issues/73.

— Reply to this email directly, view it on GitHub https://github.com/KeithSloan/GDML/issues/11#issuecomment-1053961509, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAHWHHN4P43PSCHCF4HBODU5MPBXANCNFSM4M6OMQBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>