Exemplo n.º 1
0
def get_elebase_sh(corner_min, size, baseheight, tm):

    from FreeCAD import Vector as vec
    from MeshPart import meshFromShape
    from Part import makeLine

    # scaled place on orgin
    place_for_mesh = FreeCAD.Vector(-corner_min.x - size[0],
                                    -corner_min.y - size[1], 0.00)

    # SRTM data resolution is 30 m = 30'000 mm in the usa
    # rest of the world is 90 m = 90'000 mm
    # it makes no sense to use values smaller than 90'000 mm
    pt_distance = 100000

    say(corner_min)
    # y is huge!, but this is ok!
    say(size)

    # base area surface mesh with heights
    # Version new
    pn1 = vec(0, 0, 0)
    pn2 = vec(pn1.x + size[0] * 2, pn1.y, 0)
    pn3 = vec(pn1.x + size[0] * 2, pn1.y + size[1] * 2, 0)
    pn4 = vec(pn1.x, pn1.y + size[1] * 2, 0)
    ln1 = makeLine(pn1, pn2)
    ln2 = makeLine(pn2, pn3)
    ln3 = makeLine(pn3, pn4)
    ln4 = makeLine(pn4, pn1)
    wi = Part.Wire([ln1, ln2, ln3, ln4])
    fa = Part.makeFace([wi], "Part::FaceMakerSimple")
    msh = meshFromShape(fa, LocalLength=pt_distance)
    # move to corner_min to retrieve the heights
    msh.translate(
        corner_min.x,
        corner_min.y,
        0,
    )
    # move mesh points z-koord
    for pt_msh in msh.Points:
        # say(pt_msh.Index)
        # say(pt_msh.Vector)
        pt_tm = tm.toGeographic(pt_msh.Vector.x, pt_msh.Vector.y)
        height = get_height_single(pt_tm[0], pt_tm[1])  # mm
        # say(height)
        pt_msh.move(FreeCAD.Vector(0, 0, height))
    # move mesh back centered on origin
    msh.translate(
        -corner_min.x - size[0],
        -corner_min.y - size[1],
        -baseheight,
    )

    # create Shape from Mesh
    sh = Part.Shape()
    sh.makeShapeFromMesh(msh.Topology, 0.1)

    return sh
    def execute(self, obj):

        if self.clone(obj):
            return
        if not obj.BaseRebar:
            return
        if not obj.Individuals:
            return

        pl_list = []
        rot = FreeCAD.Rotation()
        for v in obj.Individuals:
            # Placment is not set for Part Vertex
            # built placement out of the coordinates attributes
            vertex_vec = vec(v.X, v.Y, v.Z)
            # print(FreeCAD.Placement(vertex_vec, rot))
            pl_list.append(FreeCAD.Placement(vertex_vec, rot))
        obj.RebarPlacements = pl_list

        self.build_shape(obj)
        obj.Amount = len(obj.RebarPlacements)
        obj.TotalLength = obj.Amount * obj.BaseRebar.Length

        # set Visibility of BaseRebar
        # this should be done in the Gui Command,
        # but this dos not yet exist TODO
        # set view of base rebar to off
        # if reinforcement shape is not a null shape
        # TODO may be use another color for base rebar
        if FreeCAD.GuiUp:
            if obj.Shape.isNull() is not True:
                obj.BaseRebar.ViewObject.Visibility = False
def make_reinforcement_custom(
    base_rebar,
    custom_spacing,
    direction=vec(0, 0, 1),
    base_placement=FreeCAD.Placement(),
    name="ReinforcementCustom"
):
    """
    make_reinforcement_custom(
        base_rebar,
        customspacing,
        [base_placement],
        [name]
    )
    Adds a custom reinforcement object.
    """

    if not FreeCAD.ActiveDocument:
        FreeCAD.Console.PrintError("No active document. Aborting\n")
        return

    obj = FreeCAD.ActiveDocument.addObject(
        "Part::FeaturePython",
        "ReinforcementCustom"
    )
    obj.Label = translate("Arch", name)

    ReinforcementCustom(obj)
    if FreeCAD.GuiUp:
        view_custom.ViewProviderReinforcementCustom(obj.ViewObject)

    obj.BaseRebar = base_rebar
    obj.CustomSpacing = custom_spacing
    obj.BasePlacement = base_placement
    obj.Direction = direction

    # mark base_rebar obj to make it collect its new child
    base_rebar.touch()
    return obj
