diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index ad7c8f0be..1eb7fc076 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -75,7 +75,7 @@ def makeSectionView(section,name="View"): return view -def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1,techdraw=False): +def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1,techdraw=False,rotation=0): """getSVG(section,[allOn,renderMode,showHidden,showFill,scale,linewidth,fontsize]) : returns an SVG fragment from an Arch section plane. If allOn is True, all cut objects are shown, regardless if they are visible or not. @@ -214,7 +214,6 @@ def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill= svgs = svgs.replace('stroke-width="0.35 px"','stroke-width="SWPlaceholder"') svgs = svgs.replace('stroke-width:0.35','stroke-width:SWPlaceholder') svg += svgs - scaledlinewidth = linewidth/scale st = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("CutLineThickness",2) da = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetString("archHiddenPattern","30,10") @@ -226,14 +225,17 @@ def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill= if not techdraw: svg += '' for d in drafts: - svg += Draft.getSVG(d,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw) + svg += Draft.getSVG(d,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw,rotation=rotation) if not techdraw: svg += '' + # filter out spaces not cut by the section plane + if cutface and spaces: + spaces = [s for s in spaces if s.Shape.BoundBox.intersect(cutface.BoundBox)] if spaces: if not techdraw: svg += '' for s in spaces: - svg += Draft.getSVG(s,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw) + svg += Draft.getSVG(s,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw,rotation=rotation) if not techdraw: svg += '' #print "complete node:",svg diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 9b6ce84c2..b19da480c 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -1723,7 +1723,7 @@ def getDXF(obj,direction=None): return result -def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False): +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): '''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 @@ -2253,6 +2253,8 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct c = getrgb(obj.ViewObject.TextColor) n = obj.ViewObject.FontName a = 0 + if rotation != 0: + a = -math.radians(rotation) t1 = obj.ViewObject.Proxy.text1.string.getValues() t2 = obj.ViewObject.Proxy.text2.string.getValues() scale = obj.ViewObject.FirstLine.Value/obj.ViewObject.FontSize.Value @@ -2263,7 +2265,10 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct j = obj.ViewObject.TextAlign svg += getText(c,f1,n,a,getProj(p1),t1,linespacing,j,flip=True) if t2: - svg += getText(c,fontsize,n,a,getProj(p1).add(FreeCAD.Vector(0,lspc.Length,0)),t2,linespacing,j,flip=True) + 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).add(ofs),t2,linespacing,j,flip=True) elif obj.isDerivedFrom('Part::Feature'): if obj.Shape.isNull(): diff --git a/src/Mod/TechDraw/App/DrawViewArch.cpp b/src/Mod/TechDraw/App/DrawViewArch.cpp index 289480ff2..70185b7fb 100644 --- a/src/Mod/TechDraw/App/DrawViewArch.cpp +++ b/src/Mod/TechDraw/App/DrawViewArch.cpp @@ -109,7 +109,8 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void) << ",scale=" << Scale.getValue() << ",linewidth=" << LineWidth.getValue() << ",fontsize=" << FontSize.getValue() - << ",techdraw=True"; + << ",techdraw=True" + << ",rotation=" << Rotation.getValue(); Base::Interpreter().runString("import ArchSectionPlane"); Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)",