Line 38 is where the attached code experiences an error. Line 30 of "write_constraint_centrif.py" attempts to import a module called "six," which causes an error. I assume this is associated with Line 38 of the attached code. I'm sorry if this is a dumb question, I'm a mechanical engineering student a little over my head in the coding. Any guidance would be appreciated!
Code: Select all
# Embed freeCAD into the python IDE
FREECADPATH = 'C:/Program Files/FreeCAD 0.20/bin'
import sys
sys.path.append(FREECADPATH)
# Import in the actual packages from freeCAD
import FreeCAD as App
import FreeCADGui
#import FreeCADGui
# import function to make a new file
import library as lib
# name the file directory properly; requires just a file name
# and the actual directory to save the file to
fileDirectory = "C://FreeCAD Files//"
fileName = "testingSaveFile"
# make a new file
lib.newFile(fileDirectory, fileName)
# Make a box. In the actual code, this is handled by newLandingLeg()
doc = App.activeDocument()
box = doc.addObject("Part::Box", "myBox")
box.Length = 4
box.Width = 8
box.Height = 24
box.Placement = App.Placement(App.Vector(1,2,3), App.Rotation(75, 60, 30))
# recompute should ensure everything renders correctly. right now, it doesn't work
doc.recompute
# Save document
doc.save()
# WORKING AS OF 2/5/2023
# Begin FEA
import ObjectsFem
# Copy pasted from wiki page: https://wiki.freecad.org/FEM_Tutorial_Python
# analysis
analysis_object = ObjectsFem.makeAnalysis(doc, "Analysis")
# solver (we gone use the well tested CcxTools solver object)
solver_object = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiX")
solver_object.GeometricalNonlinearity = 'linear'
solver_object.ThermoMechSteadyState = True
solver_object.MatrixSolverType = 'default'
solver_object.IterationsControlParameterTimeUse = False
analysis_object.addObject(solver_object)
# material
material_object = ObjectsFem.makeMaterialSolid(doc, "SolidMaterial")
mat = material_object.Material
mat['Name'] = "Steel-Generic"
mat['YoungsModulus'] = "210000 MPa"
mat['PoissonRatio'] = "0.30"
mat['Density'] = "7900 kg/m^3"
material_object.Material = mat
analysis_object.addObject(material_object)
# fixed_constraint
fixed_constraint = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
fixed_constraint.References = [(doc.Box, "Face1")]
analysis_object.addObject(fixed_constraint)
# force_constraint
force_constraint = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce")
force_constraint.References = [(doc.Box, "Face2")]
force_constraint.Force = 9000000.0
force_constraint.Direction = (doc.Box, ["Edge5"])
force_constraint.Reversed = True
analysis_object.addObject(force_constraint)