def execute(self, obj): PathLog.track() if not obj.Base: PathLog.error(translate('Path_DressupTag', 'No Base object found.')) return if not obj.Base.isDerivedFrom('Path::Feature'): PathLog.error( translate('Path_DressupTag', 'Base is not a Path::Feature object.')) return if not obj.Base.Path: PathLog.error( translate('Path_DressupTag', 'Base doesn\'t have a Path to dress-up.')) return if not obj.Base.Path.Commands: PathLog.error(translate('Path_DressupTag', 'Base Path is empty.')) return self.obj = obj minZ = +sys.maxint minX = minZ minY = minZ maxZ = -sys.maxint maxX = maxZ maxY = maxZ # the assumption is that all helixes are in the xy-plane - in other words there is no # intermittent point of a command that has a lower/higher Z-position than the start and # and end positions of a command. lastPt = FreeCAD.Vector(0, 0, 0) for cmd in obj.Base.Path.Commands: pt = PathGeom.commandEndPoint(cmd, lastPt) if lastPt.x != pt.x: maxX = max(pt.x, maxX) minX = min(pt.x, minX) if lastPt.y != pt.y: maxY = max(pt.y, maxY) minY = min(pt.y, minY) if lastPt.z != pt.z: maxZ = max(pt.z, maxZ) minZ = min(pt.z, minZ) lastPt = pt PathLog.debug("bb = (%.2f, %.2f, %.2f) ... (%.2f, %.2f, %.2f)" % (minX, minY, minZ, maxX, maxY, maxZ)) self.ptMin = FreeCAD.Vector(minX, minY, minZ) self.ptMax = FreeCAD.Vector(maxX, maxY, maxZ) self.masterSolid = TagSolid(self, minZ, self.toolRadius()) self.solids = [ self.masterSolid.cloneAt(pos) for pos in self.obj.Positions ] self.tagSolid = Part.Compound(self.solids) self.wire, rapid = PathGeom.wireForPath(obj.Base.Path) self.edges = self.wire.Edges maxTagZ = minZ + obj.Height.Value # lastX = 0 # lastY = 0 lastZ = 0 commands = [] for cmd in obj.Base.Path.Commands: if cmd in PathGeom.CmdMove: if lastZ <= maxTagZ or cmd.Parameters.get('Z', lastZ) <= maxTagZ: pass else: commands.append(cmd) else: commands.append(cmd) obj.Path = obj.Base.Path PathLog.track()
def execute(self, obj): PathLog.track() if not obj.Base: PathLog.error(translate('Path_DressupTag', 'No Base object found.')) return if not obj.Base.isDerivedFrom('Path::Feature'): PathLog.error(translate('Path_DressupTag', 'Base is not a Path::Feature object.')) return if not obj.Base.Path: PathLog.error(translate('Path_DressupTag', 'Base doesn\'t have a Path to dress-up.')) return if not obj.Base.Path.Commands: PathLog.error(translate('Path_DressupTag', 'Base Path is empty.')) return self.obj = obj minZ = +sys.maxint minX = minZ minY = minZ maxZ = -sys.maxint maxX = maxZ maxY = maxZ # the assumption is that all helixes are in the xy-plane - in other words there is no # intermittent point of a command that has a lower/higher Z-position than the start and # and end positions of a command. lastPt = FreeCAD.Vector(0, 0, 0) for cmd in obj.Base.Path.Commands: pt = PathGeom.commandEndPoint(cmd, lastPt) if lastPt.x != pt.x: maxX = max(pt.x, maxX) minX = min(pt.x, minX) if lastPt.y != pt.y: maxY = max(pt.y, maxY) minY = min(pt.y, minY) if lastPt.z != pt.z: maxZ = max(pt.z, maxZ) minZ = min(pt.z, minZ) lastPt = pt PathLog.debug("bb = (%.2f, %.2f, %.2f) ... (%.2f, %.2f, %.2f)" % (minX, minY, minZ, maxX, maxY, maxZ)) self.ptMin = FreeCAD.Vector(minX, minY, minZ) self.ptMax = FreeCAD.Vector(maxX, maxY, maxZ) self.masterSolid = TagSolid(self, minZ, self.toolRadius()) self.solids = [self.masterSolid.cloneAt(pos) for pos in self.obj.Positions] self.tagSolid = Part.Compound(self.solids) self.wire, rapid = PathGeom.wireForPath(obj.Base.Path) self.edges = self.wire.Edges maxTagZ = minZ + obj.Height.Value # lastX = 0 # lastY = 0 lastZ = 0 commands = [] for cmd in obj.Base.Path.Commands: if cmd in PathGeom.CmdMove: if lastZ <= maxTagZ or cmd.Parameters.get('Z', lastZ) <= maxTagZ: pass else: commands.append(cmd) else: commands.append(cmd) obj.Path = obj.Base.Path PathLog.track()