Exemplo n.º 4
0
def setup(doc=None, solvertype="ccxtools"):
    # setup reinfoced wall in 2D

    if doc is None:
        doc = init_doc()

    # part
    from FreeCAD import Vector as vec
    import Part
    from Part import makeLine as ln

    v1 = vec(0, -2000, 0)
    v2 = vec(500, -2000, 0)
    v3 = vec(500, 0, 0)
    v4 = vec(3500, 0, 0)
    v5 = vec(3500, -2000, 0)
    v6 = vec(4000, -2000, 0)
    v7 = vec(4000, 2000, 0)
    v8 = vec(0, 2000, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v5)
    l5 = ln(v5, v6)
    l6 = ln(v6, v7)
    l7 = ln(v7, v8)
    l8 = ln(v8, v1)
    rcwall = doc.addObject("Part::Feature", "FIB_Wall")
    rcwall.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))
    doc.recompute()

    if FreeCAD.GuiUp:
        import FreeCADGui
        FreeCADGui.ActiveDocument.activeView().viewAxonometric()
        FreeCADGui.SendMsgToActiveView("ViewFit")

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

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

    # shell thickness
    thickness = analysis.addObject(
        ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness"))[0]
    thickness.Thickness = 150.0

    # material
    matrixprop = {}
    matrixprop["Name"] = "Concrete-EN-C35/45"
    matrixprop["YoungsModulus"] = "32000 MPa"
    matrixprop["PoissonRatio"] = "0.17"
    matrixprop["CompressiveStrength"] = "15.75 MPa"
    # make some hint on the possible angle units in material system
    matrixprop["AngleOfFriction"] = "30 deg"
    matrixprop["Density"] = "2500 kg/m^3"
    reinfoprop = {}
    reinfoprop["Name"] = "Reinforcement-FIB-B500"
    reinfoprop["YieldStrength"] = "315 MPa"
    # not an official FreeCAD material property
    reinfoprop["ReinforcementRatio"] = "0.0"
    material_reinforced = analysis.addObject(
        ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced"))[0]
    material_reinforced.Material = matrixprop
    material_reinforced.Reinforcement = reinfoprop

    # fixed_constraint
    fixed_constraint = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0]
    fixed_constraint.References = [(rcwall, "Edge1"), (rcwall, "Edge5")]

    # force constraint
    force_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0]
    force_constraint.References = [(rcwall, "Edge7")]
    force_constraint.Force = 1000000.0
    force_constraint.Direction = (rcwall, ["Edge8"])
    force_constraint.Reversed = False

    # displacement_constraint
    displacement_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintDisplacement(
            doc, name="ConstraintDisplacmentPrescribed"))[0]
    displacement_constraint.References = [(rcwall, "Face1")]
    displacement_constraint.zFix = True

    # mesh
    from .meshes.mesh_rc_wall_2d_tria6 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(
        doc.addObject("Fem::FemMeshObject", mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh

    doc.recompute()
    return doc
Exemplo n.º 5
0
def setup(doc=None, solvertype="ccxtools"):
    """ Nonlinear material example, plate with hole.

    https://forum.freecadweb.org/viewtopic.php?f=24&t=31997&start=30
    https://forum.freecadweb.org/viewtopic.php?t=33974&start=90
    https://forum.freecadweb.org/viewtopic.php?t=35893

    plate: 400x200x10 mm
    hole: diameter 100 mm (half cross section)
    load: 130 MPa tension
    linear material: Steel, E = 210000 MPa, my = 0.3
    nonlinear material: '240.0, 0.0' to '270.0, 0.025'
    TODO nonlinear material: give more information, use values from harry
    TODO compare results with example from HarryvL

    """

    if doc is None:
        doc = init_doc()

    # part
    import Part
    from FreeCAD import Vector as vec
    from Part import makeLine as ln
    from Part import makeCircle as ci

    v1 = vec(-200, -100, 0)
    v2 = vec(200, -100, 0)
    v3 = vec(200, 100, 0)
    v4 = vec(-200, 100, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v1)
    v5 = vec(0, 0, 0)
    c1 = ci(50, v5)
    face = Part.makeFace([Part.Wire([l1, l2, l3, l4]), c1],
                         "Part::FaceMakerBullseye")
    partfem = doc.addObject("Part::Feature", "Hole_Plate")
    partfem.Shape = face.extrude(vec(0, 0, 10))
    doc.recompute()

    if FreeCAD.GuiUp:
        import FreeCADGui
        FreeCADGui.ActiveDocument.activeView().viewAxonometric()
        FreeCADGui.SendMsgToActiveView("ViewFit")

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

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

    # linear material
    matprop = {}
    matprop["Name"] = "CalculiX-Steel"
    matprop["YoungsModulus"] = "210000 MPa"
    matprop["PoissonRatio"] = "0.30"
    matprop["Density"] = "7900 kg/m^3"
    material = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "Material_lin"))[0]
    material.Material = matprop

    # nonlinear material
    nonlinear_material = analysis.addObject(
        ObjectsFem.makeMaterialMechanicalNonlinear(doc, material,
                                                   "Material_nonlin"))[0]
    nonlinear_material.YieldPoint1 = '240.0, 0.0'
    nonlinear_material.YieldPoint2 = '270.0, 0.025'
    # check solver attributes, Nonlinearity needs to be set to nonlinear

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

    # force constraint
    pressure_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure"))[0]
    pressure_constraint.References = [(partfem, "Face2")]
    pressure_constraint.Pressure = 130.0
    pressure_constraint.Reversed = True

    # mesh
    from .meshes.mesh_platewithhole_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(
        doc.addObject("Fem::FemMeshObject", mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh

    doc.recompute()
    return doc
Exemplo n.º 6
0
                                        name="RebarShape_No_" + str(markno))

    # rebar distribution
    # TODO mght be there is only the first distribution of many distributions of the MarkNumber rebar
    # lattice2 placements
    custom_pls = []
    for ifc_mapped_item in ifc_shape_representation.Items:
        ifc_cartesian_point = ifc_mapped_item.MappingTarget.LocalOrigin
        coord = ifc_cartesian_point.Coordinates
        custom_pl = lattice2Placement.makeLatticePlacement(
            name=str(ifc_cartesian_point.id()))
        custom_pl.PlacementChoice = "Custom"
        custom_pl.MarkerSize = 25
        lattice2Executer.executeFeature(custom_pl)
        custom_pl.Placement = FreeCAD.Placement(
            vec(coord[0], coord[1], coord[2]),
            FreeCAD.Rotation(vec(0, 0, 1), 0), vec(0, 0, 0))
        custom_pls.append(custom_pl)

    # lattice2 array placement
    cpa = lattice2JoinArrays.makeJoinArrays(name="CustomPlacementArray")
    cpa.Links = custom_pls
    cpa.MarkerSize = 25
    for child in cpa.ViewObject.Proxy.claimChildren():
        child.ViewObject.hide()

    lattice2Executer.executeFeature(cpa)
    ifc_cartesian_point_cpa = rebar.ObjectPlacement.RelativePlacement.Location
    coord_cpa = ifc_cartesian_point_cpa.Coordinates
    cpa_pl = FreeCAD.Placement(vec(coord_cpa[0], coord_cpa[1], coord_cpa[2]),
                               FreeCAD.Rotation(vec(0, 0, 1), 0), vec(0, 0, 0))
Exemplo n.º 7
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geometry objects
    v1 = vec(-200, -100, 0)
    v2 = vec(200, -100, 0)
    v3 = vec(200, 100, 0)
    v4 = vec(-200, 100, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v1)
    v5 = vec(0, 0, 0)
    c1 = ci(50, v5)
    face = Part.makeFace([Part.Wire([l1, l2, l3, l4]), c1],
                         "Part::FaceMakerBullseye")
    geom_obj = doc.addObject("Part::Feature", "Hole_Plate")
    geom_obj.Shape = face.extrude(vec(0, 0, 10))
    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 = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX"))[0]
    elif solvertype == "ccxtools":
        solver = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools"))[0]
        solver.WorkingDir = u""
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver.SplitInputWriter = False
        solver.AnalysisType = "static"
        solver.GeometricalNonlinearity = "linear"
        solver.ThermoMechSteadyState = False
        solver.MatrixSolverType = "default"
        solver.IterationsControlParameterTimeUse = False
        solver.GeometricalNonlinearity = 'nonlinear'
        solver.MaterialNonlinearity = 'nonlinear'

    # linear material
    matprop = {}
    matprop["Name"] = "CalculiX-Steel"
    matprop["YoungsModulus"] = "210000 MPa"
    matprop["PoissonRatio"] = "0.30"
    matprop["Density"] = "7900 kg/m^3"
    material = analysis.addObject(
        ObjectsFem.makeMaterialSolid(doc, "Material_lin"))[0]
    material.Material = matprop

    # nonlinear material
    nonlinear_material = analysis.addObject(
        ObjectsFem.makeMaterialMechanicalNonlinear(doc, material,
                                                   "Material_nonlin"))[0]
    nonlinear_material.YieldPoint1 = '240.0, 0.0'
    nonlinear_material.YieldPoint2 = '270.0, 0.025'
    # check solver attributes, Nonlinearity needs to be set to nonlinear

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

    # force constraint
    pressure_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure"))[0]
    pressure_constraint.References = [(geom_obj, "Face2")]
    pressure_constraint.Pressure = 130.0
    pressure_constraint.Reversed = True

    # mesh
    from .meshes.mesh_platewithhole_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
Exemplo n.º 8
0
def setup(doc=None, solvertype="ccxtools"):
    # setup model

    if doc is None:
        doc = init_doc()

    # geometry objects
    p1 = vec(0, 0, 50)
    p2 = vec(0, 0, -50)
    p3 = vec(0, 0, -4300)
    p4 = vec(4950, 0, -4300)
    p5 = vec(5000, 0, -4300)
    p6 = vec(8535.53, 0, -7835.53)
    p7 = vec(8569.88, 0, -7870.88)
    p8 = vec(12105.41, 0, -11406.41)
    p9 = vec(12140.76, 0, -11441.76)
    p10 = vec(13908.53, 0, -13209.53)
    p11 = vec(13943.88, 0, -13244.88)
    p12 = vec(15046.97, 0, -14347.97)
    p13 = vec(15046.97, 0, -7947.97)
    p14 = vec(15046.97, 0, -7847.97)
    p15 = vec(0, 0, 0)
    p16 = vec(0, 0, -2175)
    p17 = vec(2475, 0, -4300)
    p18 = vec(4975, 0, -4300)
    p19 = vec(6767.765, 0, -6067.765)
    p20 = vec(8552.705, 0, -7853.205)
    p21 = vec(10337.645, 0, -9638.645)
    p22 = vec(12123.085, 0, -11424.085)
    p23 = vec(13024.645, 0, -12325.645)
    p24 = vec(13926.205, 0, -13227.205)
    p25 = vec(14495.425, 0, -13796.425)
    p26 = vec(15046.97, 0, -11147.97)
    p27 = vec(15046.97, 0, -7897.97)
    points = [
        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16,
        p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27
    ]
    geom_obj = makeWire(points, closed=False, face=False, support=None)
    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")  # CalculiX
        )[0]
        solver_object.WorkingDir = u""
    if solvertype == "calculix" or solvertype == "ccxtools":
        solver_object.SplitInputWriter = False
        solver_object.AnalysisType = "thermomech"
        solver_object.GeometricalNonlinearity = "linear"
        solver_object.ThermoMechSteadyState = True
        solver_object.MatrixSolverType = "default"
        solver_object.IterationsThermoMechMaximum = 2000
        solver_object.IterationsControlParameterTimeUse = False

    # material
    material_object = analysis.addObject(
        ObjectsFem.makeMaterialFluid(doc, "FluidMaterial"))[0]
    mat = material_object.Material
    mat["Name"] = "Water"
    mat["Density"] = "998 kg/m^3"
    mat["SpecificHeat"] = "4.182 J/kg/K"
    mat["DynamicViscosity"] = "1.003e-3 kg/m/s"
    mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K"
    mat["ThermalConductivity"] = "0.591 W/m/K"
    material_object.Material = mat

    inlet = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    inlet.SectionType = "Liquid"
    inlet.LiquidSectionType = "PIPE INLET"
    inlet.InletPressure = 0.1
    inlet.References = [(geom_obj, "Edge1")]

    entrance = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    entrance.SectionType = "Liquid"
    entrance.LiquidSectionType = "PIPE ENTRANCE"
    entrance.EntrancePipeArea = 31416.00
    entrance.EntranceArea = 25133.00
    entrance.References = [(geom_obj, "Edge2")]

    manning1 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning1.SectionType = "Liquid"
    manning1.LiquidSectionType = "PIPE MANNING"
    manning1.ManningArea = 31416
    manning1.ManningRadius = 50
    manning1.ManningCoefficient = 0.002
    manning1.References = [(geom_obj, "Edge3"), (geom_obj, "Edge5")]

    bend = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    bend.SectionType = "Liquid"
    bend.LiquidSectionType = "PIPE BEND"
    bend.BendPipeArea = 31416
    bend.BendRadiusDiameter = 1.5
    bend.BendAngle = 45
    bend.BendLossCoefficient = 0.4
    bend.References = [(geom_obj, "Edge4")]

    enlargement1 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    enlargement1.SectionType = "Liquid"
    enlargement1.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement1.EnlargeArea1 = 31416.00
    enlargement1.EnlargeArea2 = 70686.00
    enlargement1.References = [(geom_obj, "Edge6")]

    manning2 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning2.SectionType = "Liquid"
    manning2.LiquidSectionType = "PIPE MANNING"
    manning2.ManningArea = 70686.00
    manning2.ManningRadius = 75
    manning2.ManningCoefficient = 0.002
    manning2.References = [(geom_obj, "Edge7")]

    contraction = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    contraction.SectionType = "Liquid"
    contraction.LiquidSectionType = "PIPE CONTRACTION"
    contraction.ContractArea1 = 70686
    contraction.ContractArea2 = 17671
    contraction.References = [(geom_obj, "Edge8")]

    manning3 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    manning3.SectionType = "Liquid"
    manning3.LiquidSectionType = "PIPE MANNING"
    manning3.ManningArea = 17671.00
    manning3.ManningRadius = 37.5
    manning3.ManningCoefficient = 0.002
    manning3.References = [(geom_obj, "Edge11"), (geom_obj, "Edge9")]

    gate_valve = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    gate_valve.SectionType = "Liquid"
    gate_valve.LiquidSectionType = "PIPE GATE VALVE"
    gate_valve.GateValvePipeArea = 17671
    gate_valve.GateValveClosingCoeff = 0.5
    gate_valve.References = [(geom_obj, "Edge10")]

    enlargement2 = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    enlargement2.SectionType = "Liquid"
    enlargement2.LiquidSectionType = "PIPE ENLARGEMENT"
    enlargement2.EnlargeArea1 = 17671
    enlargement2.EnlargeArea2 = 1e12
    enlargement2.References = [(geom_obj, "Edge12")]

    outlet = analysis.addObject(
        ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D"))[0]
    outlet.SectionType = "Liquid"
    outlet.LiquidSectionType = "PIPE OUTLET"
    outlet.OutletPressure = 0.1
    outlet.References = [(geom_obj, "Edge13")]

    self_weight = analysis.addObject(
        ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight"))[0]
    self_weight.Gravity_x = 0.0
    self_weight.Gravity_y = 0.0
    self_weight.Gravity_z = -1.0

    # mesh
    from .meshes.mesh_thermomech_flow1d_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(
        doc.addObject("Fem::FemMeshObject", mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh

    doc.recompute()
    return doc
Exemplo n.º 9
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
# use for unit tests and documentation
# see Draft unit test or Arch unit test

# documentation of methods and class of all rebar2 objects
# see ArchWall which uses Numpy style

# ************************************************************************************************
# standard FreeCAD rebar *************************************************************************
# ************************************************************************************************

# ************************************************************************************************
# https://forum.freecadweb.org/viewtopic.php?f=23&t=35849
# code to make a rebar based on a simple wire
from FreeCAD import Vector as vec
import FreeCAD, Arch, Draft
Wire = Draft.makeWire([vec(0, 2000, 0), vec(0, 2000, 2000)])
Rebar = Arch.makeRebar(None, Wire, diameter=30, amount=1)
FreeCAD.ActiveDocument.recompute()

# code to make a rebar based on a wire and a structure
import FreeCAD, Arch, Draft
from FreeCAD import Vector as vec
myh = 3000

Structure = Arch.makeStructure(None, length=1000, width=1000, height=myh)
Structure.ViewObject.Transparency = 80
FreeCAD.ActiveDocument.recompute()

p1 = vec(0, 0, 0)
p2 = vec(0, 0, myh)
Wire1 = Draft.makeWire([p1, p2])
Exemplo n.º 11
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
    v1 = vec(-200, -100, 0)
    v2 = vec(200, -100, 0)
    v3 = vec(200, 100, 0)
    v4 = vec(-200, 100, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v1)
    v5 = vec(0, 0, 0)
    c1 = ci(50, v5)
    face = Part.makeFace([Part.Wire([l1, l2, l3, l4]), c1],
                         "Part::FaceMakerBullseye")
    geom_obj = doc.addObject("Part::Feature", "Hole_Plate")
    geom_obj.Shape = face.extrude(vec(0, 0, 10))
    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
        solver_obj.GeometricalNonlinearity = 'nonlinear'
        solver_obj.MaterialNonlinearity = 'nonlinear'
    analysis.addObject(solver_obj)

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

    # nonlinear material
    name_nlm = "Material_nonlin"
    nonlinear_mat = ObjectsFem.makeMaterialMechanicalNonlinear(
        doc, material_obj, name_nlm)
    nonlinear_mat.YieldPoint1 = '240.0, 0.0'
    nonlinear_mat.YieldPoint2 = '270.0, 0.025'
    analysis.addObject(nonlinear_mat)
    # check solver attributes, Nonlinearity needs to be set to nonlinear

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

    # pressure constraint
    con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
    con_pressure.References = [(geom_obj, "Face2")]
    con_pressure.Pressure = 130.0
    con_pressure.Reversed = True
    analysis.addObject(con_pressure)

    # mesh
    from .meshes.mesh_platewithhole_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
Exemplo n.º 12
0
def setup_rcwall2d(doc=None, solver='ccxtools'):
    # setup reinfoced wall in 2D

    if doc is None:
        doc = init_doc()

    # part
    from FreeCAD import Vector as vec
    import Part
    from Part import makeLine as ln

    v1 = vec(0, -2000, 0)
    v2 = vec(500, -2000, 0)
    v3 = vec(500, 0, 0)
    v4 = vec(3500, 0, 0)
    v5 = vec(3500, -2000, 0)
    v6 = vec(4000, -2000, 0)
    v7 = vec(4000, 2000, 0)
    v8 = vec(0, 2000, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v5)
    l5 = ln(v5, v6)
    l6 = ln(v6, v7)
    l7 = ln(v7, v8)
    l8 = ln(v8, v1)
    rcwall = doc.addObject("Part::Feature", "FIB_Wall")
    rcwall.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))

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

    solver
    # TODO How to pass multiple solver for one analysis in one doc
    if solver is None:
        pass  # no solver is added
    elif solver is 'calculix':
        solver = analysis.addObject(
            ObjectsFem.makeSolverCalculix(doc, 'SolverCalculiX'))[0]
        solver.AnalysisType = 'static'
        solver.GeometricalNonlinearity = 'linear'
        solver.ThermoMechSteadyState = False
        solver.MatrixSolverType = 'default'
        solver.IterationsControlParameterTimeUse = False
    elif solver is 'ccxtools':
        solver = analysis.addObject(
            ObjectsFem.makeSolverCalculixCcxTools(doc, 'CalculiXccxTools'))[0]
        solver.AnalysisType = 'static'
        solver.GeometricalNonlinearity = 'linear'
        solver.ThermoMechSteadyState = False
        solver.MatrixSolverType = 'default'
        solver.IterationsControlParameterTimeUse = False
        solver.WorkingDir = u''

    # shell thickness
    thickness = analysis.addObject(
        ObjectsFem.makeElementGeometry2D(doc, 0, 'ShellThickness'))[0]
    thickness.Thickness = 150.0

    # material
    matrixprop = {}
    matrixprop['Name'] = "Concrete-EN-C35/45"
    matrixprop['YoungsModulus'] = "32000 MPa"
    matrixprop['PoissonRatio'] = "0.17"
    matrixprop['CompressiveStrength'] = "15.75 MPa"
    # make some hint on the possible angle units in material system
    matrixprop['AngleOfFriction'] = "30 deg"
    matrixprop['Density'] = '2500 kg/m^3'
    reinfoprop = {}
    reinfoprop['Name'] = "Reinforcement-FIB-B500"
    reinfoprop['YieldStrength'] = "315 MPa"
    # not an official FreeCAD material property
    reinfoprop['ReinforcementRatio'] = "0.0"
    material_reinforced = analysis.addObject(
        ObjectsFem.makeMaterialReinforced(doc, 'MaterialReinforced'))[0]
    material_reinforced.Material = matrixprop
    material_reinforced.Reinforcement = reinfoprop

    # fixed_constraint
    fixed_constraint = analysis.addObject(
        ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0]
    fixed_constraint.References = [(rcwall, "Edge1"), (rcwall, "Edge5")]

    # force constraint
    force_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintForce(doc, name="ConstraintForce"))[0]
    force_constraint.References = [(rcwall, "Edge7")]
    force_constraint.Force = 1000000.0
    force_constraint.Direction = (rcwall, ["Edge8"])
    force_constraint.Reversed = False

    # displacement_constraint
    displacement_constraint = doc.Analysis.addObject(
        ObjectsFem.makeConstraintDisplacement(
            doc, name="ConstraintDisplacmentPrescribed"))[0]
    displacement_constraint.References = [(rcwall, "Face1")]
    displacement_constraint.zFix = True

    # mesh
    from femexamples.meshes.mesh_rc_wall_2d_tria6 import create_nodes, create_elements
    fem_mesh = Fem.FemMesh()
    control = create_nodes(fem_mesh)
    if not control:
        print('ERROR on creating nodes')
    control = create_elements(fem_mesh)
    if not control:
        print('ERROR on creating elements')
    femmesh_obj = analysis.addObject(
        doc.addObject('Fem::FemMeshObject', mesh_name))[0]
    femmesh_obj.FemMesh = fem_mesh

    doc.recompute()
    return doc
Exemplo n.º 13
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 objects
    # ring
    stiffener = doc.addObject("Part::Box", "Stiffener")
    stiffener.Length = 10
    stiffener.Width = 200
    stiffener.Height = 10
    stiffener.Placement.Base = (-5, -100, 0)
    circumference = Shapes.addTube(doc, "Circumference")
    circumference.Height = 10.0
    circumference.InnerRadius = 97.5
    circumference.OuterRadius = 102.5
    doc.recompute()

    fusion = doc.addObject("Part::MultiFuse", "Fusion")
    fusion.Shapes = [stiffener, circumference]
    doc.recompute()

    centerhole = doc.addObject("Part::Cylinder", "CenterHole")
    centerhole.Radius = 3
    centerhole.Height = 20
    doc.recompute()

    ring_bottom = doc.addObject("Part::Cut", "RingBottom")
    ring_bottom.Base = fusion
    ring_bottom.Tool = centerhole
    doc.recompute()

    # standard ring
    ring_top = clone(ring_bottom, delta=vec(0, 0, 20))
    ring_top.Label = "RingTop"

    # compound of both rings
    geom_obj = doc.addObject("Part::Compound", "TheRingOfFire")
    geom_obj.Links = [ring_bottom, ring_top]
    doc.recompute()

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

    # line for centrif axis
    sh_axis_line = makeLine(vec(0, 0, 0), vec(0, 0, 31))
    axis_line = doc.addObject("Part::Feature", "CentrifAxis")
    axis_line.Shape = sh_axis_line
    doc.recompute()
    if FreeCAD.GuiUp:
        axis_line.ViewObject.LineWidth = 5.0
        axis_line.ViewObject.LineColor = (1.0, 0.0, 0.0)

    # 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.AnalysisType = "static"
        solver_obj.GeometricalNonlinearity = "linear"
        solver_obj.ThermoMechSteadyState = False
        solver_obj.MatrixSolverType = "default"
        solver_obj.IterationsControlParameterTimeUse = False
        solver_obj.SplitInputWriter = False
    analysis.addObject(solver_obj)

    # materials
    material_obj_scotty = ObjectsFem.makeMaterialSolid(doc, "Steel_Scotty")
    mat = material_obj_scotty.Material
    mat["Name"] = "Steel_Scotty"
    mat["YoungsModulus"] = "210000 MPa"
    mat["PoissonRatio"] = "0.30"
    mat["Density"] = "4000 kg/m^3"
    material_obj_scotty.Material = mat
    material_obj_scotty.References = [(ring_bottom, "Solid1")]
    analysis.addObject(material_obj_scotty)

    material_obj_std = ObjectsFem.makeMaterialSolid(doc, "Steel_Std")
    mat = material_obj_std.Material
    mat["Name"] = "Steel_Std"
    mat["YoungsModulus"] = "210000 MPa"
    mat["PoissonRatio"] = "0.30"
    mat["Density"] = "8000 kg/m^3"
    material_obj_std.Material = mat
    material_obj_std.References = [(ring_top, "Solid1")]
    analysis.addObject(material_obj_std)

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

    # constraint centrif
    con_centrif = ObjectsFem.makeConstraintCentrif(doc, "ConstraintCentrif")
    con_centrif.RotationFrequency = "100 Hz"
    con_centrif.RotationAxis = [(axis_line, "Edge1")]
    analysis.addObject(con_centrif)

    # mesh
    from .meshes.mesh_constraint_centrif_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
    femmesh_obj.CharacteristicLengthMax = "5.0 mm"

    doc.recompute()
    return doc
Exemplo n.º 14
0
def make_reinforcement_linear(
    base_rebar,
    amount=None,
    spacing=None,
    distance=None,
    direction=vec(0, 0, 1),
    base_placement=FreeCAD.Placement(),
    name="ReinforcementLinear"
):
    """
    make_reinforcement_linear(
        base_rebar,
        [amount],
        [spacing],
        [distance],
        [direction],
        [base_placement],
        [name]
    )
    Adds a linear reinforcement object.
    """

    if not FreeCAD.ActiveDocument:
        FreeCAD.Console.PrintError("No active document. Aborting\n")
        return

    # print("amount: {}".format(amount))
    # print("distance: {}".format(distance))
    # print("spacing: {}".format(spacing))
    if (
        (amount is None and spacing is None)
        or (amount is None and distance is None)
        or (distance is None and spacing is None)
        or (amount is None and distance is None and spacing is None)
        or (
            amount is not None
            and distance is not None
            and spacing is not None
        )
    ):
        FreeCAD.Console.PrintError(
            "This combination of parameter is not yet supported. Aborting\n"
        )
        return

    obj = FreeCAD.ActiveDocument.addObject(
        "Part::FeaturePython",
        "ReinforcementLinear"
    )
    obj.Label = translate("Arch", name)

    ReinforcementLinear(obj)
    if FreeCAD.GuiUp:
        view_linear.ViewProviderReinforcementLinear(obj.ViewObject)

    obj.BaseRebar = base_rebar
    obj.BasePlacement = base_placement
    obj.Direction = direction

    if distance is None:
        obj.FixedAttribut = "Amount"
        obj.Amount = amount
        obj.Spacing = spacing

    if amount is None:
        obj.FixedAttribut = "Distance"
        obj.Distance = distance
        obj.Spacing = spacing

    if spacing is None:
        obj.FixedAttribut = "Spacing"
        obj.Distance = distance
        obj.Amount = amount

    # mark base_rebar obj to make it collect its new child
    base_rebar.touch()
    return obj
Exemplo n.º 15
0
raeume_building = Arch.makeBuilding([], name="Reihenhaus_Raeume")
Arch.addComponents(raeume_building, raeume_site)

# the materials, windows, doors and spaces do not get a material
brick = Arch.makeMaterial('Backstein')
concrete = Arch.makeMaterial('Beton')
brick.Color = (1.0, 0.502, 0.0, 0.0)
concrete.Color = (0.439, 1.0, 0.439, 0.0)

# ***************************************************************************
# lets start with geometry creation

# *******************************************
# bodenplatte
bpl_place = FreeCAD.Placement(
    vec(base_x-seitenwand_dicke, base_y, eg_boden_roh),
    FreeCAD.Rotation(vec(0, 0, 1), 0)
)
bpl_base = Draft.makeRectangle(
    length=reihenhaus_laenge,
    height=haus_t,
    placement=bpl_place
)
bpl_obj = Arch.makeStructure(
    baseobj=bpl_base,
    height=bpl_dicke
)
# structure will be extruded in positive z
# thus set extrude Normale downwards
bpl_obj.Normal = vec(0, 0, -1)
doc_obj.recompute()
Exemplo n.º 16
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
    v1 = vec(0, -2000, 0)
    v2 = vec(500, -2000, 0)
    v3 = vec(500, 0, 0)
    v4 = vec(3500, 0, 0)
    v5 = vec(3500, -2000, 0)
    v6 = vec(4000, -2000, 0)
    v7 = vec(4000, 2000, 0)
    v8 = vec(0, 2000, 0)
    l1 = ln(v1, v2)
    l2 = ln(v2, v3)
    l3 = ln(v3, v4)
    l4 = ln(v4, v5)
    l5 = ln(v5, v6)
    l6 = ln(v6, v7)
    l7 = ln(v7, v8)
    l8 = ln(v8, v1)
    geom_obj = doc.addObject("Part::Feature", "FIB_Wall")
    geom_obj.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))
    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)

    # shell thickness
    thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 150.0, "ShellThickness")
    analysis.addObject(thickness_obj)

    # material
    matrixprop = {}
    matrixprop["Name"] = "Concrete-EN-C35/45"
    matrixprop["YoungsModulus"] = "32000 MPa"
    matrixprop["PoissonRatio"] = "0.17"
    matrixprop["CompressiveStrength"] = "15.75 MPa"
    # make some hint on the possible angle units in material system
    matrixprop["AngleOfFriction"] = "30 deg"
    reinfoprop = {}
    reinfoprop["Name"] = "Reinforcement-FIB-B500"
    reinfoprop["YieldStrength"] = "315 MPa"
    # not an official FreeCAD material property
    reinfoprop["ReinforcementRatio"] = "0.0"
    material_reinforced = ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced")
    material_reinforced.Material = matrixprop
    material_reinforced.Reinforcement = reinfoprop
    analysis.addObject(material_reinforced)

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

    # constraint force
    con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
    con_force.References = [(geom_obj, "Edge7")]
    con_force.Force = 1000000.0
    con_force.Direction = (geom_obj, ["Edge8"])
    con_force.Reversed = False
    analysis.addObject(con_force)

    # constraint displacement
    con_disp = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacmentPrescribed")
    con_disp.References = [(geom_obj, "Face1")]
    con_disp.zFree = False
    con_disp.zFix = True
    analysis.addObject(con_disp)

    # mesh
    from .meshes.mesh_rc_wall_2d_tria6 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
