예제 #1
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geometry objects
    # two boxes
    boxlow = doc.addObject("Part::Box", "BoxLower")
    boxupp = doc.addObject("Part::Box", "BoxUpper")
    boxupp.Placement.Base = (0, 0, 10)

    # boolean fragment of the two boxes
    bf = SplitFeatures.makeBooleanFragments(name="BooleanFragments")
    bf.Objects = [boxlow, boxupp]
    bf.Mode = "CompSolid"
    doc.recompute()
    bf.Proxy.execute(bf)
    bf.purgeTouched()
    if FreeCAD.GuiUp:
        for child in bf.ViewObject.Proxy.claimChildren():
            child.ViewObject.hide()
    doc.recompute()

    # extract CompSolid by compound filter tool
    geom_obj = CompoundFilter.makeCompoundFilter(name="MultiMatCompSolid")
    geom_obj.Base = bf
    geom_obj.FilterType = "window-volume"
    geom_obj.Proxy.execute(geom_obj)
    geom_obj.purgeTouched()
    if FreeCAD.GuiUp:
        geom_obj.Base.ViewObject.hide()
    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0]
    elif solvertype == "ccxtools":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0]
        solver_object.WorkingDir = u""
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.SplitInputWriter = False
        solver_object.AnalysisType = "static"
        solver_object.GeometricalNonlinearity = "linear"
        solver_object.ThermoMechSteadyState = False
        solver_object.MatrixSolverType = "default"
        solver_object.IterationsControlParameterTimeUse = False

    # material
    material_object_low = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialLow"))[0]
    mat = material_object_low.Material
    mat["Name"] = "Aluminium-Generic"
    mat["YoungsModulus"] = "70000 MPa"
    mat["PoissonRatio"] = "0.35"
    mat["Density"] = "2700  kg/m^3"
    material_object_low.Material = mat
    material_object_low.References = [(boxlow, "Solid1")]
    analysis.addObject(material_object_low)

    material_object_upp = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialUpp"))[0]
    mat = material_object_upp.Material
    mat["Name"] = "Steel-Generic"
    mat["YoungsModulus"] = "200000 MPa"
    mat["PoissonRatio"] = "0.30"
    mat["Density"] = "7980 kg/m^3"
    material_object_upp.Material = mat
    material_object_upp.References = [(boxupp, "Solid1")]

    # fixed_constraint
    fixed_constraint = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed"))[0]
    fixed_constraint.References = [(geom_obj, "Face5")]

    # pressure_constraint
    pressure_constraint = analysis.addObject(
        ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure"))[0]
    pressure_constraint.References = [(geom_obj, "Face11")]
    pressure_constraint.Pressure = 1000.0
    pressure_constraint.Reversed = False

    # mesh
    from .meshes.mesh_boxes_2_vertikal_tetra10 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc,
                                                             mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc
예제 #2
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geom objects
    # bottom box
    bottom_box_obj = doc.addObject("Part::Box", "BottomBox")
    bottom_box_obj.Length = 100
    bottom_box_obj.Width = 5
    bottom_box_obj.Height = 1

    # top box
    top_box_obj = doc.addObject("Part::Box", "TopBox")
    top_box_obj.Length = 100
    top_box_obj.Width = 5
    top_box_obj.Height = 1
    top_box_obj.Placement = FreeCAD.Placement(
        Vector(0, 0, 1),
        Rotation(0, 0, 0),
        Vector(0, 0, 0),
    )
    doc.recompute()

    # all geom boolean fragment
    geom_obj = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
    geom_obj.Objects = [bottom_box_obj, top_box_obj]
    if FreeCAD.GuiUp:
        bottom_box_obj.ViewObject.hide()
        top_box_obj.ViewObject.hide()
    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0]
    elif solvertype == "ccxtools":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0]
        solver_object.WorkingDir = u""
    elif solvertype == "elmer":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0]
        solver_object.SteadyStateMinIterations = 1
        solver_object.SteadyStateMaxIterations = 10
        eq_heat = ObjectsFem.makeEquationHeat(doc, solver_object)
        eq_heat.Bubbles = True
        eq_heat.Priority = 2
        eq_elasticity = ObjectsFem.makeEquationElasticity(doc, solver_object)
        eq_elasticity.Bubbles = True
        eq_elasticity.Priority = 1
        eq_elasticity.LinearSolverType = "Direct"
    else:
        FreeCAD.Console.PrintWarning(
            "Not known or not supported solver type: {}. "
            "No solver object was created.\n".format(solvertype))
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.AnalysisType = "thermomech"
        solver_object.GeometricalNonlinearity = "linear"
        solver_object.ThermoMechSteadyState = True
        # solver_object.MatrixSolverType = "default"
        solver_object.MatrixSolverType = "spooles"  # thomas
        solver_object.SplitInputWriter = False
        solver_object.IterationsThermoMechMaximum = 2000
        # solver_object.IterationsControlParameterTimeUse = True  # thermomech spine

    # material
    material_obj_bottom = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MaterialCopper"))[0]
    mat = material_obj_bottom.Material
    mat["Name"] = "Copper"
    mat["YoungsModulus"] = "130000 MPa"
    mat["PoissonRatio"] = "0.354"
    mat["SpecificHeat"] = "385 J/kg/K"
    mat["ThermalConductivity"] = "200 W/m/K"
    mat["ThermalExpansionCoefficient"] = "0.00002 m/m/K"
    mat["Density"] = "1.00 kg/m^3"
    material_obj_bottom.Material = mat
    material_obj_bottom.References = [(geom_obj, "Solid1")]
    analysis.addObject(material_obj_bottom)

    material_obj_top = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MaterialInvar"))[0]
    mat = material_obj_top.Material
    mat["Name"] = "Invar"
    mat["YoungsModulus"] = "137000 MPa"
    mat["PoissonRatio"] = "0.28"
    mat["SpecificHeat"] = "510 J/kg/K"
    mat["ThermalConductivity"] = "13 W/m/K"
    mat["ThermalExpansionCoefficient"] = "0.0000012 m/m/K"
    mat["Density"] = "1.00 kg/m^3"
    material_obj_top.Material = mat
    material_obj_top.References = [(geom_obj, "Solid2")]
    analysis.addObject(material_obj_top)

    # constraint fixed
    con_fixed = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed"))[0]
    con_fixed.References = [
        (geom_obj, "Face1"),
        (geom_obj, "Face7"),
    ]

    # constraint initial temperature
    constraint_initialtemp = analysis.addObject(
        ObjectsFem.makeConstraintInitialTemperature(
            doc, "ConstraintInitialTemperature"))[0]
    constraint_initialtemp.initialTemperature = 273.0

    # constraint temperature
    constraint_temperature = analysis.addObject(
        ObjectsFem.makeConstraintTemperature(doc, "ConstraintTemperature"))[0]
    constraint_temperature.References = [
        (geom_obj, "Face1"),
        (geom_obj, "Face2"),
        (geom_obj, "Face3"),
        (geom_obj, "Face4"),
        (geom_obj, "Face5"),
        (geom_obj, "Face7"),
        (geom_obj, "Face8"),
        (geom_obj, "Face9"),
        (geom_obj, "Face10"),
        (geom_obj, "Face11"),
    ]
    constraint_temperature.Temperature = 373.0
    constraint_temperature.CFlux = 0.0

    # mesh
    from .meshes.mesh_thermomech_bimetall_tetra10 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc,
                                                             mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geometry objects
    # TODO turn circle of upper tube to have the line on the other side
    # make a boolean fragment of them to be sure there is a mesh point on remesh
    # but as long as we do not remesh it works without the boolean fragment too

    # tubes
    tube_radius = 25
    tube_length = 500
    sh_lower_circle = Part.Wire(Part.makeCircle(tube_radius))
    sh_lower_tube = sh_lower_circle.extrude(FreeCAD.Vector(0, 0, tube_length))
    sh_lower_tube.reverse()
    lower_tube = doc.addObject("Part::Feature", "Lower_tube")
    lower_tube.Shape = sh_lower_tube

    sh_upper_circle = Part.Wire(Part.makeCircle(tube_radius))
    sh_upper_tube = sh_upper_circle.extrude(FreeCAD.Vector(0, 0, tube_length))
    sh_upper_tube.reverse()
    upper_tube = doc.addObject("Part::Feature", "Upper_tube")
    upper_tube.Shape = sh_upper_tube
    upper_tube.Placement = FreeCAD.Placement(
        FreeCAD.Vector(-25, 51, 475),
        FreeCAD.Rotation(90, 0, 90),
        FreeCAD.Vector(0, 0, 0),
    )

    # point for load
    v_force_pt = FreeCAD.Vector(0, 76, 475)
    sh_force_point = Part.Vertex(v_force_pt)
    force_point = doc.addObject("Part::Feature", "Load_place_point")
    force_point.Shape = sh_force_point
    if FreeCAD.GuiUp:
        force_point.ViewObject.PointSize = 10.0
        force_point.ViewObject.PointColor = (1.0, 0.0, 0.0)

    # boolean fragment of upper tubo and force point
    boolfrag = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
    boolfrag.Objects = [upper_tube, force_point]
    if FreeCAD.GuiUp:
        upper_tube.ViewObject.hide()

    # compound out of bool frag and lower tube
    geom_obj = doc.addObject("Part::Compound", "AllGeomCompound")
    geom_obj.Links = [boolfrag, lower_tube]

    # line for load direction
    sh_load_line = Part.makeLine(v_force_pt, FreeCAD.Vector(0, 150, 475))
    load_line = doc.addObject("Part::Feature", "Load_direction_line")
    load_line.Shape = sh_load_line
    if FreeCAD.GuiUp:
        load_line.ViewObject.LineWidth = 5.0
        load_line.ViewObject.LineColor = (1.0, 0.0, 0.0)

    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0]
    elif solvertype == "ccxtools":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0]
        solver_object.WorkingDir = u""
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.AnalysisType = "static"
        solver_object.BeamShellResultOutput3D = True
        solver_object.GeometricalNonlinearity = "linear"  # really?
        # TODO iterations parameter !!!
        solver_object.ThermoMechSteadyState = False
        solver_object.MatrixSolverType = "default"
        solver_object.IterationsControlParameterTimeUse = False
        solver_object.SplitInputWriter = False

    # shell thickness
    analysis.addObject(
        ObjectsFem.makeElementGeometry2D(doc, 0.5, 'ShellThickness'))

    # material
    material_obj = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial"))[0]
    mat = material_obj.Material
    mat["Name"] = "AlCuMgPb"
    mat["YoungsModulus"] = "72000 MPa"
    mat["PoissonRatio"] = "0.30"
    material_obj.Material = mat
    analysis.addObject(material_obj)

    # fixed_constraint
    fixed_constraint = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed"))[0]
    fixed_constraint.References = [
        (lower_tube, "Edge2"),
        (upper_tube, "Edge3"),
    ]

    # force_constraint
    force_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0]
    # TODO use point of tube boolean fragment
    force_constraint.References = [(force_point, "Vertex1")]
    force_constraint.Force = 5000.0
    force_constraint.Direction = (load_line, ["Edge1"])
    force_constraint.Reversed = True

    # contact constraint
    contact_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintContact(doc, name="ConstraintContact"))[0]
    contact_constraint.References = [
        (lower_tube, "Face1"),
        (upper_tube, "Face1"),
    ]
    contact_constraint.Friction = 0.0
    # contact_constrsh_aint.Slope = "1000000.0 kg/(mm*s^2)"  # contact stiffness
    contact_constraint.Slope = 1000000.0  # should be 1000000.0 kg/(mm*s^2)

    # mesh
    from .meshes.mesh_contact_tube_tube_tria3 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc,
                                                             mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc
