Code: Select all
import FreeCAD
docpath = FreeCAD.ConfigGet("AppHomePath") + "data/examples/FemCalculixCantilever3D.FCStd"
doc = FreeCAD.open(docpath)
for o in doc.Objects:
print(o.Name)
analysis = doc.Analysis
solver = doc.CalculiX
from femtools import ccxtools
fea = ccxtools.FemToolsCcx(analysis, solver, test_mode=True)
fea.setup_working_dir()
error = fea.check_prerequisites()
fea.set_analysis_type("static")
error = fea.write_inp_file()
This works perfectly, however I still don't knw how to export the generated inp file. When I run your code in the console mode I can't see the inp text anywhere.bernd wrote: ↑Fri Jan 12, 2018 5:51 amtwo possibilities:
use the testmode which was implemented for unit tests: The sollowing works for me on FreeCAD 0.17.13005 (you have to have greater than 0.17.12995)
Code: Select all
import FreeCAD docpath = FreeCAD.ConfigGet("AppHomePath") + "data/examples/FemCalculixCantilever3D.FCStd" doc = FreeCAD.open(docpath) for o in doc.Objects: print(o.Name) analysis = doc.Analysis solver = doc.CalculiX from femtools import ccxtools fea = ccxtools.FemToolsCcx(analysis, solver, test_mode=True) fea.setup_working_dir() error = fea.check_prerequisites() fea.set_analysis_type("static") error = fea.write_inp_file()
Code: Select all
import Fem
Fem.export(u"C:/FreeCAD_0.17.13005_x64_dev_win/test.inp")
ah I didn't read the output thoroughly, the inp file is there in the working directory
Code: Select all
>>> import FreeCAD
>>> docupath = FreeCAD.ConfigGet("AppHomePath") + "result.FCStd"
>>>
>>> docu = FreeCAD.open(docupath)
>>> App.setActiveDocument("result")
>>> App.ActiveDocument=App.getDocument("result")
>>> Gui.ActiveDocument=Gui.getDocument("result")
>>>
>>> for o in docu.Objects:
... print(o.Name)
...
cube
Analysis
Calculix
SolidMaterial
FemConstraintDisplacement
FemConstraintInitialTemperature
FemConstraintHeatflux
FEMMeshGMSH
>>>
>>> analysis = docu.Analysis
>>> solver = docu.Calculix
>>>
>>> from femtools import ccxtools
>>> fea = ccxtools.FemToolsCcx(analysis, solver, test_mode=True)
Dir 'C:/FreeCAD_0.17.13005_x64_dev_win/bin/ccx.exe\' doesn't exist and cannot be created.
Dir 'c:\users\diodwi~1\appdata\local\temp' will be used instead.
FemToolsCCx.setup_working_dir() --> self.working_dir = c:\users\diodwi~1\appdata\local\temp
>>> fea.setup_working_dir()
Dir 'C:/FreeCAD_0.17.13005_x64_dev_win/bin/ccx.exe\' doesn't exist and cannot be created.
Dir 'c:\users\diodwi~1\appdata\local\temp' will be used instead.
FemToolsCCx.setup_working_dir() --> self.working_dir = c:\users\diodwi~1\appdata\local\temp
>>> error = fea.check_prerequisites()
SolidMaterial has Solid reference shapes.
>>> fea.set_analysis_type("thermomech")
>>> error = fea.write_inp_file()
FemInputWriterCcx --> self.dir_name --> c:\users\diodwi~1\appdata\local\temp\
FemInputWriterCcx --> self.main_file_name --> FEMMeshGMSH.inp
FemInputWriterCcx --> self.file_name --> c:\users\diodwi~1\appdata\local\temp\FEMMeshGMSH.inp
Constraint displacement: FemConstraintDisplacement
nodes will be retrieved by searching the appropriate nodes in the FEM mesh
ReferenceShape ... Type: Face, Object name: cube, Object label: cube, Element name: Face1
Writing time input file: 0.119304669422
Code: Select all
fea.setup_working_dir('YourOwnSpecialInputFilePath')
top!bernd wrote: ↑Mon Jan 15, 2018 1:08 pm![]()
if you pass a path with set working dir you can set it to any dir you like
Code: Select all
fea.setup_working_dir('YourOwnSpecialInputFilePath')
Code: Select all
Traceback (most recent call last): (100.0 %)
File "test.py", line 14, in <module>
solver = doc.CalculiX
AttributeError: 'App.Document' object has no attribute 'CalculiX'