Arch Added extra panel tools for sliptonic:

* ArchPanelCut.getWires(): returns (outlines,holes,tags) of this panel
* ArchPanelSheet.getOutlines(): returns the outlines of inner panels
* ArchPanelSheet.getHoles(): returns the holes of inner panels
* ArchPanelSheet.getTags(): returns the tags of inner panels
This commit is contained in:
Yorik van Havre
2017-03-16 18:12:10 -03:00
parent 18a7e73bf6
commit 6be77ef271
2 changed files with 152 additions and 40 deletions

View File

@@ -723,6 +723,43 @@ class PanelCut(Draft._DraftObject):
obj.Shape = base
obj.Placement = pl
def getWires(self,obj):
"""getWires(obj): returns a tuple containing 3 shapes
that define the panel outline, the panel holes, and
tags (engravings): (outline,holes,tags). Any of these can
be None if nonexistent"""
tag = None
outl = None
inl = None
if not hasattr(self,"outline"):
self.execute(obj)
if not hasattr(self,"outline"):
return None
outl = self.outline
if hasattr(self,"tag"):
tag = self.tag
if tag:
tag.Placement = obj.Placement.multiply(tag.Placement)
if parent:
tag.Placement = parent.Placement.multiply(tag.Placement)
outl.Placement = obj.Placement.multiply(outl.Placement)
if len(outl.Wires) > 1:
# separate outline
d = 0
ow = None
for w in outl.Wires:
if w.BoundBox.DiagonalLength > d:
d = w.BoundBox.DiagonalLength
ow = w
if ow:
inl = Part.Compound([w for w in outl.Wires if w.hashCode() != ow.hashCode()])
outl = ow
else:
inl = None
outl = outl.Wires[0]
return (outl,inl,tags)
class ViewProviderPanelCut(Draft._ViewProviderDraft):
"a view provider for the panel cut object"
@@ -853,6 +890,66 @@ class PanelSheet(Draft._DraftObject):
obj.Placement = pl
obj.FillRatio = int((subarea/area)*100)
def getOutlines(self,obj,transform=False):
"""getOutlines(obj,transform=False): returns a list of wires that define the
outlines of the panels in this sheet. If transform is True, the placement of
the sheet will be added to each wire"""
outp = []
for p in obj.Group:
ispanel = False
if hasattr(p,"Proxy"):
if hasattr(p.Proxy,"getWires"):
ispanel = True
w = p.Proxy.getWires(p)
if w[0]:
w = w[0]
if transform:
w.Placement = obj.Placement.multiply(w.Placement)
outp.append(w)
if not ispanel:
if p.isDerivedFrom("Part::Feature"):
for w in p.Shape.Wires:
if transform:
w.Placement = obj.Placement.multiply(w.Placement)
outp.append(w)
return outp
def getHoles(self,obj,transform=False):
"""getHoles(obj,transform=False): returns a list of wires that define the
holes contained in the panels in this sheet. If transform is True, the placement of
the sheet will be added to each wire"""
outp = []
for p in obj.Group:
if hasattr(p,"Proxy"):
if hasattr(p.Proxy,"getWires"):
w = p.Proxy.getWires(p)
if w[1]:
w = w[1]
if transform:
w.Placement = obj.Placement.multiply(w.Placement)
outp.append(w)
return outp
def getTags(self,obj,transform=False):
"""getTags(obj,transform=False): returns a list of wires that define the
tags (engravings) contained in the panels in this sheet. If transform is
True, the placement of the sheet will be added to each wire. Warning, the
wires returned by this function may not be closed, depending on the font"""
outp = []
for p in obj.Group:
if hasattr(p,"Proxy"):
if hasattr(p.Proxy,"getWires"):
w = p.Proxy.getWires(p)
if w[1]:
w = w[1]
if transform:
w.Placement = obj.Placement.multiply(w.Placement)
outp.append(w)
return outp
class ViewProviderPanelSheet(Draft._ViewProviderDraft):
"a view provider for the panel sheet object"

View File