Exemplo n.º 17
0
def insert(filename, docname, skip=[], only=[], root=None):
    """insert(filename,docname,skip=[],only=[],root=None):
    imports the contents of an IFC file.
    skip can contain a list of ids of objects to be skipped,
    only can restrict the import to certain object ids
    (will also get their children) and root can be used to
    import only the derivates of a certain element type
    (default = ifcProduct)."""

    getPreferences()

    # *****************************************************************
    # we are going to overwrite skip and only
    # needs to be after getPreferences
    # skip = [1030, 1922, 9813, 13030, 28999, 30631, 34909, 39120]
    #
    # only = [679567]
    # add this modules to the modules to reload on my reload tool

    try:
        import ifcopenshell
    except:
        FreeCAD.Console.PrintError(
            "IfcOpenShell was not found on this system. "
            "IFC support is disabled\n")
        return

    if DEBUG:
        print("Opening ", filename, "...", end="")
    try:
        doc = FreeCAD.getDocument(docname)
    except:
        doc = FreeCAD.newDocument(docname)
    FreeCAD.ActiveDocument = doc

    if DEBUG:
        print("done.")

    global ROOT_ELEMENT
    if root:
        ROOT_ELEMENT = root

    from ifcopenshell import geom
    settings = ifcopenshell.geom.settings()
    settings.set(settings.USE_BREP_DATA, True)
    settings.set(settings.SEW_SHELLS, True)
    settings.set(settings.USE_WORLD_COORDS, True)
    settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, False)
    settings.set(settings.INCLUDE_CURVES, True)
    settings.set(settings.EXCLUDE_SOLIDS_AND_SURFACES, True)

    # global ifcfile # keeping global for debugging purposes
    filename = ifcdecode(filename, utf=True)
    ifcfile = ifcopenshell.open(filename)

    # get the length scale facter from of unit of the ifc file
    length_scale = get_prj_unit_length_scale(ifcfile)
    print("Length scale = {}\n".format(length_scale))

    reinforcements = ifcfile.by_type("IfcReinforcingBar")
    rebar_objs = []
    base_rebars = {}  # {rebar_mark_number : rebar_obj}
    reinforcement_counter = 1

    # reinforcements
    for pno, rebar in enumerate(reinforcements):
        pid = rebar.id()
        ptype = rebar.is_a()
        print("Product {} of {} is Entity #{}: {}, ".format(
            pno + 1,
            len(reinforcements),
            pid,
            ptype,
        ),
              end="",
              flush=True)

        if pid in skip:
            print(" --> is in skip list, thus skipped", end="\n")
            continue
        if only and pid not in only:
            print(
                " --> only list is no empty and pid "
                "not in only list, thus skipped",
                end="\n")
            continue

        # properties, get the mark number
        # print("")
        # build list of related property sets
        psets = getIfcPropertySets(ifcfile, pid)
        # print(psets)
        # build dict of properties
        ifc_properties = {}
        rebar_mark_number = 0
        ifc_properties = getIfcProperties(ifcfile, pid, psets, ifc_properties)
        # print(ifc_properties)
        # get the mark number (Position number)
        for key, value in ifc_properties.items():
            pset, pname, ptype, pvalue = getPropertyData(
                key, value, {"Debug": True})
            if (pset == "Allplan_ReinforcingBar" and
                    pname == "Position number"  # need to be Position not Mark!
                ):
                rebar_mark_number = pvalue
        # print(rebar_mark_number)
        # print("")
        # for debugging, TODO some Parameter to only import certain mark numbers
        # if rebar_mark_number != 3:
        #     continue

        # get the radius and the IfcCurve (Directrix) out of the ifc
        ifc_shape_representation = rebar.Representation.Representations[0]
        item_ifc_shape_representation = ifc_shape_representation.Items[0]
        mapping_source = item_ifc_shape_representation.MappingSource
        ifc_swept_disk_solid = mapping_source.MappedRepresentation.Items[0]
        radius = ifc_swept_disk_solid.Radius * length_scale
        # print(radius)
        entity_polyline = ifc_swept_disk_solid.Directrix

        # sweep path
        # get the geometry out of the IfcCurve (Directrix) and create a Wire
        cr = ifcopenshell.geom.create_shape(settings, entity_polyline)
        brep = cr.brep_data
        sweep_path = Part.Shape()
        sweep_path.importBrepFromString(brep)
        sweep_path.scale(1000.0)  # IfcOpenShell always outputs in meters

        # does it makes sense to check if the sweep_path and Radius
        # really are the same if mark number equals (yes, thus TODO)
        base_placement = FreeCAD.Placement()
        if rebar_mark_number not in base_rebars:
            # create a new rebar shape
            wire = Draft.makeWire(sweep_path.Wires[0])
            rebar_shape = archadd.BaseRebar(wire,
                                            diameter=2 * radius,
                                            mark=rebar_mark_number,
                                            name="BaseRebar_Mark_" +
                                            str(rebar_mark_number))
            rebar_shape.IfcProperties = ifc_properties
            print("based on: {}, ".format(wire.Name), end="")
            rebar_objs.append(rebar_shape)
            base_rebars[rebar_mark_number] = rebar_shape
        else:
            # get the relative placement between
            # the base wire (the one in base_rebars already)
            # the sweep_path
            base_wire_obj = base_rebars[rebar_mark_number].Base
            print("based on: {}, ".format(base_wire_obj.Name), end="")
            base_placement = get_relative_placement(base_wire_obj.Shape,
                                                    sweep_path)
            # print(base_placement)

        # reinforcement made out of the imported rebar
        # coord placements
        vec_base_rebar = []
        for ifc_mapped_item in ifc_shape_representation.Items:
            ifc_cartesian_point = ifc_mapped_item.MappingTarget.LocalOrigin
            coord = ifc_cartesian_point.Coordinates
            co_vec = vec(coord[0] * length_scale, coord[1] * length_scale,
                         coord[2] * length_scale)
            vec_base_rebar.append(co_vec)
        # print("\n{}".format(vec_base_rebar))

        # check if we have a linear reinforcement
        is_linear_reinforcement = False
        space_one = 0
        if len(vec_base_rebar) > 1:
            # edge from first point to last point
            ed = Part.Edge(
                Part.LineSegment(vec_base_rebar[0], vec_base_rebar[-1]))
            # spacing between first and second point
            space_one = vec_base_rebar[1] - vec_base_rebar[0]
            for i, co_vec in enumerate(vec_base_rebar):
                # check distance point to edge
                dist = ed.distToShape(Part.Vertex(co_vec))[0]
                if dist > 2:
                    # 2 mm, much better would be some dimensionless value
                    break
                # check spaceing, if they are constant
                if i > 0:
                    space_i = vec_base_rebar[i] - vec_base_rebar[i - 1]
                    difference_length = (space_one - space_i).Length
                    if difference_length > 2:
                        # 2 mm, much better would be some dimensionless value
                        break
            else:
                is_linear_reinforcement = True

        # get placement for first reinforcement bar
        relplacement_firstbar = rebar.ObjectPlacement.RelativePlacement
        coord_firstbar = relplacement_firstbar.Location.Coordinates
        vec_firstbar = vec(coord_firstbar[0] * length_scale,
                           coord_firstbar[1] * length_scale,
                           coord_firstbar[2] * length_scale)
        firstbar_pl = FreeCAD.Placement(vec_firstbar,
                                        FreeCAD.Rotation(vec(0, 0, 1), 0),
                                        vec(0, 0, 0))

        marker_size = 25
        lattice_placement = None
        if (REINFORCEMENT_LATTICE is True and is_linear_reinforcement is True):
            # linear lattice reinforcement
            print("reinforcement: linear lattice")
            # print(len(vec_base_rebar))
            # print(space_one)
            space_length = space_one.Length
            la = lattice2LinearArray.makeLinearArray(name="LinearArray")
            # SpanN ... put in Count
            # Step will be calculated
            # SpanStep ... put in Step (space between rebars)
            # Count will be calculated
            la.GeneratorMode = "SpanStep"
            # https://forum.freecadweb.org/viewtopic.php?f=22&t=37657#p320586
            la.Alignment = "Justify"
            la.SpanEnd = (len(vec_base_rebar) - 1) * space_length
            la.Step = space_length
            la.MarkerSize = marker_size
            # direction of linear lattice2 placement
            la.Dir = space_one
            # do not change the orientation of the little planes
            # https://forum.freecadweb.org/viewtopic.php?f=22&t=37893&p=322427#p322421
            la.OrientMode = "None"
            lattice2Executer.executeFeature(la)
            la.Placement = firstbar_pl
            if la.Count != len(vec_base_rebar):
                print("Problem: {} != {}".format(la.Count,
                                                 len(vec_base_rebar)))
            lattice_placement = la
        elif (REINFORCEMENT_LATTICE is True
              and is_linear_reinforcement is False):
            # custom lattice placement for every rebar of this reinforcement
            print("reinforcement: custom lattice")
            custom_pls = []
            for co_vec in vec_base_rebar:
                custom_pl = lattice2Placement.makeLatticePlacement(
                    name=str(ifc_cartesian_point.id()))
                custom_pl.PlacementChoice = "Custom"
                custom_pl.MarkerSize = marker_size
                lattice2Executer.executeFeature(custom_pl)
                custom_pl.Placement = FreeCAD.Placement(
                    co_vec, FreeCAD.Rotation(vec(0, 0, 1), 0), vec(0, 0, 0))
                custom_pls.append(custom_pl)

                # lattice array placement from custom lattice placements
                cpa = lattice2JoinArrays.makeJoinArrays(
                    name="CustomPlacementArray")
                cpa.Links = custom_pls
                cpa.MarkerSize = marker_size
                lattice2Executer.executeFeature(cpa)
                cpa.Placement = firstbar_pl
                lattice_placement = cpa
                if FreeCAD.GuiUp:
                    for child in cpa.ViewObject.Proxy.claimChildren():
                        child.ViewObject.hide()

        if lattice_placement is not None:
            # lattice2 reinforcement
            archadd.ReinforcementLattice(
                rebar_shape,
                lattice_placement,
                base_placement,
                # name="Reinforcement_"+str(reinforcement_counter)
                name="ReinforcementLattice_" + str(pid))

        if (REINFORCEMENT_LATTICE is False
                and is_linear_reinforcement is True):
            # linear reinforcement
            print("reinforcement: linear std")
            if space_one == 0:
                # TODO handle a reinforcement with one rebar
                # this should not be a linear reinforcement
                continue
            amount = len(vec_base_rebar)
            spacing = space_one.Length
            # distance = (len(vec_base_rebar) - 1) * spacing

            archadd.ReinforcementLinear(
                rebar_shape,
                amount=amount,
                spacing=spacing,
                direction=space_one,
                base_placement=firstbar_pl.multiply(base_placement),
                # name="Reinforcement_"+str(reinforcement_counter)
                name="ReinforcementLinear_" + str(pid))
        elif (REINFORCEMENT_LATTICE is False
              and is_linear_reinforcement is False):
            # individual reinforcement
            print("reinforcement: individual std")
            individuals = []
            for co in vec_base_rebar:
                v_placement_lok = FreeCAD.Placement(co, FreeCAD.Rotation())
                v_placement_glob = v_placement_lok.multiply(firstbar_pl)
                v = doc.addObject("Part::Vertex", "Vertex1")
                v_vec = v_placement_glob.Base
                v.X, v.Y, v.Z = v_vec.x, v_vec.y, v_vec.z,
                v.ViewObject.PointColor = (1.0, 0.7, 0.0, 0.0)
                v.ViewObject.PointSize = 15
                individuals.append(v)
            archadd.ReinforcementIndividual(rebar_shape,
                                            individuals=individuals,
                                            base_placement=base_placement,
                                            name="ReinforcementIndividual_" +
                                            str(pid))

        reinforcement_counter += 1
        # print("")

    FreeCAD.ActiveDocument.recompute()
    # End reinforcements loop

    if FreeCAD.GuiUp:
        FreeCADGui.activeDocument().activeView().viewAxometric()
        FreeCADGui.SendMsgToActiveView("ViewFit")
    return doc