예제 #4
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geometry objects
    # cones cut
    cone_outer_sh = Part.makeCone(1100, 1235, 1005, Vector(0, 0, 0),
                                  Vector(0, 0, 1), 359)
    cone_inner_sh = Part.makeCone(1050, 1185, 1005, Vector(0, 0, 0),
                                  Vector(0, 0, 1), 359)
    cone_cut_sh = cone_outer_sh.cut(cone_inner_sh)
    cone_cut_obj = doc.addObject("Part::Feature", "Cone_Cut")
    cone_cut_obj.Shape = cone_cut_sh

    # lines
    line_fix_sh = Part.Edge(
        Part.LineSegment(Vector(0, -1235, 1005), Vector(0, -1185, 1005)))
    line_fix_obj = doc.addObject("Part::Feature", "Line_Fix")
    line_fix_obj.Shape = line_fix_sh
    line_force_sh = Part.Edge(
        Part.LineSegment(Vector(0, 1185, 1005), Vector(0, 1235, 1005)))
    line_force_obj = doc.addObject("Part::Feature", "Line_Force")
    line_force_obj.Shape = line_force_sh

    geom_obj = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
    geom_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj]
    if FreeCAD.GuiUp:
        cone_cut_obj.ViewObject.hide()
        line_fix_obj.ViewObject.hide()
        line_force_obj.ViewObject.hide()

    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0]
    elif solvertype == "ccxtools":
        solver_object = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0]
        solver_object.WorkingDir = u""
    else:
        FreeCAD.Console.PrintWarning(
            "Not known or not supported solver type: {}. "
            "No solver object was created.\n".format(solvertype))
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.AnalysisType = "static"
        solver_object.GeometricalNonlinearity = "linear"
        solver_object.ThermoMechSteadyState = False
        solver_object.MatrixSolverType = "default"
        solver_object.IterationsControlParameterTimeUse = False
        solver_object.SplitInputWriter = False

    # material
    material_obj = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial"))[0]
    mat = material_obj.Material
    mat["Name"] = "Calculix-Steel"
    mat["YoungsModulus"] = "210000 MPa"
    mat["PoissonRatio"] = "0.30"
    material_obj.Material = mat
    analysis.addObject(material_obj)

    # constraint fixed
    con_fixed = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed"))[0]
    con_fixed.References = [(geom_obj, "Edge1")]

    # constraint force
    con_force = doc.Analysis.addObject(
        ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0]
    con_force.References = [(geom_obj, "Edge2")]
    con_force.Force = 10000.0  # 10000 N = 10 kN
    con_force.Direction = (geom_obj, ["Edge2"])
    con_force.Reversed = False

    # constraint tie
    con_tie = doc.Analysis.addObject(
        ObjectsFem.makeConstraintTie(doc, name="ConstraintTie"))[0]
    con_tie.References = [
        (geom_obj, "Face5"),
        (geom_obj, "Face7"),
    ]
    con_tie.Tolerance = 25.0

    # mesh
    from .meshes.mesh_constraint_tie_tetra10 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc,
                                                             mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc
