def createGeometry(self,obj): import Part from draftlibs import fcgeo pl = obj.Placement if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): if obj.WindowParts and (len(obj.WindowParts)%5 == 0): shapes = [] for i in range(len(obj.WindowParts)/5): wires = [] wstr = obj.WindowParts[(i*5)+2].split(',') for s in wstr: j = int(s[4:]) if obj.Base.Shape.Wires: if len(obj.Base.Shape.Wires) >= j: wires.append(obj.Base.Shape.Wires[j]) if wires: max_length = 0 for w in wires: if w.BoundBox.DiagonalLength > max_length: max_length = w.BoundBox.DiagonalLength ext = w wires.remove(ext) shape = Part.Face(ext) norm = shape.normalAt(0,0) thk = float(obj.WindowParts[(i*5)+3]) if thk: exv = fcvec.scaleTo(norm,thk) shape = shape.extrude(exv) for w in wires: f = Part.Face(w) f = f.extrude(exv) shape = shape.cut(f) if obj.WindowParts[(i*5)+4]: zof = float(obj.WindowParts[(i*5)+4]) if zof: zov = fcvec.scaleTo(norm,zof) shape.translate(zov) print shape shapes.append(shape) obj.Shape = Part.makeCompound(shapes) if not fcgeo.isNull(pl): obj.Placement = pl
def createGeometry(self, obj): import Part from draftlibs import fcgeo pl = obj.Placement if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): if obj.WindowParts and (len(obj.WindowParts) % 5 == 0): shapes = [] for i in range(len(obj.WindowParts) / 5): wires = [] wstr = obj.WindowParts[(i * 5) + 2].split(',') for s in wstr: j = int(s[4:]) if len(obj.Base.Shape.Wires) >= j: wires.append(obj.Base.Shape.Wires[j]) if wires: max_length = 0 for w in wires: if w.BoundBox.DiagonalLength > max_length: max_length = w.BoundBox.DiagonalLength ext = w wires.remove(ext) shape = Part.Face(ext) norm = shape.normalAt(0, 0) thk = float(obj.WindowParts[(i * 5) + 3]) if thk: exv = fcvec.scaleTo(norm, thk) shape = shape.extrude(exv) for w in wires: f = Part.Face(w) f = f.extrude(exv) shape = shape.cut(f) if obj.WindowParts[(i * 5) + 4]: zof = float(obj.WindowParts[(i * 5) + 4]) if zof: zov = fcvec.scaleTo(norm, zof) shape.translate(zov) shapes.append(shape) obj.Shape = Part.makeCompound(shapes) if not fcgeo.isNull(pl): obj.Placement = pl
def createGeometry(self, obj): import Part from draftlibs import fcgeo # getting default values height = normal = None if obj.Length: length = obj.Length else: length = 1 if obj.Width: width = obj.Width else: width = 1 if obj.Height: height = obj.Height else: for p in obj.InList: if Draft.getType(p) == "Floor": height = p.Height if not height: height = 1 if obj.Normal == Vector(0, 0, 0): normal = Vector(0, 0, 1) else: normal = Vector(obj.Normal) # creating shape pl = obj.Placement norm = normal.multiply(height) base = None if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): base = obj.Base.Shape.copy() if base.Solids: pass elif base.Faces: base = base.extrude(normal) elif (len(base.Wires) == 1) and base.Wires[0].isClosed(): base = Part.Face(base.Wires[0]) base = base.extrude(normal) else: l2 = length / 2 or 0.5 w2 = width / 2 or 0.5 v1 = Vector(-l2, -w2, 0) v2 = Vector(l2, -w2, 0) v3 = Vector(l2, w2, 0) v4 = Vector(-l2, w2, 0) base = Part.makePolygon([v1, v2, v3, v4, v1]) base = Part.Face(base) base = base.extrude(normal) for app in obj.Additions: base = base.oldFuse(app.Shape) app.ViewObject.hide() # to be removed for hole in obj.Subtractions: cut = False if hasattr(hole, "Proxy"): if hasattr(hole.Proxy, "Subvolume"): if hole.Proxy.Subvolume: print "cutting subvolume", hole.Proxy.Subvolume base = base.cut(hole.Proxy.Subvolume) cut = True if not cut: if hasattr(obj, "Shape"): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed if base: pts = self.getAxisPoints(obj) if pts: fsh = [] for p in pts: sh = base.copy() sh.translate(p) fsh.append(sh) obj.Shape = Part.makeCompound(fsh) else: obj.Shape = base if not fcgeo.isNull(pl): obj.Placement = pl
def createGeometry(self, obj): import Part from draftlibs import fcgeo flat = False if hasattr(obj.ViewObject, "DisplayMode"): flat = (obj.ViewObject.DisplayMode == "Flat 2D") def getbase(wire): "returns a full shape from a base wire" dvec = fcgeo.vec(wire.Edges[0]).cross(normal) dvec.normalize() if obj.Align == "Left": dvec = dvec.multiply(obj.Width) w2 = fcgeo.offsetWire(wire, dvec) sh = fcgeo.bind(wire, w2) elif obj.Align == "Right": dvec = dvec.multiply(obj.Width) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire, dvec) sh = fcgeo.bind(wire, w2) elif obj.Align == "Center": dvec = dvec.multiply(obj.Width / 2) w1 = fcgeo.offsetWire(wire, dvec) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire, dvec) sh = fcgeo.bind(w1, w2) # fixing self-intersections sh.fix(0.1, 0, 1) if height and (not flat): norm = Vector(normal).multiply(height) sh = sh.extrude(norm) return sh pl = obj.Placement # getting default values height = normal = None if obj.Height: height = obj.Height else: for p in obj.InList: if Draft.getType(p) == "Floor": height = p.Height if not height: height = 1 if obj.Normal == Vector(0, 0, 0): normal = Vector(0, 0, 1) else: normal = Vector(obj.Normal) # computing shape if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): base = obj.Base.Shape.copy() if base.Solids: pass elif base.Faces: if height: norm = normal.multiply(height) base = base.extrude(norm) elif base.Wires: temp = None for wire in obj.Base.Shape.Wires: sh = getbase(wire) if temp: temp = temp.oldFuse(sh) else: temp = sh base = temp else: if obj.Length == 0: return v1 = Vector(0, 0, 0) v2 = Vector(obj.Length, 0, 0) w = Part.Wire(Part.Line(v1, v2).toShape()) base = getbase(w) for app in obj.Additions: base = base.oldFuse(app.Shape) app.ViewObject.hide() #to be removed for hole in obj.Subtractions: if Draft.getType(hole) == "Window": # window if hole.Base and obj.Width: f = self.getSubVolume(hole.Base, obj.Width) base = base.cut(f) elif Draft.isClone(hole, "Window"): if hole.Objects[0].Base and obj.Width: f = self.getSubVolume(hole.Objects[0].Base, obj.Width, hole.Placement.Base) base = base.cut(f) elif hasattr(obj, "Shape"): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed obj.Shape = base if not fcgeo.isNull(pl): obj.Placement = pl
def createGeometry(self,obj): import Part from draftlibs import fcgeo # getting default values height = normal = None if obj.Length: length = obj.Length else: length = 1 width = 1 if hasattr(obj,"Width"): if obj.Width: width = obj.Width if obj.Height: height = obj.Height else: for p in obj.InList: if Draft.getType(p) == "Floor": height = p.Height if not height: height = 1 if obj.Normal == Vector(0,0,0): normal = Vector(0,0,1) else: normal = Vector(obj.Normal) # creating shape pl = obj.Placement norm = normal.multiply(height) base = None if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): base = obj.Base.Shape.copy() if base.Solids: pass elif base.Faces: base = base.extrude(normal) elif (len(base.Wires) == 1) and base.Wires[0].isClosed(): base = Part.Face(base.Wires[0]) base = base.extrude(normal) else: l2 = length/2 or 0.5 w2 = width/2 or 0.5 v1 = Vector(-l2,-w2,0) v2 = Vector(l2,-w2,0) v3 = Vector(l2,w2,0) v4 = Vector(-l2,w2,0) base = Part.makePolygon([v1,v2,v3,v4,v1]) base = Part.Face(base) base = base.extrude(normal) for app in obj.Additions: base = base.oldFuse(app.Shape) app.ViewObject.hide() # to be removed for hole in obj.Subtractions: cut = False if hasattr(hole,"Proxy"): if hasattr(hole.Proxy,"Subvolume"): if hole.Proxy.Subvolume: print "cutting subvolume",hole.Proxy.Subvolume base = base.cut(hole.Proxy.Subvolume) cut = True if not cut: if hasattr(obj,"Shape"): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed if base: pts = self.getAxisPoints(obj) if pts: fsh = [] for p in pts: sh = base.copy() sh.translate(p) fsh.append(sh) obj.Shape = Part.makeCompound(fsh) else: obj.Shape = base if not fcgeo.isNull(pl): obj.Placement = pl
def createGeometry(self,obj): "builds the wall shape" if not obj.Base: return import Part from draftlibs import fcgeo flat = False if hasattr(obj.ViewObject,"DisplayMode"): flat = (obj.ViewObject.DisplayMode == "Flat 2D") width = 1.0 if hasattr(obj,"Width"): if obj.Width: width = obj.Width def getbase(wire): "returns a full shape from a base wire" dvec = fcgeo.vec(wire.Edges[0]).cross(normal) dvec.normalize() if obj.Align == "Left": dvec = dvec.multiply(width) w2 = fcgeo.offsetWire(wire,dvec) w1 = Part.Wire(fcgeo.sortEdges(wire.Edges)) sh = fcgeo.bind(w1,w2) elif obj.Align == "Right": dvec = dvec.multiply(width) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire,dvec) w1 = Part.Wire(fcgeo.sortEdges(wire.Edges)) sh = fcgeo.bind(w1,w2) elif obj.Align == "Center": dvec = dvec.multiply(width/2) w1 = fcgeo.offsetWire(wire,dvec) dvec = fcvec.neg(dvec) w2 = fcgeo.offsetWire(wire,dvec) sh = fcgeo.bind(w1,w2) # fixing self-intersections sh.fix(0.1,0,1) if height and (not flat): norm = Vector(normal).multiply(height) sh = sh.extrude(norm) return sh pl = obj.Placement # getting default values height = normal = None if obj.Height: height = obj.Height else: for p in obj.InList: if Draft.getType(p) == "Floor": height = p.Height if not height: height = 1 if obj.Normal == Vector(0,0,0): normal = Vector(0,0,1) else: normal = Vector(obj.Normal) # computing shape base = None if obj.Base.isDerivedFrom("Part::Feature"): if not obj.Base.Shape.isNull(): base = obj.Base.Shape.copy() if base.Solids: pass elif base.Faces: if height: norm = normal.multiply(height) base = base.extrude(norm) elif base.Wires: temp = None for wire in obj.Base.Shape.Wires: sh = getbase(wire) if temp: temp = temp.fuse(sh) else: temp = sh base = temp base = base.removeSplitter() for app in obj.Additions: base = base.oldFuse(app.Shape) app.ViewObject.hide() #to be removed for hole in obj.Subtractions: if Draft.getType(hole) == "Window": # window if hole.Base and obj.Width: f = self.getSubVolume(hole.Base,width) base = base.cut(f) elif Draft.isClone(hole,"Window"): if hole.Objects[0].Base and width: f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement.Base) base = base.cut(f) elif hasattr(hole,"Shape"): if not hole.Shape.isNull(): base = base.cut(hole.Shape) hole.ViewObject.hide() # to be removed if base: obj.Shape = base if not fcgeo.isNull(pl): obj.Placement = pl