@@ -1874,7 +1874,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
return ''
def getPath(edges=[],wires=[],pathname=None):
import DraftGeomUtils
import Part,DraftGeomUtils
svg = "<path "
if pathname is None:
svg += 'id="%s" ' % obj.Name
@@ -1916,45 +1916,60 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
if plane: drawing_plane_normal = plane.axis
c = e.Curve
if round(c.Axis.getAngle(drawing_plane_normal),2) == 0:
if len(e.Vertexes) == 1 and iscircle: #complete curve
svg = getCircle(e)
return svg
elif len(e.Vertexes) == 1 and isellipse:
#svg = getEllipse(e)
#return svg
endpoints = (getProj(c.value((c.LastParameter-\
c.FirstParameter)/2.0)), \
getProj(vs[-1].Point))
else:
endpoints = (getProj(vs[-1].Point),)
# arc
if iscircle:
rx = ry = c.Radius
rot = 0
else: #ellipse
rx = c.MajorRadius
ry = c.MinorRadius
rot = math.degrees(c.AngleXU * (c.Axis * \
FreeCAD.Vector(0,0,1)))
if rot > 90:
rot -=180
if rot < -90:
rot += 180
#be careful with the sweep flag
flag_large_arc = (((e.ParameterRange[1] - \
e.ParameterRange[0]) / math.pi) % 2) > 1
#flag_sweep = (c.Axis * drawing_plane_normal >= 0) \
# == (e.LastParameter > e.FirstParameter)
# == (e.Orientation == "Forward")
# other method: check the direction of the angle between tangents
t1 = e.tangentAt(e.FirstParameter)
t2 = e.tangentAt(e.FirstParameter + (e.LastParameter-e.FirstParameter)/10)
flag_sweep = (DraftVecUtils.angle(t1,t2,drawing_plane_normal) < 0)
for v in endpoints:
edata += 'A %s %s %s %s %s %s %s ' % \
(str(rx),str(ry),str(rot),\
str(int(flag_large_arc)),\
str(int(flag_sweep)),str(v.x),str(v.y))
occversion = Part.OCC_VERSION.split(".")
done = False
if (occversion[0] >= 7) and (occversion[1] >= 1):
# if using occ >= 7.1, use HLR algorithm
import Drawing
snip = Drawing.projectToSVG(e,drawing_plane_normal)
if snip:
try:
a = "A " + snip.split("path d=\"")[1].split("\"")[0].split("A")[1]
except:
pass
else:
edata += a
done = True
if not done:
if len(e.Vertexes) == 1 and iscircle: #complete curve
svg = getCircle(e)
return svg
elif len(e.Vertexes) == 1 and isellipse:
#svg = getEllipse(e)
#return svg
endpoints = (getProj(c.value((c.LastParameter-\
c.FirstParameter)/2.0)), \
getProj(vs[-1].Point))
else:
endpoints = (getProj(vs[-1].Point),)
# arc
if iscircle:
rx = ry = c.Radius
rot = 0
else: #ellipse
rx = c.MajorRadius
ry = c.MinorRadius
rot = math.degrees(c.AngleXU * (c.Axis * \
FreeCAD.Vector(0,0,1)))
if rot > 90:
rot -=180
if rot < -90:
rot += 180
#be careful with the sweep flag
flag_large_arc = (((e.ParameterRange[1] - \
e.ParameterRange[0]) / math.pi) % 2) > 1
#flag_sweep = (c.Axis * drawing_plane_normal >= 0) \
# == (e.LastParameter > e.FirstParameter)
# == (e.Orientation == "Forward")
# other method: check the direction of the angle between tangents
t1 = e.tangentAt(e.FirstParameter)
t2 = e.tangentAt(e.FirstParameter + (e.LastParameter-e.FirstParameter)/10)
flag_sweep = (DraftVecUtils.angle(t1,t2,drawing_plane_normal) < 0)
for v in endpoints:
edata += 'A %s %s %s %s %s %s %s ' % \
(str(rx),str(ry),str(rot),\
str(int(flag_large_arc)),\
str(int(flag_sweep)),str(v.x),str(v.y))
else:
edata += getDiscretized(e)
elif DraftGeomUtils.geomType(e) == "Line":