예제 #5
0
    def Activated(self):
        try:
            # Save object name that will be divided.
            selection = Gui.Selection.getSelectionEx()
            if (len(selection) < 1):
                # An object must be selected
                errMessage = "Select an object to use Split Tool"
                faced.getInfo(selection).errorDialog(errMessage)
                return
            shape = selection[0].Object.Shape
            bb = shape.BoundBox
            length = max(bb.XLength, bb.YLength, bb.ZLength)

            nameOfselectedObject = selection[0].ObjectName
            totalName = nameOfselectedObject + '_cs'
            """ slow function . . you need to use wait before getting 
				the answer as the execution is continuing down """
            Gui.runCommand('Part_CrossSections', 0)
            gcompund = App.ActiveDocument.addObject("Part::Compound",
                                                    "Compound")

            App.ActiveDocument.recompute()

            # get object name
            # We need this delay to let user choose the split form. And
            getExtrude_cs = None  # Dummy variable used to wait for the Extrude_cs be made
            while (getExtrude_cs is None):
                getExtrude_cs = App.ActiveDocument.getObject(totalName)
                _sleep(.1)
                Gui.updateGui()
            # Begin command Part_Compound
            gcompund.Links = [
                getExtrude_cs,
            ]

            # Begin command Part_BooleanFragments
            j = SPLIT.makeBooleanFragments(name='BooleanFragments')
            j.Objects = [
                gcompund,
                App.ActiveDocument.getObject(nameOfselectedObject)
            ]
            j.Mode = 'Standard'
            j.Proxy.execute(j)
            j.purgeTouched()
            App.ActiveDocument.recompute()
            if j.isValid() == False:
                App.ActiveDocument.removeObject(j.Name)
                # Shape is not OK
                errMessage = "Failed to fillet the objects"
                faced.getInfo(selection).errorDialog(errMessage)
            else:
                # Make a simple copy
                newShape = Part.getShape(j,
                                         '',
                                         needSubElement=False,
                                         refine=False)
                NewJ = App.ActiveDocument.addObject(
                    'Part::Feature', 'SplitedObject').Shape = newShape
                # Remove Old objects
                for obj in j.Objects:
                    App.ActiveDocument.removeObject(obj.Name)
                App.ActiveDocument.removeObject(totalName)
                App.ActiveDocument.removeObject(j.Name)

            App.ActiveDocument.recompute()
        except Exception as err:
            App.Console.PrintError("'SplitObject' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
예제 #6
0
def setup(doc=None, solvertype="ccxtools"):

    # init FreeCAD document
    if doc is None:
        doc = init_doc()

    # explanation object
    # just keep the following line and change text string in get_explanation method
    manager.add_explanation_obj(
        doc, get_explanation(manager.get_header(get_information())))

    # geometric object
    plate = doc.addObject("Part::Plane", "Plate")
    plate.Width = 10
    plate.Length = 10
    force_pt1 = doc.addObject("Part::Vertex", "ForcePT1")
    force_pt1.X = 10
    force_pt1.Y = 2
    force_pt2 = doc.addObject("Part::Vertex", "ForcePT2")
    force_pt2.X = 10
    force_pt2.Y = 4
    force_pt3 = doc.addObject("Part::Vertex", "ForcePT3")
    force_pt3.X = 10
    force_pt3.Y = 6
    force_pt4 = doc.addObject("Part::Vertex", "ForcePT4")
    force_pt4.X = 10
    force_pt4.Y = 8
    doc.recompute()

    # all geom boolean fragment
    geom_obj = SplitFeatures.makeBooleanFragments(name='ThePointPlate')
    geom_obj.Objects = [plate, force_pt1, force_pt2, force_pt3, force_pt4]
    doc.recompute()
    if FreeCAD.GuiUp:
        plate.ViewObject.hide()
        force_pt1.ViewObject.hide()
        force_pt2.ViewObject.hide()
        force_pt3.ViewObject.hide()
        force_pt4.ViewObject.hide()
    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.PointSize = 10
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
    elif solvertype == "ccxtools":
        solver_obj = ObjectsFem.makeSolverCalculixCcxTools(
            doc, "CalculiXccxTools")
        solver_obj.WorkingDir = u""
    elif solvertype == "elmer":
        solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
        ObjectsFem.makeEquationElasticity(doc, solver_obj)
    elif solvertype == "mystran":
        solver_obj = ObjectsFem.makeSolverMystran(doc, "SolverMystran")
    elif solvertype == "z88":
        solver_obj = ObjectsFem.makeSolverZ88(doc, "SolverZ88")
    else:
        FreeCAD.Console.PrintWarning(
            "Not known or not supported solver type: {}. "
            "No solver object was created.\n".format(solvertype))

    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_obj.SplitInputWriter = False
        solver_obj.AnalysisType = "static"
        solver_obj.GeometricalNonlinearity = "linear"
        solver_obj.ThermoMechSteadyState = False
        solver_obj.MatrixSolverType = "default"
        solver_obj.IterationsControlParameterTimeUse = False
    analysis.addObject(solver_obj)

    # shell thickness
    thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 0.3, 'Thickness')
    analysis.addObject(thickness_obj)

    # material
    material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
    mat = material_obj.Material
    mat["Name"] = "CalculiX-Steel"
    mat["YoungsModulus"] = "210000 MPa"
    mat["PoissonRatio"] = "0.30"
    material_obj.Material = mat
    analysis.addObject(material_obj)

    # constraint fixed
    con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
    con_fixed.References = [(geom_obj, "Edge1")]
    analysis.addObject(con_fixed)

    # constraint force
    con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
    con_force.References = [
        (geom_obj, "Vertex7"),
        (geom_obj, "Vertex1"),
        (geom_obj, "Vertex2"),
        (geom_obj, "Vertex3"),
        (geom_obj, "Vertex4"),
        (geom_obj, "Vertex8"),
    ]
    con_force.Force = 600  # 600 N on six nodes == 100 N/Node
    con_force.Reversed = False
    con_force.Direction = (geom_obj, ["Edge2"])
    analysis.addObject(con_force)

    # mesh
    from .meshes.mesh_plate_mystran_quad4 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(
        ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False
    femmesh_obj.CharacteristicLengthMax = "1.0 mm"
    femmesh_obj.ElementDimension = "2D"
    femmesh_obj.ElementOrder = "1st"

    doc.recompute()
    return doc
def setup(doc=None, solvertype="ccxtools"):

    # init FreeCAD document
    if doc is None:
        doc = init_doc()

    # explanation object
    # just keep the following line and change text string in get_explanation method
    manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

    # geometric objects
    # two boxes
    boxlow = doc.addObject("Part::Box", "BoxLower")
    boxupp = doc.addObject("Part::Box", "BoxUpper")
    boxupp.Placement.Base = (0, 0, 10)

    # boolean fragment of the two boxes
    bf = SplitFeatures.makeBooleanFragments(name="BooleanFragments")
    bf.Objects = [boxlow, boxupp]
    bf.Mode = "CompSolid"
    doc.recompute()
    bf.Proxy.execute(bf)
    bf.purgeTouched()
    doc.recompute()
    if FreeCAD.GuiUp:
        for child in bf.ViewObject.Proxy.claimChildren():
            child.ViewObject.hide()

    # extract CompSolid by compound filter tool
    geom_obj = CompoundFilter.makeCompoundFilter(name="MultiMatCompSolid")
    geom_obj.Base = bf
    geom_obj.FilterType = "window-volume"
    geom_obj.Proxy.execute(geom_obj)
    geom_obj.purgeTouched()
    if FreeCAD.GuiUp:
        bf.ViewObject.hide()
    doc.recompute()

    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
    elif solvertype == "ccxtools":
        solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
        solver_obj.WorkingDir = u""
    else:
        FreeCAD.Console.PrintWarning(
            "Not known or not supported solver type: {}. "
            "No solver object was created.\n".format(solvertype)
        )
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_obj.SplitInputWriter = False
        solver_obj.AnalysisType = "static"
        solver_obj.GeometricalNonlinearity = "linear"
        solver_obj.ThermoMechSteadyState = False
        solver_obj.MatrixSolverType = "default"
        solver_obj.IterationsControlParameterTimeUse = False
    analysis.addObject(solver_obj)

    # materials
    material_obj_low = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialLow")
    mat = material_obj_low.Material
    mat["Name"] = "Aluminium-Generic"
    mat["YoungsModulus"] = "70000 MPa"
    mat["PoissonRatio"] = "0.35"
    material_obj_low.Material = mat
    material_obj_low.References = [(boxlow, "Solid1")]
    analysis.addObject(material_obj_low)

    material_obj_upp = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialUpp")
    mat = material_obj_upp.Material
    mat["Name"] = "Steel-Generic"
    mat["YoungsModulus"] = "200000 MPa"
    mat["PoissonRatio"] = "0.30"
    material_obj_upp.Material = mat
    material_obj_upp.References = [(boxupp, "Solid1")]
    analysis.addObject(material_obj_upp)

    # constraint fixed
    con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
    con_fixed.References = [(geom_obj, "Face5")]
    analysis.addObject(con_fixed)

    # constraint pressure
    con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
    con_pressure.References = [(geom_obj, "Face11")]
    con_pressure.Pressure = 1000.0
    con_pressure.Reversed = False
    analysis.addObject(con_pressure)

    # mesh
    from .meshes.mesh_boxes_2_vertikal_tetra10 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False

    doc.recompute()
    return doc
예제 #8
0
def setup(doc=None, solvertype="ccxtools"):

    # init FreeCAD document
    if doc is None:
        doc = init_doc()

    # explanation object
    # just keep the following line and change text string in get_explanation method
    manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

    # geometric object
    # load line
    load_line = doc.addObject("Part::Line", "LoadLine")
    load_line.X1 = 0
    load_line.Y1 = 0
    load_line.Z1 = 1000
    load_line.X2 = 0
    load_line.Y2 = 0
    load_line.Z2 = 0
    if FreeCAD.GuiUp:
        load_line.ViewObject.hide()

    # commands where generated by Python out of the original Z88 Mesh obj data
    v1 = vec(0.0, 2000.0, 0.0)
    v2 = vec(0.0, 0.0, 0.0)
    v3 = vec(1000.0, 1000.0, 2000.0)
    v4 = vec(2000.0, 2000.0, 0.0)
    v5 = vec(2000.0, 0.0, 0.0)
    v6 = vec(3000.0, 1000.0, 2000.0)
    v7 = vec(4000.0, 2000.0, 0.0)
    v8 = vec(4000.0, 0.0, 0.0)
    v9 = vec(5000.0, 1000.0, 2000.0)
    v10 = vec(6000.0, 2000.0, 0.0)
    v11 = vec(6000.0, 0.0, 0.0)
    v12 = vec(7000.0, 1000.0, 2000.0)
    v13 = vec(8000.0, 2000.0, 0.0)
    v14 = vec(8000.0, 0.0, 0.0)
    v15 = vec(9000.0, 1000.0, 2000.0)
    v16 = vec(10000.0, 2000.0, 0.0)
    v17 = vec(10000.0, 0.0, 0.0)
    v18 = vec(11000.0, 1000.0, 2000.0)
    v19 = vec(12000.0, 2000.0, 0.0)
    v20 = vec(12000.0, 0.0, 0.0)
    line1 = makeLine(v1, v2)
    line2 = makeLine(v4, v5)
    line3 = makeLine(v7, v8)
    line4 = makeLine(v10, v11)
    line5 = makeLine(v13, v14)
    line6 = makeLine(v16, v17)
    line7 = makeLine(v19, v20)
    line8 = makeLine(v1, v4)
    line9 = makeLine(v2, v5)
    line10 = makeLine(v4, v7)
    line11 = makeLine(v5, v8)
    line12 = makeLine(v7, v10)
    line13 = makeLine(v8, v11)
    line14 = makeLine(v10, v13)
    line15 = makeLine(v11, v14)
    line16 = makeLine(v13, v16)
    line17 = makeLine(v14, v17)
    line18 = makeLine(v16, v19)
    line19 = makeLine(v17, v20)
    line20 = makeLine(v1, v3)
    line21 = makeLine(v4, v6)
    line22 = makeLine(v7, v9)
    line23 = makeLine(v10, v12)
    line24 = makeLine(v13, v15)
    line25 = makeLine(v16, v18)
    line26 = makeLine(v2, v3)
    line27 = makeLine(v5, v6)
    line28 = makeLine(v8, v9)
    line29 = makeLine(v11, v12)
    line30 = makeLine(v14, v15)
    line31 = makeLine(v17, v18)
    line32 = makeLine(v3, v4)
    line33 = makeLine(v6, v7)
    line34 = makeLine(v9, v10)
    line35 = makeLine(v12, v13)
    line36 = makeLine(v15, v16)
    line37 = makeLine(v18, v19)
    line38 = makeLine(v3, v5)
    line39 = makeLine(v6, v8)
    line40 = makeLine(v9, v11)
    line41 = makeLine(v12, v14)
    line42 = makeLine(v15, v17)
    line43 = makeLine(v18, v20)
    line44 = makeLine(v3, v6)
    line45 = makeLine(v6, v9)
    line46 = makeLine(v9, v12)
    line47 = makeLine(v12, v15)
    line48 = makeLine(v15, v18)
    line49 = makeLine(v2, v4)
    line50 = makeLine(v5, v7)
    line51 = makeLine(v8, v10)
    line52 = makeLine(v11, v13)
    line53 = makeLine(v14, v16)
    line54 = makeLine(v17, v19)
    obj_line1 = doc.addObject("Part::Feature", "Line1")
    obj_line1.Shape = line1
    obj_line2 = doc.addObject("Part::Feature", "Line2")
    obj_line2.Shape = line2
    obj_line3 = doc.addObject("Part::Feature", "Line3")
    obj_line3.Shape = line3
    obj_line4 = doc.addObject("Part::Feature", "Line4")
    obj_line4.Shape = line4
    obj_line5 = doc.addObject("Part::Feature", "Line5")
    obj_line5.Shape = line5
    obj_line6 = doc.addObject("Part::Feature", "Line6")
    obj_line6.Shape = line6
    obj_line7 = doc.addObject("Part::Feature", "Line7")
    obj_line7.Shape = line7
    obj_line8 = doc.addObject("Part::Feature", "Line8")
    obj_line8.Shape = line8
    obj_line9 = doc.addObject("Part::Feature", "Line9")
    obj_line9.Shape = line9
    obj_line10 = doc.addObject("Part::Feature", "Line10")
    obj_line10.Shape = line10
    obj_line11 = doc.addObject("Part::Feature", "Line11")
    obj_line11.Shape = line11
    obj_line12 = doc.addObject("Part::Feature", "Line12")
    obj_line12.Shape = line12
    obj_line13 = doc.addObject("Part::Feature", "Line13")
    obj_line13.Shape = line13
    obj_line14 = doc.addObject("Part::Feature", "Line14")
    obj_line14.Shape = line14
    obj_line15 = doc.addObject("Part::Feature", "Line15")
    obj_line15.Shape = line15
    obj_line16 = doc.addObject("Part::Feature", "Line16")
    obj_line16.Shape = line16
    obj_line17 = doc.addObject("Part::Feature", "Line17")
    obj_line17.Shape = line17
    obj_line18 = doc.addObject("Part::Feature", "Line18")
    obj_line18.Shape = line18
    obj_line19 = doc.addObject("Part::Feature", "Line19")
    obj_line19.Shape = line19
    obj_line20 = doc.addObject("Part::Feature", "Line20")
    obj_line20.Shape = line20
    obj_line21 = doc.addObject("Part::Feature", "Line21")
    obj_line21.Shape = line21
    obj_line22 = doc.addObject("Part::Feature", "Line22")
    obj_line22.Shape = line22
    obj_line23 = doc.addObject("Part::Feature", "Line23")
    obj_line23.Shape = line23
    obj_line24 = doc.addObject("Part::Feature", "Line24")
    obj_line24.Shape = line24
    obj_line25 = doc.addObject("Part::Feature", "Line25")
    obj_line25.Shape = line25
    obj_line26 = doc.addObject("Part::Feature", "Line26")
    obj_line26.Shape = line26
    obj_line27 = doc.addObject("Part::Feature", "Line27")
    obj_line27.Shape = line27
    obj_line28 = doc.addObject("Part::Feature", "Line28")
    obj_line28.Shape = line28
    obj_line29 = doc.addObject("Part::Feature", "Line29")
    obj_line29.Shape = line29
    obj_line30 = doc.addObject("Part::Feature", "Line30")
    obj_line30.Shape = line30
    obj_line31 = doc.addObject("Part::Feature", "Line31")
    obj_line31.Shape = line31
    obj_line32 = doc.addObject("Part::Feature", "Line32")
    obj_line32.Shape = line32
    obj_line33 = doc.addObject("Part::Feature", "Line33")
    obj_line33.Shape = line33
    obj_line34 = doc.addObject("Part::Feature", "Line34")
    obj_line34.Shape = line34
    obj_line35 = doc.addObject("Part::Feature", "Line35")
    obj_line35.Shape = line35
    obj_line36 = doc.addObject("Part::Feature", "Line36")
    obj_line36.Shape = line36
    obj_line37 = doc.addObject("Part::Feature", "Line37")
    obj_line37.Shape = line37
    obj_line38 = doc.addObject("Part::Feature", "Line38")
    obj_line38.Shape = line38
    obj_line39 = doc.addObject("Part::Feature", "Line39")
    obj_line39.Shape = line39
    obj_line40 = doc.addObject("Part::Feature", "Line40")
    obj_line40.Shape = line40
    obj_line41 = doc.addObject("Part::Feature", "Line41")
    obj_line41.Shape = line41
    obj_line42 = doc.addObject("Part::Feature", "Line42")
    obj_line42.Shape = line42
    obj_line43 = doc.addObject("Part::Feature", "Line43")
    obj_line43.Shape = line43
    obj_line44 = doc.addObject("Part::Feature", "Line44")
    obj_line44.Shape = line44
    obj_line45 = doc.addObject("Part::Feature", "Line45")
    obj_line45.Shape = line45
    obj_line46 = doc.addObject("Part::Feature", "Line46")
    obj_line46.Shape = line46
    obj_line47 = doc.addObject("Part::Feature", "Line47")
    obj_line47.Shape = line47
    obj_line48 = doc.addObject("Part::Feature", "Line48")
    obj_line48.Shape = line48
    obj_line49 = doc.addObject("Part::Feature", "Line49")
    obj_line49.Shape = line49
    obj_line50 = doc.addObject("Part::Feature", "Line50")
    obj_line50.Shape = line50
    obj_line51 = doc.addObject("Part::Feature", "Line51")
    obj_line51.Shape = line51
    obj_line52 = doc.addObject("Part::Feature", "Line52")
    obj_line52.Shape = line52
    obj_line53 = doc.addObject("Part::Feature", "Line53")
    obj_line53.Shape = line53
    obj_line54 = doc.addObject("Part::Feature", "Line54")
    obj_line54.Shape = line54
    doc.recompute()
    geom_obj = SplitFeatures.makeBooleanFragments(name="CraneTruss")
    geom_obj.Objects = [
        obj_line1,
        obj_line2,
        obj_line3,
        obj_line4,
        obj_line5,
        obj_line6,
        obj_line7,
        obj_line8,
        obj_line9,
        obj_line10,
        obj_line11,
        obj_line12,
        obj_line13,
        obj_line14,
        obj_line15,
        obj_line16,
        obj_line17,
        obj_line18,
        obj_line19,
        obj_line20,
        obj_line21,
        obj_line22,
        obj_line23,
        obj_line24,
        obj_line25,
        obj_line26,
        obj_line27,
        obj_line28,
        obj_line29,
        obj_line30,
        obj_line31,
        obj_line32,
        obj_line33,
        obj_line34,
        obj_line35,
        obj_line36,
        obj_line37,
        obj_line38,
        obj_line39,
        obj_line40,
        obj_line41,
        obj_line42,
        obj_line43,
        obj_line44,
        obj_line45,
        obj_line46,
        obj_line47,
        obj_line48,
        obj_line49,
        obj_line50,
        obj_line51,
        obj_line52,
        obj_line53,
        obj_line54,
    ]
    if FreeCAD.GuiUp:
        obj_line1.ViewObject.hide()
        obj_line2.ViewObject.hide()
        obj_line3.ViewObject.hide()
        obj_line4.ViewObject.hide()
        obj_line5.ViewObject.hide()
        obj_line6.ViewObject.hide()
        obj_line7.ViewObject.hide()
        obj_line8.ViewObject.hide()
        obj_line9.ViewObject.hide()
        obj_line10.ViewObject.hide()
        obj_line11.ViewObject.hide()
        obj_line12.ViewObject.hide()
        obj_line13.ViewObject.hide()
        obj_line14.ViewObject.hide()
        obj_line15.ViewObject.hide()
        obj_line16.ViewObject.hide()
        obj_line17.ViewObject.hide()
        obj_line18.ViewObject.hide()
        obj_line19.ViewObject.hide()
        obj_line20.ViewObject.hide()
        obj_line21.ViewObject.hide()
        obj_line22.ViewObject.hide()
        obj_line23.ViewObject.hide()
        obj_line24.ViewObject.hide()
        obj_line25.ViewObject.hide()
        obj_line26.ViewObject.hide()
        obj_line27.ViewObject.hide()
        obj_line28.ViewObject.hide()
        obj_line29.ViewObject.hide()
        obj_line30.ViewObject.hide()
        obj_line31.ViewObject.hide()
        obj_line32.ViewObject.hide()
        obj_line33.ViewObject.hide()
        obj_line34.ViewObject.hide()
        obj_line35.ViewObject.hide()
        obj_line36.ViewObject.hide()
        obj_line37.ViewObject.hide()
        obj_line38.ViewObject.hide()
        obj_line39.ViewObject.hide()
        obj_line40.ViewObject.hide()
        obj_line41.ViewObject.hide()
        obj_line42.ViewObject.hide()
        obj_line43.ViewObject.hide()
        obj_line44.ViewObject.hide()
        obj_line45.ViewObject.hide()
        obj_line46.ViewObject.hide()
        obj_line47.ViewObject.hide()
        obj_line48.ViewObject.hide()
        obj_line49.ViewObject.hide()
        obj_line50.ViewObject.hide()
        obj_line51.ViewObject.hide()
        obj_line52.ViewObject.hide()
        obj_line53.ViewObject.hide()
        obj_line54.ViewObject.hide()

    doc.recompute()
    if FreeCAD.GuiUp:
        geom_obj.ViewObject.Document.activeView().viewAxonometric()
        geom_obj.ViewObject.Document.activeView().fitAll()

    # analysis
    analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

    # solver
    if solvertype == "calculix":
        solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
    elif solvertype == "ccxtools":
        solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
        solver_obj.WorkingDir = u""
    elif solvertype == "z88":
        solver_obj = ObjectsFem.makeSolverZ88(doc, "SolverZ88")
    else:
        FreeCAD.Console.PrintWarning(
            "Not known or not supported solver type: {}. "
            "No solver object was created.\n".format(solvertype)
        )
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_obj.SplitInputWriter = False
        solver_obj.AnalysisType = "static"
        solver_obj.GeometricalNonlinearity = "linear"
        solver_obj.ThermoMechSteadyState = False
        solver_obj.MatrixSolverType = "default"
        solver_obj.IterationsControlParameterTimeUse = False
    analysis.addObject(solver_obj)

    # beam section
    beamsection_obj = ObjectsFem.makeElementGeometry1D(
        doc,
        sectiontype="Circular",
        height=25.0,
        name="CrossSectionCircular"
    )
    analysis.addObject(beamsection_obj)

    # material
    material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
    mat = material_obj.Material
    mat["Name"] = "Steel"
    mat["YoungsModulus"] = "200000 MPa"
    mat["PoissonRatio"] = "0.30"
    material_obj.Material = mat
    analysis.addObject(material_obj)

    # constraint fixed
    con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
    con_fixed.References = [(geom_obj, ("Vertex1", "Vertex2", "Vertex13", "Vertex14"))]
    analysis.addObject(con_fixed)

    # constraint force
    con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
    con_force.References = [(geom_obj, ("Vertex5", "Vertex6"))]
    con_force.Force = 60000.0  # 30 kN on each Node
    con_force.Direction = (load_line, ["Edge1"])
    con_force.Reversed = False
    analysis.addObject(con_force)

    # mesh
    from .meshes.mesh_truss_crane_seg3 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating nodes.\n")
    control = create_elements(fem_mesh)
    if not control:
        FreeCAD.Console.PrintError("Error on creating elements.\n")
    femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0]
    femmesh_obj.FemMesh = fem_mesh
    femmesh_obj.Part = geom_obj
    femmesh_obj.SecondOrderLinear = False
    femmesh_obj.ElementDimension = "1D"
    # four elements for each bar
    femmesh_obj.CharacteristicLengthMax = "1500.0 mm"
    femmesh_obj.CharacteristicLengthMin = "1500.0 mm"
    if FreeCAD.GuiUp:
        femmesh_obj.ViewObject.DisplayMode = "Faces, Wireframe & Nodes"
        femmesh_obj.ViewObject.PointColor = (1.0, 0.0, 0.5, 0.0)

    doc.recompute()
    return doc