-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to create new geometry in GDML workbench #132
Comments
Are you following https://github.com/KeithSloan/GDML/wiki/Model_Creation ? That is the workflow of Activate GDML Workbench Should give you a structure that looks like From the error messages it looks like you are using the Ellipse Command and it is not finding the Materials Group that is setup by the above workflow and it is trying to correct for this i.e. buildDefaultDoc function Objects line 87 and there is a problem with this recovery action. I will look into this but would be good if you could confirm. A file save after the initial setup should look like |
I tried to recreate your problem by deleting the Materials Group and then using the Ellipsoid Command but it did not fail. Please could you send me a complete copy of the Report View from your FreeCAD
|
Again looking at the last error in your report
I am wondering if there is a bug in the Windows version of lxml Would be good if you could confirm if your system correctly sets up the initial environment after Please could you report your level of lxml From FC in the Python console
|
"I can import gmsh and lXML from the freecad command line" Is lXML a typo? library should be lxml ( In lower case), maybe you are defaulting to xml rather than lxml. Even if yes it would be a bug in that should not fail but if you are defaulting to xml as a result, it would help me track things down - Thanks |
>>> import lxml
>>> print(lxml.__version__)
5.2.2 this is my version of lxml. |
""Would be good if you could confirm if your system correctly sets up the initial environment after Do you get errors if you just activate the workbench and start a new file. |
I'm sure I have an interface that looks the same as yours. Because I added the gdml workbench directly from the add-on manager instead of gdml (another plugin). |
This is the error reported by the report view when I only open the workbench and create a new file |
Not sure why my Mac version of lxml 4.9.2 is so far behind, latest is 5.2.2 as you have. I will try and upgrade to 5.2.2 to see if I can recreate Get current path to lxml in FC python console import lxml from outside FC pip3 install lxml="version" -t 'path as noted from above' I would try 4.9.3 |
I just tried 5.2.2 on my system and did not have a problem
|
>>> import lxml
>>> print(lxml.__version__)
4.9.2 Yes, I rolled back to 4.9.2 and the error did not change. I also checked the getroot method in the XML and found that it has not changed since Python 3.8. |
Thanks for report. view 16:21:55 Activated The messages 16:22:05 running with etree.ElementTree (import limitations) Mean it is not finding lxml and defaulting to xml and it is xml that is barfing Yet it appears you can use lxml from the FC console |
The projects in my combo view are somewhat different from yours. My combo view only have Constants, Variables, and Quantities.I'm trying to figure out if I made any foolish operational mistakes. |
Is it possible that there are some lXML dependency libraries that I did not install successfully? I will check this.Although I installed it using pip。 >>> import lxml
>>> print(lxml.__version__)
4.9.2
>>> from lxml import etree
Traceback (most recent call last):
File "<input>", line 1, in <module>
ImportError: cannot import name 'etree' from 'lxml' (E:\software\freecad\bin\lib\site-packages\lxml\__init__.py)
‘’‘
I will cofirm and reply
thank you for your help, i am appreciate |
The messages and dropping to xml come from
so if you have lxml but it is failing to find xtree, that would explain a lot. |
yes I think this is problem,I will make sure all of dependency of lxml and I can import etree. |
I have completed my installation and would like to share my installation steps. Firstly, regarding the installation process you mentioned in README.txt. D:\FreeCAD 0.20\bin\python -m pip install --target="D:\FreeCAD 0.20\bin\Lib\site-packages" --upgrade gmsh
D:\FreeCAD 0.20\bin\python -m pip install -i https://gmsh.info/python-packages --force-reinstall --no-cache-dir --upgrade --target="D:\FreeCAD 0.20\bin\Lib\site-packages" gmsh-dev This is no problem, but when you go https://gmsh.info/bin/Windows/gmsh-4.10.5-Windows64-sdk.zip Download the package, the version of your pip download may not be consistent with the version you downloaded directly from this website, which will result in an import gmsh error.This is no problem, but when you go https://gmsh.info/bin/Windows/gmsh-4.10.5-Windows64-sdk.zip Download the package. The version of your pip download may not be consistent with the version you downloaded directly from this website, which may result in an import gmsh error. Therefore, you need to confirm your gmsh version and provide it in the https://gmsh.info/bin/Windows/ download. D:\FreeCAD 0.20\bin\python -m pip install --target="D:\FreeCAD 0.20\bin\Lib\site-packages" --upgrade lxml After the successful installation of PIP, you need to check whether the import lXML from Etree and import lXML from HTML can succeed. If not, you can refer to my experience. I created a new virtual environment using Conda, and the Python version of this virtual environment is consistent with Freecad's Python. Then, I used PIP to install lXML in this environment and confirmed that there are no issues with the use of lXML in this environment. Then, I copied all the files in the site-package folder of this environment to Freecad's site-package. |
Thanks for your feedback. Can I ask if you ever tried to install just by using the Addon Manager? i.e. Rather than having to run pip commands, you tried FreeCAD | Tools | Addon Manager Select the GDML Workbench and responded to the install python dependencies button. I would be very interested to know if the errors you encounter also occurred using the Addon Manager |
I use new computer test the Addon Manager install dependencies.It can open workbench sucessfully,It means lxml install is sucessfully, but i think it need to to add the missed "gmsh.exe", "gmsh-4.10.dll" and update "gmsh.py" .Because there will be a prompt in the report view that gmsh-4.10.dll cannot be found. 10:29:22 time : 0.3697 seconds
10:44:10 PropertyPythonObject::toString(): failed for <class 'freecad.gdml.GDMLObjects.GDMLconstant'>
10:44:10 Traceback (most recent call last):
File "E:\software\freecad\bin\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "E:\software\freecad\bin\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "E:\software\freecad\bin\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "E:\software\freecad\bin\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
<class 'TypeError'>: Object of type FeaturePython is not JSON serializable
10:44:10 PropertyPythonObject::toString(): failed for <class 'freecad.gdml.GDMLObjects.GDMLconstant'>
10:44:10 Traceback (most recent call last):
File "E:\software\freecad\bin\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "E:\software\freecad\bin\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True) you can see 10:29:22 is my last operation and i do nothing until 10:44 report these error。 |
I think these error may cause geant4 to not be able to read the corresponding materials when reading the gdml file, which means that there is no material content when exporting the gdml file from freecad. I want to know if this is my personal operational issue. I followed the instructions on the wiki. G4GDML: Reading '123.gdml'...
G4GDML: VALIDATION ERROR! ID attribute 'G4_BGO' is referenced but was never declared at line: 34
G4GDML: VALIDATION ERROR! ID attribute 'G4_AIR' is referenced but was never declared at line: 34 and this is gdml file which I export: <?xml version='1.0' encoding='ASCII'?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<define>
<constant name="HALFPI" value="pi/2."/>
<constant name="PI" value="1.*pi"/>
<constant name="TWOPI" value="2.*pi"/>
<position name="center" x="0" y="0" z="0" unit="mm"/>
<rotation name="identity" x="0" y="0" z="0"/>
</define>
<materials/>
<solids>
<box name="WorldBox" x="200.0" y="200.0" z="200.0" lunit="mm"/>
<torus name="GDMLTorus" rmin="10.0" rmax="50.0" rtor="50.0" startphi="10.0" deltaphi="360.0" aunit="deg" lunit="mm"/>
</solids>
<structure>
<volume name="LV_Torus">
<materialref ref="G4_BGO"/>
<solidref ref="GDMLTorus"/>
<auxiliary auxtype="Color" auxvalue="#ff780000"/>
</volume>
<volume name="worldVOL">
<materialref ref="G4_AIR"/>
<solidref ref="WorldBox"/>
<physvol name="PV-LV_Torus">
<volumeref ref="LV_Torus"/>
<positionref ref="center"/>
<rotationref ref="identity"/>
</physvol>
</volume>
</structure>
<setup name="Default" version="1.0">
<world ref="worldVOL"/>
</setup>
</gdml> I think it lack of materials definition. |
Geant4 knows of all the the predefined (e.g. NIST) materials. The VALIDATION ERROR is because of the Schema checking and can be ignored unless in your Geant4 installation |
If you need the material definitions for software other than Geant4, then there is a configuration setting to have G4 Material definitions exported. Test file exported with option set. |
Yes, thank you for your reply. I have successfully exported the first gdml file and read it out in geant4。I am currently trying to import STP format files into Freecad and convert them using Tessellate via Gmsh. 15:12:46 Running the Python command 'TessellateCommand' failed:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\GDMLCommands.py", line 2341, in Activated
vol = createPartVol(obj)
createPartVol() missing 1 required positional argument: 'doc' Is this related to the complexity of my model? This is a file containing sixteen clover type HPGe detectors. |
Sorry that is a bug that has crept in. createPartVol should have had a default of FreeCAD.ActiveDoument i.e. Please try the latest version. def createPartVol(obj, doc=FreeCAD.ActiveDocument, selection=False) |
Have you considered using Arrays with GDMLObjects? see https://github.com/KeithSloan/GDML/wiki#arrays-of-objects Arrays are exported as MultiUnions and if you can avoid the need to Tessellate will be much faster to process. |
The workbench uses Part::FeaturePython for GDML Objects and these get saved and loaded with JSON |
Sorry, there have been experiments these days and no response has been received.I am unable to upload my project because the maximum size is limited to 26MB.If you want to use it for testing, please give me an email. 09:09:36 Traceback (most recent call last):
File "<string>", line 8, in <module>
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 3052, in export
exportGDMLworld(first, filepath, fileExt)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 2818, in exportGDMLworld
exportGDML(first, filepath, fileExt)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 2752, in exportGDML
exportWorldVol(first, fileExt)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 2679, in exportWorldVol
processVolAssem(vol, xmlParent, WorldVOL)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 2343, in processVolAssem
processVolume(vol, xmlParent, psPlacement, isPhysVol, volName=None)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 2202, in processVolume
solidExporter = SolidExporter.getExporter(topObject)
File "C:\Users\Administrator\AppData\Roaming\FreeCAD\Mod\GDML\.\freecad\gdml\exportGDML.py", line 3193, in getExporter
typeId = obj.Proxy.Type
<class 'AttributeError'>: 'GDMLTessellated' object has no attribute 'Type' |
My email address is at the bottom of the README, just replace [at] with @ and [dot] with . |
i have another problem that when I just open the workbench and create a geometry without doing anything, my report view will report this error.
Not sure why that is happening, somehow one of the constant values is being corrupted, I you open a new file in the Workbench the first Group should be "Constants" If you click on Constants you should see |
09:09:36 Traceback (most recent call last): Found a bug in that Type was not being set if the Gui was not up, could it have been created using the command line? if you email me the file I can fix. |
What version of FreeCAD are you using? There are problems with files created with FreeCAD 0.21.2 |
version 0.21.2 |
ok,i will try later and feedback, now I have other work to do. |
Thank you for your response to my previous question,and I have a new problem.I feel like I have successfully installed the GDML workbench. I can import gmsh and lXML from the freecad command line, but when I create any geometry in the workbench, this error will be reported.
The text was updated successfully, but these errors were encountered: