From d9872bfa57f9452d0ff9014b48d867bb1448d649 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 24 Apr 2012 21:54:07 -0300 Subject: [PATCH] Added code to join similar object types in Arch SectionPlane --- src/Mod/Arch/ArchSectionPlane.py | 132 ++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 45 deletions(-) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 04a8fb1d31..7113f4fabf 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -122,7 +122,6 @@ class _ViewProviderSectionPlane(ArchComponent.ViewProviderComponent): self.setVerts() def setColor(self): - print self.Object.ViewObject.LineColor self.col.rgb.setValue(self.Object.ViewObject.LineColor[0], self.Object.ViewObject.LineColor[1], self.Object.ViewObject.LineColor[2]) @@ -173,54 +172,97 @@ class _ArchDrawingView: if prop in ["Source","RenderingMode"]: obj.ViewResult = self.updateSVG(obj) - def updateSVG(self, obj): + def updateSVG(self, obj,join=False): "encapsulates a svg fragment into a transformation node" import Part from draftlibs import fcgeo - if obj.Source: - if obj.Source.Objects: - svg = '' - cp = ArchCommands.getCutVolume(obj.Source.Objects,obj.Source.Placement) - self.sections = [] - if cp: - cutvolume = cp[0].extrude(cp[1]) - shapes = [] - colors = [] - for o in obj.Source.Objects: - color = o.ViewObject.DiffuseColor[0] - print "adding ",o.Name," with color ",color + if hasattr(obj,"Source"): + if obj.Source: + if obj.Source.Objects: + svg = '' + + # getting section plane + cp = ArchCommands.getCutVolume(obj.Source.Objects,obj.Source.Placement) + self.sections = [] if cp: - for s in o.Shape.Solids: - shapes.append(s.cut(cutvolume)) - colors.append(color) - sec = o.Shape.section(cp[0]) - if sec.Edges: - wires = fcgeo.findWires(sec.Edges) - for w in wires: - sec = Part.Wire(fcgeo.sortEdges(w.Edges)) - sec = Part.Face(sec) - self.sections.append(sec) + cutvolume = cp[0].extrude(cp[1]) + shapes = [] + colors = [] + + # sorting + if join: + walls = [] + structs = [] + objs = [] + for o in obj.Source.Objects: + t = Draft.getType(o) + if t == "Wall": + walls.append(o) + elif t == "Structure": + structs.append(o) + else: + objs.append(o) + for g in [walls,structs]: + if g: + print "group:",g + col = g[0].ViewObject.DiffuseColor[0] + s = g[0].Shape + for o in g[1:]: + try: + fs = s.fuse(o.Shape) + fs = fs.removeSplitter() + except: + print "shape fusion failed" + objs.append([o.Shape,o.ViewObject.DiffuseColor[0]]) + else: + s = fs + objs.append([s,col]) else: - shapes.append(o.Shape) - colors.append(color) - linewidth = obj.LineWidth/obj.Scale - if obj.RenderingMode == "Solid": - svg += self.renderVRM(shapes,obj.Source.Placement,colors,linewidth) - else: - svg += self.renderOCC(shapes,obj.Source.Proxy.getNormal(obj.Source),linewidth) - for s in self.sections: - svg += self.renderSection(s,obj.Source.Placement,linewidth*2) - result = '' - result += '