Arch/TechDraw: TD Arch views now have a 'fillSpaces' property to show Arch spaces as color-filled areas

This commit is contained in:
Yorik van Havre
2019-04-19 18:20:33 -03:00
parent 9d296194e8
commit ea0c7694cd
5 changed files with 46 additions and 24 deletions

View File

@@ -68,7 +68,7 @@ def getPattern(pat):
return ''
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0):
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0,fillSpaces=False):
'''getSVG(object,[scale], [linewidth],[fontsize],[fillstyle],[direction],[linestyle],[color],[linespacing]):
returns a string containing a SVG representation of the given object,
with the given linewidth and fontsize (used if the given object contains
@@ -732,6 +732,19 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
if not obj.ViewObject:
print ("export of spaces to SVG is only available in GUI mode")
else:
if fillSpaces:
if hasattr(obj,"Proxy"):
if not hasattr(obj.Proxy,"face"):
obj.Proxy.getArea(obj,notouch=True)
if hasattr(obj.Proxy,"face"):
# setting fill
if gui:
fill = getrgb(obj.ViewObject.ShapeColor,testbw=False)
fill_opacity = 1 - (obj.ViewObject.Transparency / 100.0)
else:
fill = "#888888"
lstyle = getLineStyle(linestyle, scale)
svg += getPath(wires=[obj.Proxy.face.OuterWire])
c = getrgb(obj.ViewObject.TextColor)
n = obj.ViewObject.FontName
a = 0
@@ -741,16 +754,18 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
t2 = obj.ViewObject.Proxy.text2.string.getValues()
scale = obj.ViewObject.FirstLine.Value/obj.ViewObject.FontSize.Value
f1 = fontsize*scale
p2 = FreeCAD.Vector(obj.ViewObject.Proxy.coords.translation.getValue().getValue())
p2 = obj.Placement.multVec(FreeCAD.Vector(obj.ViewObject.Proxy.coords.translation.getValue().getValue()))
lspc = FreeCAD.Vector(obj.ViewObject.Proxy.header.translation.getValue().getValue())
p1 = p2.add(lspc)
j = obj.ViewObject.TextAlign
svg += getText(c,f1,n,a,getProj(p1, plane),t1,linespacing,j,flip=True)
t3 = getText(c,f1,n,a,getProj(p1, plane),t1,linespacing,j,flip=True)
svg += t3
if t2:
ofs = FreeCAD.Vector(0,lspc.Length,0)
ofs = FreeCAD.Vector(0,-lspc.Length,0)
if a:
ofs = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),-rotation).multVec(ofs)
svg += getText(c,fontsize,n,a,getProj(p1, plane).add(ofs),t2,linespacing,j,flip=True)
t4 = getText(c,fontsize,n,a,getProj(p1, plane).add(ofs),t2,linespacing,j,flip=True)
svg += t4
elif obj.isDerivedFrom('Part::Feature'):
if obj.Shape.isNull():