From cf474f60ed7ff316c48e9726ace1f38f33b9e317 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 8 Apr 2020 14:34:51 +0200 Subject: [PATCH] Arch: rebar, allow to make rebars from an edge too --- src/Mod/Arch/ArchRebar.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Mod/Arch/ArchRebar.py b/src/Mod/Arch/ArchRebar.py index 9ce7aceb00..0f4c40f921 100644 --- a/src/Mod/Arch/ArchRebar.py +++ b/src/Mod/Arch/ArchRebar.py @@ -312,9 +312,15 @@ class _Rebar(ArchComponent.Component): .format(obj.Name) ) return - if not obj.Base.Shape.Wires: + if obj.Base.Shape.Faces: FreeCAD.Console.PrintError( - "No Wires in Shape of Base, return without a rebar shape for {}.\n" + "Faces in Shape of Base, return without a rebar shape for {}.\n" + .format(obj.Name) + ) + return + if not obj.Base.Shape.Edges: + FreeCAD.Console.PrintError( + "No Edges in Shape of Base, return without a rebar shape for {}.\n" .format(obj.Name) ) return @@ -342,13 +348,22 @@ class _Rebar(ArchComponent.Component): if hasattr(father,'Shape'): fathershape = father.Shape - wire = obj.Base.Shape.Wires[0] + import Part + # corner cases: + # compound from more Wires + # compound without Wires but with multiple Edges + # Does they make sense? If yes handle them. + # Does it makes sense to handle Shapes with Faces or even Solids? + if not obj.Base.Shape.Wires and len(obj.Base.Shape.Edges) == 1: + wire = Part.Wire(obj.Base.Shape.Edges[0]) + else: + 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) + from DraftGeomUtils import filletWire + wire = filletWire(wire,radius) bpoint, bvec = self.getBaseAndAxis(wire) if not bpoint: return @@ -382,7 +397,6 @@ class _Rebar(ArchComponent.Component): if length: obj.Length = length pl = obj.Placement - import Part circle = Part.makeCircle(obj.Diameter.Value/2,bpoint,bvec) circle = Part.Wire(circle) try: