Draft: Draft-to-Drawing command now works on groups

This commit is contained in:
Yorik van Havre 2013-08-21 19:15:10 -03:00
parent a39397cf89
commit 61837b6ef8

View File

@ -1447,6 +1447,8 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
pass pass
elif getType(obj) == "Dimension": elif getType(obj) == "Dimension":
svg = ""
if obj.ViewObject.Proxy:
p1,p2,p3,p4,tbase,norm,rot = obj.ViewObject.Proxy.calcGeom(obj) p1,p2,p3,p4,tbase,norm,rot = obj.ViewObject.Proxy.calcGeom(obj)
dimText = getParam("dimPrecision") dimText = getParam("dimPrecision")
dimText = "%."+str(dimText)+"f" dimText = "%."+str(dimText)+"f"
@ -1595,10 +1597,13 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
lstyle = getLineStyle(obj) lstyle = getLineStyle(obj)
name = obj.Name name = obj.Name
if gui: if gui:
try:
if obj.ViewObject.DisplayMode == "Shaded": if obj.ViewObject.DisplayMode == "Shaded":
stroke = "none" stroke = "none"
else: else:
stroke = getrgb(obj.ViewObject.LineColor) stroke = getrgb(obj.ViewObject.LineColor)
except:
stroke = "#000000"
else: else:
stroke = "#000000" stroke = "#000000"
@ -3442,8 +3447,17 @@ class _DrawingView(_DraftObject):
def updateSVG(self, obj): def updateSVG(self, obj):
"encapsulates a svg fragment into a transformation node" "encapsulates a svg fragment into a transformation node"
result = ""
if hasattr(obj,"Source"):
if obj.Source:
if obj.Source.isDerivedFrom("App::DocumentObjectGroup"):
svg = ""
shapes = []
others = []
for o in obj.Source.Group:
svg += getSVG(o,obj.Scale,obj.LineWidth,obj.FontSize,obj.FillStyle,obj.Direction)
else:
svg = getSVG(obj.Source,obj.Scale,obj.LineWidth,obj.FontSize,obj.FillStyle,obj.Direction) svg = getSVG(obj.Source,obj.Scale,obj.LineWidth,obj.FontSize,obj.FillStyle,obj.Direction)
result = ''
result += '<g id="' + obj.Name + '"' result += '<g id="' + obj.Name + '"'
result += ' transform="' result += ' transform="'
result += 'rotate('+str(obj.Rotation)+','+str(obj.X)+','+str(obj.Y)+') ' result += 'rotate('+str(obj.Rotation)+','+str(obj.X)+','+str(obj.Y)+') '