def getRebarData(self,obj): if len(obj.InList) != 1: return if Draft.getType(obj.InList[0]) != "Structure": return if not obj.InList[0].Shape: return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.InList[0] wire = obj.Base.Shape.Wires[0] axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1)) size = (ArchCommands.projectToVector(father.Shape.copy(),axis)).Length if hasattr(obj,"Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) axis.normalize() if hasattr(obj,"Distance"): if obj.Distance.Value: size = obj.Distance.Value if hasattr(obj,"Rounding"): if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire,radius) wires = [] if obj.Amount == 1: offset = DraftVecUtils.scaleTo(axis,size/2) wire.translate(offset) wires.append(wire) else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) else: baseoffset = None interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) vinterval = DraftVecUtils.scaleTo(axis,interval) for i in range(obj.Amount): if i == 0: if baseoffset: wire.translate(baseoffset) wires.append(wire) else: wire = wire.copy() wire.translate(vinterval) wires.append(wire) return [wires,obj.Diameter.Value/2]
def execute(self,obj): if len(obj.InList) != 1: return if Draft.getType(obj.InList[0]) != "Structure": return if not obj.InList[0].Shape: return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.InList[0] wire = obj.Base.Shape.Wires[0] if hasattr(obj,"Rounding"): #print obj.Rounding if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire,radius) bpoint, bvec = self.getBaseAndAxis(obj) if not bpoint: return axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1)) size = (ArchCommands.projectToVector(father.Shape.copy(),axis)).Length if hasattr(obj,"Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) #.normalize() # don't normalize so the vector can also be used to determine the distance size = axis.Length #print axis #print size if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: return # all tests ok! pl = obj.Placement import Part circle = Part.makeCircle(obj.Diameter.Value/2,bpoint,bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle],True,False,2) except: print "Arch: error sweeping rebar profile along the base sketch" return # building final shape shapes = [] if obj.Amount == 1: offset = DraftVecUtils.scaleTo(axis,size/2) bar.translate(offset) shapes.append(bar) if hasattr(obj,"Spacing"): obj.Spacing = 0 else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) else: baseoffset = None interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) vinterval = DraftVecUtils.scaleTo(axis,interval) for i in range(obj.Amount): if i == 0: if baseoffset: bar.translate(baseoffset) shapes.append(bar) else: bar = bar.copy() bar.translate(vinterval) shapes.append(bar) if hasattr(obj,"Spacing"): obj.Spacing = interval if shapes: obj.Shape = Part.makeCompound(shapes) obj.Placement = pl
def execute(self,obj): if self.clone(obj): return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.Host fathershape = None if not father: # support for old-style rebars if obj.InList: if hasattr(obj.InList[0],"Armatures"): if obj in obj.InList[0].Armatures: father = obj.InList[0] if father: if father.isDerivedFrom("Part::Feature"): fathershape = father.Shape wire = obj.Base.Shape.Wires[0] if hasattr(obj,"Rounding"): #print(obj.Rounding) if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire,radius) bpoint, bvec = self.getBaseAndAxis(wire) if not bpoint: return axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1)) if fathershape: size = (ArchCommands.projectToVector(fathershape.copy(),axis)).Length else: size = 1 if hasattr(obj,"Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) axis.normalize() if fathershape: size = (ArchCommands.projectToVector(fathershape.copy(),axis)).Length else: size = 1 if hasattr(obj,"Distance"): if obj.Distance.Value: size = obj.Distance.Value spacinglist = None if hasattr(obj, "CustomSpacing"): if obj.CustomSpacing: spacinglist = strprocessOfCustomSpacing(obj.CustomSpacing) influenceArea = sum(spacinglist) - spacinglist[0] / 2 - spacinglist[-1] / 2 if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: return # all tests ok! if hasattr(obj, "Length"): length = getLengthOfRebar(obj) if length: obj.Length = length pl = obj.Placement import Part circle = Part.makeCircle(obj.Diameter.Value/2,bpoint,bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle],True,False,2) basewire = wire.copy() except Part.OCCError: print("Arch: error sweeping rebar profile along the base sketch") return # building final shape shapes = [] placementlist = [] self.wires = [] rot = FreeCAD.Rotation() if obj.Amount == 1: barplacement = CalculatePlacement(obj.Amount, 1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value, obj.ViewObject.RebarShape) placementlist.append(barplacement) if hasattr(obj,"Spacing"): obj.Spacing = 0 else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) else: baseoffset = None if obj.ViewObject.RebarShape == "Stirrup": interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value + obj.Diameter.Value) else: interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) for i in range(obj.Amount): barplacement = CalculatePlacement(obj.Amount, i+1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value, obj.ViewObject.RebarShape) placementlist.append(barplacement) if hasattr(obj,"Spacing"): obj.Spacing = interval # Calculate placement of bars from custom spacing. if spacinglist: placementlist[:] = [] if obj.ViewObject.RebarShape == "Stirrup": reqInfluenceArea = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value + obj.Diameter.Value) else: reqInfluenceArea = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) # Avoid unnecessary checks to pass like. For eg.: when we have values # like influenceArea is 100.00001 and reqInflueneArea is 100 if round(influenceArea) > round(reqInfluenceArea): FreeCAD.Console.PrintWarning("Influence area of rebars is greater than "+ str(reqInfluenceArea) + ".\n") elif round(influenceArea) < round(reqInfluenceArea): FreeCAD.Console.PrintWarning("Last span is greater that end offset.\n") for i in range(len(spacinglist)): if i == 0: barplacement = CustomSpacingPlacement(spacinglist, 1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) else: barplacement = CustomSpacingPlacement(spacinglist, i+1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) obj.Amount = len(spacinglist) obj.Spacing = 0 obj.PlacementList = placementlist for i in range(len(obj.PlacementList)): if i == 0: bar.Placement = obj.PlacementList[i] shapes.append(bar) basewire.Placement = obj.PlacementList[i] self.wires.append(basewire) else: bar = bar.copy() bar.Placement = obj.PlacementList[i] shapes.append(bar) w = basewire.copy() w.Placement = obj.PlacementList[i] self.wires.append(w) if shapes: obj.Shape = Part.makeCompound(shapes) obj.Placement = pl obj.TotalLength = obj.Length * len(obj.PlacementList)
def execute(self, obj): if len(obj.InList) != 1: return if Draft.getType(obj.InList[0]) != "Structure": return if not obj.InList[0].Shape: return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.InList[0] wire = obj.Base.Shape.Wires[0] if hasattr(obj, "Rounding"): #print obj.Rounding if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire, radius) bpoint, bvec = self.getBaseAndAxis(obj) if not bpoint: return axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0, 0, -1)) size = (ArchCommands.projectToVector(father.Shape.copy(), axis)).Length if hasattr(obj, "Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) #.normalize() # don't normalize so the vector can also be used to determine the distance size = axis.Length #print axis #print size if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: return # all tests ok! pl = obj.Placement import Part circle = Part.makeCircle(obj.Diameter.Value / 2, bpoint, bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle], True, False, 2) except: print "Arch: error sweeping rebar profile along the base sketch" return # building final shape shapes = [] if obj.Amount == 1: offset = DraftVecUtils.scaleTo(axis, size / 2) bar.translate(offset) shapes.append(bar) if hasattr(obj, "Spacing"): obj.Spacing = 0 else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis, obj.OffsetStart.Value) else: baseoffset = None interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) vinterval = DraftVecUtils.scaleTo(axis, interval) for i in range(obj.Amount): if i == 0: if baseoffset: bar.translate(baseoffset) shapes.append(bar) else: bar = bar.copy() bar.translate(vinterval) shapes.append(bar) if hasattr(obj, "Spacing"): obj.Spacing = interval if shapes: obj.Shape = Part.makeCompound(shapes) obj.Placement = pl
def makeUShapeRebar(f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom", structure=None, facename=None): """ makeUShapeRebar(FrontCover, BottomCover, RightCover, LeftCover, Diameter, Topcover, Rounding, AmountSpacingCheck, AmountSpacingValue, Orientation, Structure, Facename): Adds the U-Shape reinforcement bar to the selected structural object. It takes four different types of orientations as input i.e 'Bottom', 'Top', 'Right', 'Left'. """ if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] #StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identified shape or from which base object sturctural element is derived\n" ) return # Get points of U-Shape rebar points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation, diameter) import Part import Arch sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch') sketch.MapMode = "FlatFace" sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) sketch.addGeometry(Part.LineSegment(points[1], points[2]), False) import Sketcher sketch.addGeometry(Part.LineSegment(points[2], points[3]), False) if amount_spacing_check: rebar = Arch.makeRebar(structure, sketch, diameter, amount_spacing_value, f_cover + diameter / 2) FreeCAD.ActiveDocument.recompute() else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar(structure, sketch, diameter, int((size - diameter) / amount_spacing_value), f_cover + diameter / 2) rebar.Rounding = rounding # Adds properties to the rebar object rebar.ViewObject.addProperty( "App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "UShapeRebar" rebar.ViewObject.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty( "App::PropertyDistance", "RightCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar")).RightCover = r_cover rebar.setEditorMode("RightCover", 2) rebar.addProperty( "App::PropertyDistance", "LeftCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar")).LeftCover = l_cover rebar.setEditorMode("LeftCover", 2) rebar.addProperty( "App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).BottomCover = b_cover rebar.setEditorMode("BottomCover", 2) rebar.addProperty( "App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck rebar.setEditorMode("AmountCheck", 2) rebar.addProperty( "App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar")).TopCover = t_cover rebar.setEditorMode("TopCover", 2) rebar.addProperty( "App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP( "App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value rebar.setEditorMode("TrueSpacing", 2) rebar.addProperty( "App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).Orientation = orientation rebar.setEditorMode("Orientation", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value rebar.Label = "UShapeRebar" FreeCAD.ActiveDocument.recompute() return rebar
def makeStraightRebars( s_cover, t_offset, b_offset, dia_of_main_rebars, number_angle_check, number_angle_value, structure, facename, base_line_list=None, ): """makeStraightRebars(SideCover, TopOffset, BottomOffset, Diameter, NumberAngleCheck, NumberAngleValue, Structure, Facename, BaseLineObjList): Adds the straight rebars in circular column structural object. """ face = structure.Shape.Faces[(getFaceNumber(facename) - 1)] FacePRM = getParametersOfFace(structure, facename, False) column_size = ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0)).Length points_list = getPointsOfStraightRebars( FacePRM, s_cover, t_offset, b_offset, column_size, dia_of_main_rebars, number_angle_check, number_angle_value, ) import Arch import Draft pl = FreeCAD.Placement() pl.Rotation.Q = (0.5, 0.5, 0.5, 0.5) main_rebars_list = [] for i, points in enumerate(points_list): if not base_line_list or i >= len(base_line_list): line = Draft.makeWire( points, placement=pl, closed=False, face=True, support=[(structure, facename)], ) else: line = base_line_list[i] line.Start = points[0] line.End = points[1] main_rebars_list.append( Arch.makeRebar( structure, line, dia_of_main_rebars, amount=1, name="StraightRebar", )) main_rebars_list[-1].Label = "StraightRebar" main_rebars_list[-1].OffsetStart = 0 main_rebars_list[-1].OffsetEnd = 0 main_rebars_list[-1].addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() main_rebars_list[-1].RebarShape = "StraightRebar" main_rebars_list[-1].setEditorMode("RebarShape", 2) return main_rebars_list
def editLShapeRebar( Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Recompute sketch to resolve issue as discussed here: # https://forum.freecadweb.org/viewtopic.php?f=3&t=6989#p335986 sketch.recompute() # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename) # Get points of L-Shape rebar points = getpointsOfLShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, orientation, diameter) sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 1, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 2, points[2], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = int((size - diameter) / amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.Diameter = diameter Rebar.FrontCover = f_cover Rebar.LeftCover = l_cover Rebar.RightCover = r_cover Rebar.BottomCover = b_cover Rebar.TopCover = t_cover Rebar.Rounding = rounding Rebar.TrueSpacing = amount_spacing_value Rebar.Orientation = orientation FreeCAD.ActiveDocument.recompute() return Rebar
def getRebarData(self, obj): if not obj.Host: return if Draft.getType(obj.Host) != "Structure": return if not obj.Host.Shape: return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.Host wire = obj.Base.Shape.Wires[0] if Draft.getType( obj.Base) == "Wire": # Draft Wires can have "wrong" placement import DraftGeomUtils axis = DraftGeomUtils.getNormal(obj.Base.Shape) else: axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector( 0, 0, -1)) size = (ArchCommands.projectToVector(father.Shape.copy(), axis)).Length if hasattr(obj, "Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) axis.normalize() if hasattr(obj, "Distance"): if obj.Distance.Value: size = obj.Distance.Value if hasattr(obj, "Rounding"): if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire, radius) wires = [] if obj.Amount == 1: offset = DraftVecUtils.scaleTo(axis, size / 2) wire.translate(offset) wires.append(wire) else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis, obj.OffsetStart.Value) else: baseoffset = None if obj.ViewObject.RebarShape == "Stirrup": interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value + obj.Diameter.Value) else: interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) vinterval = DraftVecUtils.scaleTo(axis, interval) for i in range(obj.Amount): if i == 0: if baseoffset: wire.translate(baseoffset) wires.append(wire) else: wire = wire.copy() wire.translate(vinterval) wires.append(wire) return [wires, obj.Diameter.Value / 2]
def execute(self, obj): if self.clone(obj): return if not obj.Base: FreeCAD.Console.PrintError( "No Base, return without a rebar shape for {}.\n".format( obj.Name)) return if not obj.Base.Shape: FreeCAD.Console.PrintError( "No Shape in Base, return without a rebar shape for {}.\n". format(obj.Name)) return if not obj.Base.Shape.Wires: FreeCAD.Console.PrintError( "No Wires in Shape of Base, return without a rebar shape for {}.\n" .format(obj.Name)) return if not obj.Diameter.Value: FreeCAD.Console.PrintError( "No Diameter Value, return without a rebar shape for {}.\n". format(obj.Name)) return if not obj.Amount: return FreeCAD.Console.PrintError( "No Amount, return without a rebar shape for {}.\n".format( obj.Name)) father = obj.Host fathershape = None if not father: # support for old-style rebars if obj.InList: if hasattr(obj.InList[0], "Armatures"): if obj in obj.InList[0].Armatures: father = obj.InList[0] if father: if hasattr(father, 'Shape'): fathershape = father.Shape wire = obj.Base.Shape.Wires[0] if hasattr(obj, "Rounding"): #print(obj.Rounding) if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire, radius) bpoint, bvec = self.getBaseAndAxis(wire) if not bpoint: return axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0, 0, -1)) if fathershape: size = (ArchCommands.projectToVector(fathershape.copy(), axis)).Length else: size = 1 if hasattr(obj, "Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) axis.normalize() if fathershape: size = (ArchCommands.projectToVector( fathershape.copy(), axis)).Length else: size = 1 if hasattr(obj, "Distance"): if obj.Distance.Value: size = obj.Distance.Value spacinglist = None if hasattr(obj, "CustomSpacing"): if obj.CustomSpacing: spacinglist = strprocessOfCustomSpacing(obj.CustomSpacing) influenceArea = sum( spacinglist) - spacinglist[0] / 2 - spacinglist[-1] / 2 # Drop this check to solve issue as discussed here: https://github.com/FreeCAD/FreeCAD/pull/2550 # if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: # return # all tests ok! if hasattr(obj, "Length"): length = getLengthOfRebar(obj) if length: obj.Length = length pl = obj.Placement import Part circle = Part.makeCircle(obj.Diameter.Value / 2, bpoint, bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle], True, False, 2) basewire = wire.copy() except Part.OCCError: print("Arch: error sweeping rebar profile along the base sketch") return # building final shape shapes = [] placementlist = [] self.wires = [] rot = FreeCAD.Rotation() if obj.Amount == 1: if obj.ViewObject: barplacement = CalculatePlacement(obj.Amount, 1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value, obj.ViewObject.RebarShape) else: barplacement = CalculatePlacement(obj.Amount, 1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) if hasattr(obj, "Spacing"): obj.Spacing = 0 else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis, obj.OffsetStart.Value) else: baseoffset = None if obj.ViewObject and obj.ViewObject.RebarShape == "Stirrup": interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value + obj.Diameter.Value) else: interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) for i in range(obj.Amount): if obj.ViewObject: barplacement = CalculatePlacement( obj.Amount, i + 1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value, obj.ViewObject.RebarShape) else: barplacement = CalculatePlacement(obj.Amount, i + 1, obj.Diameter.Value, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) if hasattr(obj, "Spacing"): obj.Spacing = interval # Calculate placement of bars from custom spacing. if spacinglist: placementlist[:] = [] if obj.ViewObject.RebarShape == "Stirrup": reqInfluenceArea = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value + obj.Diameter.Value) else: reqInfluenceArea = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) # Avoid unnecessary checks to pass like. For eg.: when we have values # like influenceArea is 100.00001 and reqInflueneArea is 100 if round(influenceArea) > round(reqInfluenceArea): FreeCAD.Console.PrintWarning( "Influence area of rebars is greater than " + str(reqInfluenceArea) + ".\n") elif round(influenceArea) < round(reqInfluenceArea): FreeCAD.Console.PrintWarning( "Last span is greater that end offset.\n") for i in range(len(spacinglist)): if i == 0: barplacement = CustomSpacingPlacement( spacinglist, 1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) else: barplacement = CustomSpacingPlacement( spacinglist, i + 1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) obj.Amount = len(spacinglist) obj.Spacing = 0 obj.PlacementList = placementlist for i in range(len(obj.PlacementList)): if i == 0: bar.Placement = obj.PlacementList[i] shapes.append(bar) basewire.Placement = obj.PlacementList[i] self.wires.append(basewire) else: bar = bar.copy() bar.Placement = obj.PlacementList[i] shapes.append(bar) w = basewire.copy() w.Placement = obj.PlacementList[i] self.wires.append(w) if shapes: obj.Shape = Part.makeCompound(shapes) obj.Placement = pl obj.TotalLength = obj.Length * len(obj.PlacementList)
def editStraightRebar( Rebar, f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename) # Get points of Striaght rebar points = getpointsOfStraightRebar( FacePRM, rt_cover, lb_cover, coverAlong, orientation, diameter, facenormalDirection(structure, facename), ) sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = int((size - diameter) / amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover Rebar.RightTopCover = rt_cover Rebar.LeftBottomCover = lb_cover Rebar.CoverAlong = coverAlong[0] Rebar.Cover = coverAlong[1] Rebar.TrueSpacing = amount_spacing_value Rebar.Diameter = diameter Rebar.Orientation = orientation FreeCAD.ActiveDocument.recompute() return Rebar
def makeStirrup(l_cover, r_cover, t_cover, b_cover, f_cover, bentAngle, bentFactor, diameter, rounding,\ amount_spacing_check, amount_spacing_value, structure = None, facename = None): """ makeStirrup(LeftCover, RightCover, TopCover, BottomCover, FrontCover, BentAngle, BentFactor, Diameter, Rounding, AmountSpacingCheck, AmountSpacingValue, Structure, Facename): Adds the Stirrup reinforcement bar to the selected structural object.""" if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] #StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename, False) FaceNormal = face.normalAt(0, 0) #FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identified shape or from which base object sturctural element is derived\n" ) return # Calculate the coordinate values of Stirrup points = getpointsOfStirrup(FacePRM, l_cover, r_cover, t_cover, b_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal) import Draft line = Draft.makeWire(points, closed=False, face=True, support=None) import Arch line.Support = [(structure, facename)] if amount_spacing_check: rebar = Arch.makeRebar(structure, line, diameter, amount_spacing_value, f_cover) else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar(structure, line, diameter,\ int((size - diameter) / amount_spacing_value), f_cover) rebar.Direction = FaceNormal.negative() rebar.Rounding = rounding # Adds properties to the rebar object rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property","Shape of rebar")).RebarShape = "Stirrup" rebar.ViewObject.setEditorMode("RebarShape", 2) rebar.addProperty("App::PropertyDistance", "LeftCover", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar")).LeftCover = l_cover rebar.setEditorMode("LeftCover", 2) rebar.addProperty("App::PropertyDistance", "RightCover", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar")).RightCover = r_cover rebar.setEditorMode("RightCover", 2) rebar.addProperty("App::PropertyDistance", "TopCover", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Top Side cover of rebar")).TopCover = t_cover rebar.setEditorMode("TopCover", 2) rebar.addProperty("App::PropertyDistance", "BottomCover", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Bottom Side cover of rebar")).BottomCover = b_cover rebar.setEditorMode("BottomCover", 2) rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar")).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty("App::PropertyInteger", "BentAngle", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Bent angle between at the end of rebar")).BentAngle = bentAngle rebar.setEditorMode("BentAngle", 2) rebar.addProperty("App::PropertyInteger", "BentFactor", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Bent Length is the equal to BentFactor * Diameter")).BentFactor = bentFactor rebar.setEditorMode("BentFactor", 2) rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck rebar.setEditorMode("AmountCheck", 2) rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog",\ QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value rebar.setEditorMode("TrueSpacing", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value rebar.Label = "Stirrup" FreeCAD.ActiveDocument.recompute() return rebar
def makeStraightRebar( f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation="Horizontal", structure=None, facename=None, ): """Adds the straight reinforcement bar to the selected structural object. Case I: When orientation of straight rebar is 'Horizontal': makeStraightRebar(FrontCover, CoverAlong, RightCover, LeftCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal", Structure, Facename) Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have horizontal orientation so we can pass Top Side and Bottom Side to <Along> arguments. For eg. ("Top Side", 20) and ("Bottom Side", 20) Case II: When orientation of straight rebar is 'Vertical': makeStraightRebar(FrontCover, CoverAlong, TopCover, BottomCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal", Structure, Facename) Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have vertical orientation so we can pass Left Side and Right Side to <Along> arguments. For eg. ("Left Side", 20) and ("Right Side", 20) """ if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identified shape or from which base object sturctural " "element is derived\n") return # Get points of Striaght rebar points = getpointsOfStraightRebar( FacePRM, rt_cover, lb_cover, coverAlong, orientation, diameter, facenormalDirection(structure, facename), ) import Part import Arch sketch = FreeCAD.activeDocument().addObject("Sketcher::SketchObject", "Sketch") sketch.MapMode = "FlatFace" sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) if amount_spacing_check: rebar = Arch.makeRebar( structure, sketch, diameter, amount_spacing_value, f_cover + diameter / 2, name="StraightRebar", ) FreeCAD.ActiveDocument.recompute() else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar( structure, sketch, diameter, int((size - diameter) / amount_spacing_value), f_cover + diameter / 2, name="StraightRebar", ) # Adds properties to the rebar object rebar.addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() rebar.RebarShape = "StraightRebar" rebar.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"), ).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty( "App::PropertyDistance", "RightTopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right/Top Side cover of rebar"), ).RightTopCover = rt_cover rebar.setEditorMode("RightTopCover", 2) rebar.addProperty( "App::PropertyDistance", "LeftBottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left/Bottom Side cover of rebar"), ).LeftBottomCover = lb_cover rebar.setEditorMode("LeftBottomCover", 2) rebar.addProperty( "App::PropertyString", "CoverAlong", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover along"), ).CoverAlong = coverAlong[0] rebar.setEditorMode("CoverAlong", 2) rebar.addProperty( "App::PropertyDistance", "Cover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover of rebar along user selected side"), ).Cover = coverAlong[1] rebar.setEditorMode("Cover", 2) rebar.addProperty( "App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"), ) rebar.setEditorMode("AmountCheck", 2) rebar.addProperty( "App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"), ).TrueSpacing = amount_spacing_value rebar.setEditorMode("TrueSpacing", 2) rebar.addProperty( "App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).Orientation = orientation rebar.setEditorMode("Orientation", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return rebar
def editStirrup( Rebar, l_cover, r_cover, t_cover, b_cover, f_cover, bentAngle, bentFactor, diameter, rounding, amount_spacing_check, amount_spacing_value, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename, False) FaceNormal = face.normalAt(0, 0) # FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal) # Calculate the coordinates value of Stirrup rebar points = getpointsOfStirrup( FacePRM, l_cover, r_cover, t_cover, b_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal, ) Rebar.Base.Points = points FreeCAD.ActiveDocument.recompute() Rebar.Direction = FaceNormal.negative() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 Rebar.BentAngle = bentAngle Rebar.BentFactor = bentFactor Rebar.Rounding = rounding Rebar.Diameter = diameter if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = get_rebar_amount_from_spacing(size, diameter, amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover Rebar.LeftCover = l_cover Rebar.RightCover = r_cover Rebar.TopCover = t_cover Rebar.BottomCover = b_cover Rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return Rebar
def execute(self,obj): if self.clone(obj): return if not obj.Base: return if not obj.Base.Shape: return if not obj.Base.Shape.Wires: return if not obj.Diameter.Value: return if not obj.Amount: return father = obj.Host fathershape = None if not father: # support for old-style rebars if obj.InList: if hasattr(obj.InList[0],"Armatures"): if obj in obj.InList[0].Armatures: father = obj.InList[0] if father: if father.isDerivedFrom("Part::Feature"): fathershape = father.Shape wire = obj.Base.Shape.Wires[0] if hasattr(obj,"Rounding"): #print(obj.Rounding) if obj.Rounding: radius = obj.Rounding * obj.Diameter.Value import DraftGeomUtils wire = DraftGeomUtils.filletWire(wire,radius) bpoint, bvec = self.getBaseAndAxis(wire) if not bpoint: return axis = obj.Base.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1)) if fathershape: size = (ArchCommands.projectToVector(fathershape.copy(),axis)).Length else: size = 1 if hasattr(obj,"Direction"): if not DraftVecUtils.isNull(obj.Direction): axis = FreeCAD.Vector(obj.Direction) axis.normalize() if fathershape: size = (ArchCommands.projectToVector(fathershape.copy(),axis)).Length else: size = 1 if hasattr(obj,"Distance"): if obj.Distance.Value: size = obj.Distance.Value #print(axis) #print(size) spacinglist = None if hasattr(obj, "CustomSpacing"): if obj.CustomSpacing: spacinglist = strprocessOfCustomSpacing(obj.CustomSpacing) influenceArea = sum(spacinglist) - spacinglist[0] / 2 - spacinglist[-1] / 2 if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size: return # all tests ok! pl = obj.Placement import Part circle = Part.makeCircle(obj.Diameter.Value/2,bpoint,bvec) circle = Part.Wire(circle) try: bar = wire.makePipeShell([circle],True,False,2) except Part.OCCError: print("Arch: error sweeping rebar profile along the base sketch") return # building final shape shapes = [] placementlist = [] if father: rot = father.Placement.Rotation else: rot = FreeCAD.Rotation() if obj.Amount == 1: barplacement = CalculatePlacement(obj.Amount, 1, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) if hasattr(obj,"Spacing"): obj.Spacing = 0 else: if obj.OffsetStart.Value: baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) else: baseoffset = None interval = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) interval = interval / (obj.Amount - 1) for i in range(obj.Amount): barplacement = CalculatePlacement(obj.Amount, i+1, size, axis, rot, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) if hasattr(obj,"Spacing"): obj.Spacing = interval # Calculate placement of bars from custom spacing. if spacinglist: placementlist[:] = [] reqInfluenceArea = size - (obj.OffsetStart.Value + obj.OffsetEnd.Value) if influenceArea > reqInfluenceArea: return FreeCAD.Console.PrintError("Influence area of rebars is greater than "+ str(reqInfluenceArea) + ".\n") elif influenceArea < reqInfluenceArea: FreeCAD.Console.PrintWarning("Last span is greater that end offset.\n") for i in range(len(spacinglist)): if i == 0: barplacement = CustomSpacingPlacement(spacinglist, 1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) else: barplacement = CustomSpacingPlacement(spacinglist, i+1, axis, father.Placement.Rotation, obj.OffsetStart.Value, obj.OffsetEnd.Value) placementlist.append(barplacement) obj.Amount = len(spacinglist) obj.Spacing = 0 obj.PlacementList = placementlist for i in range(len(obj.PlacementList)): if i == 0: bar.Placement = obj.PlacementList[i] shapes.append(bar) else: bar = bar.copy() bar.Placement = obj.PlacementList[i] shapes.append(bar) if shapes: obj.Shape = Part.makeCompound(shapes) obj.Placement = pl
def editUShapeRebar(Rebar, f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch." ) return # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] #StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename) # Get points of U-Shape rebar points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation) sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 1, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 2, points[2], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(2, 1, points[2], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(2, 2, points[3], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover Rebar.OffsetEnd = f_cover if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = int((size - diameter) / amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.Diameter = diameter Rebar.FrontCover = f_cover Rebar.RightCover = r_cover Rebar.LeftCover = l_cover Rebar.BottomCover = b_cover Rebar.TopCover = t_cover Rebar.Rounding = rounding Rebar.TrueSpacing = amount_spacing_value Rebar.Orientation = orientation FreeCAD.ActiveDocument.recompute() return Rebar
def makeHelicalRebar(s_cover, b_cover, diameter, t_cover, pitch, structure=None, facename=None): """makeHelicalRebar(SideCover, BottomCover, Diameter, TopCover, Pitch, Structure, Facename): Adds the Helical reinforcement bar to the selected structural object.""" if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename, False) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identified shape or from which base object sturctural " "element is derived\n") return size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length normal = face.normalAt(0, 0) # normal = face.Placement.Rotation.inverted().multVec(normal) import Arch helix = createHelicalWire(FacePRM, s_cover, b_cover, t_cover, pitch, size, normal, diameter) helix.Support = [(structure, facename)] rebar = Arch.makeRebar(structure, helix, diameter, 1, diameter / 2, name="HelicalRebar") rebar.OffsetStart = diameter / 2 rebar.OffsetEnd = diameter / 2 FreeCAD.ActiveDocument.recompute() # Adds properties to the rebar object rebar.addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() rebar.RebarShape = "HelicalRebar" rebar.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "SideCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"), ).SideCover = s_cover rebar.setEditorMode("SideCover", 2) rebar.addProperty( "App::PropertyDistance", "Pitch", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"), ).Pitch = pitch rebar.setEditorMode("Pitch", 2) rebar.addProperty( "App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar"), ).BottomCover = b_cover rebar.setEditorMode("BottomCover", 2) rebar.addProperty( "App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"), ).TopCover = t_cover rebar.setEditorMode("TopCover", 2) FreeCAD.ActiveDocument.recompute() return rebar