Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arch: Fix ArchFrame #5479

Merged
merged 1 commit into from Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 27 additions & 31 deletions src/Mod/Arch/ArchFrame.py
Expand Up @@ -152,10 +152,10 @@ def execute(self,obj):
else:
if not obj.Profile:
return
if not obj.Profile.isDerivedFrom("Part::Part2DObject"):
return
if not obj.Profile.Shape:
return
if obj.Profile.Shape.findPlane() is None:
return
if not obj.Profile.Shape.Wires:
return
if not obj.Profile.Shape.Faces:
Expand All @@ -177,7 +177,6 @@ def execute(self,obj):
baseprofile = Part.makeCompound(f)
shapes = []
normal = DraftGeomUtils.getNormal(obj.Base.Shape)
#for wire in obj.Base.Shape.Wires:
edges = obj.Base.Shape.Edges
if hasattr(obj,"Edges"):
if obj.Edges == "Vertical edges":
Expand All @@ -199,47 +198,44 @@ def execute(self,obj):
z = edges[0].CenterOfMass.z
edges = [e for e in edges if abs(e.CenterOfMass.z-z) < 0.00001]
for e in edges:
#e = wire.Edges[0]
bvec = DraftGeomUtils.vec(e)
bpoint = e.Vertexes[0].Point
profile = baseprofile.copy()
#basepoint = profile.Placement.Base
if hasattr(obj,"BasePoint"):
rot = None # New rotation.
# Supplying FreeCAD.Rotation() with two parallel vectors and
# a null vector may seem strange, but the function is perfectly
# able to handle this. Its algorithm will use default axes in
# such cases.
if obj.Align:
if normal is None:
rot = FreeCAD.Rotation(FreeCAD.Vector(), bvec, bvec, "ZYX")
else:
rot = FreeCAD.Rotation(FreeCAD.Vector(), normal, bvec, "ZYX")
profile.Placement.Rotation = rot
if hasattr(obj, "BasePoint"):
edges = Part.__sortEdges__(profile.Edges)
basepointliste = [profile.CenterOfMass]
basepointliste = [profile.Placement.Base]
for edge in edges:
basepointliste.append(DraftGeomUtils.findMidpoint(edge))
basepointliste.append(edge.Vertexes[-1].Point)
try:
basepoint = basepointliste[obj.BasePoint]
except IndexError:
FreeCAD.Console.PrintMessage(translate("Arch","Crossing point not found in profile.")+"\n")
FreeCAD.Console.PrintMessage(translate("Arch", "Crossing point not found in profile.")+"\n")
basepoint = basepointliste[0]
else :
basepoint = profile.CenterOfMass
profile.translate(bpoint.sub(basepoint))
if obj.Align:
# Align profile's Z axis with the direction of the layout edge.
axis = profile.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1))
angle = bvec.getAngle(axis)
if round(angle,Draft.precision()) != 0:
if round(angle,Draft.precision()) != round(math.pi,Draft.precision()):
rotaxis = axis.cross(bvec)
profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(rotaxis), math.degrees(angle))
# Align profile's Y axis with layouts normal vecror.
axis = profile.Placement.Rotation.multVec(FreeCAD.Vector(0,1,0))
angle = normal.getAngle(axis)
if round(angle,Draft.precision()) != 0:
if round(angle,Draft.precision()) != round(math.pi,Draft.precision()):
rotaxis = axis.cross(normal)
profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(rotaxis), math.degrees(angle))
else:
basepoint = profile.Placement.Base
delta = bpoint.sub(basepoint) # Translation vector.
if obj.Offset and (not DraftVecUtils.isNull(obj.Offset)):
if rot is None:
delta = delta + obj.Offset
else:
delta = delta + rot.multVec(obj.Offset)
profile.translate(delta)
if obj.Rotation:
profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(FreeCAD.Vector(bvec).normalize()), obj.Rotation)
#profile = wire.makePipeShell([profile],True,False,2) TODO buggy
profile.rotate(bpoint, bvec, obj.Rotation)
# profile = wire.makePipeShell([profile], True, False, 2) TODO buggy
profile = profile.extrude(bvec)
if obj.Offset:
if not DraftVecUtils.isNull(obj.Offset):
profile.translate(obj.Offset)
shapes.append(profile)
if shapes:
if hasattr(obj,"Fuse"):
Expand Down