Draft: fix rectangle with face offset bug

This commit is contained in:
Roy-043
2022-10-30 12:49:28 +01:00
parent 1282fdb7e8
commit c9233ecdce
3 changed files with 17 additions and 7 deletions

View File

@@ -72,9 +72,12 @@ def offset(obj, delta, copy=False, bind=False, sym=False, occ=False):
newwire = None
delete = None
if utils.get_type(obj).startswith("Part::") or utils.get_type(obj).startswith("Sketcher::"):
copy = True
if (copy is False
and (utils.get_type(obj).startswith("Sketcher::")
or utils.get_type(obj).startswith("Part::")
or utils.get_type(obj).startswith("PartDesign::"))): # For PartDesign_SubShapeBinders which can reference sketches.
print("the offset tool is currently unable to offset a non-Draft object directly - Creating a copy")
copy = True
def getRect(p,obj):
"""returns length,height,placement"""
@@ -199,7 +202,7 @@ def offset(obj, delta, copy=False, bind=False, sym=False, occ=False):
try:
if p:
newobj = make_wire(p)
newobj.Closed = obj.Shape.isClosed()
newobj.Closed = DraftGeomUtils.isReallyClosed(obj.Shape)
except Part.OCCError:
pass
if (not newobj) and newwire:

View File

@@ -33,6 +33,7 @@ import DraftVecUtils
from draftgeoutils.general import geomType, vec
from draftgeoutils.geometry import get_normal
from draftgeoutils.wires import isReallyClosed
from draftgeoutils.intersections import wiresIntersect, connect
# Delay import of module until first use because it is heavy
@@ -237,7 +238,7 @@ def offsetWire(wire, dvec, bind=False, occ=False,
if norm is None:
norm = App.Vector(0, 0, 1)
closed = wire.isClosed()
closed = isReallyClosed(wire)
nedges = []
if occ:
length = abs(dvec.Length)

View File

@@ -270,9 +270,15 @@ def isReallyClosed(wire):
return False
# If more than 1 edge, further test below
v1 = wire.Edges[0].Vertexes[0].Point # v1 = wire.Vertexes[0].Point
v2 = wire.Edges[length-1].Vertexes[1].Point # v2 = wire.Vertexes[-1].Point
if DraftVecUtils.equals(v1, v2):
e1 = wire.Edges[0]
e2 = wire.Edges[length-1]
if DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[0].Point):
return True
if DraftVecUtils.equals(e1.Vertexes[0].Point, e2.Vertexes[1].Point):
return True
if DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[0].Point):
return True
if DraftVecUtils.equals(e1.Vertexes[1].Point, e2.Vertexes[1].Point):
return True
return False