Example #1
0
    def _buildPathArea(self, obj, baseobject, start=None, getsim=False):
        PathLog.track()
        profile = Path.Area()
        profile.setPlane(makeWorkplane(baseobject))
        profile.add(baseobject)

        profileparams = {'Fill': 0, 'Coplanar': 2}

        if obj.UseComp is False:
            profileparams['Offset'] = 0.0
        else:
            profileparams['Offset'] = self.radius + obj.OffsetExtra.Value

        heights = [i for i in self.depthparams]
        PathLog.debug('depths: {}'.format(heights))
        profile.setParams(**profileparams)
        #obj.AreaParams = str(profile.getParams())

        PathLog.debug("Contour with params: {}".format(profile.getParams()))
        sections = profile.makeSections(mode=0, project=True, heights=heights)
        shapelist = [sec.getShape() for sec in sections]

        params = {
            'shapes': shapelist,
            'feedrate': self.horizFeed,
            'feedrate_v': self.vertFeed,
            'verbose': True,
            'resume_height': obj.StepDown.Value,
            'retraction': obj.ClearanceHeight.Value,
            'return_end': True
        }

        if obj.Direction == 'CCW':
            params['orientation'] = 1
        else:
            params['orientation'] = 0

        if self.endVector is not None:
            params['start'] = self.endVector
        elif start is not None:
            params['start'] = start

        (pp, end_vector) = Path.fromShapes(**params)
        PathLog.debug("Generating Path with params: {}".format(params))
        PathLog.debug('pp: {}, end vector: {}'.format(pp, end_vector))
        self.endVector = end_vector

        simobj = None
        if getsim:
            profileparams[
                'Thicken'] = True  #{'Fill':0, 'Coplanar':0, 'Project':True, 'SectionMode':2, 'Thicken':True}
            profileparams['ToolRadius'] = self.radius - self.radius * .005
            profile.setParams(**profileparams)
            sec = profile.makeSections(mode=0, project=False,
                                       heights=heights)[-1].getShape()
            simobj = sec.extrude(FreeCAD.Vector(0, 0,
                                                baseobject.BoundBox.ZMax))

        return pp, simobj
Example #2
0
    def _buildPathArea(self, obj, baseobject, start=None):
        PathLog.track()
        profile = Path.Area()
        profile.setPlane(makeWorkplane(baseobject))
        profile.add(baseobject)

        profileparams = {'Fill': 0, 'Coplanar': 0}

        if obj.UseComp is False:
            profileparams['Offset'] = 0.0
        else:
            profileparams['Offset'] = self.radius + obj.OffsetExtra.Value

        depthparams = depth_params(clearance_height=obj.ClearanceHeight.Value,
                                   rapid_safety_space=obj.SafeHeight.Value,
                                   start_depth=obj.StartDepth.Value,
                                   step_down=obj.StepDown.Value,
                                   z_finish_step=0.0,
                                   final_depth=obj.FinalDepth.Value,
                                   user_depths=None)

        PathLog.debug('depths: {}'.format(depthparams.get_depths()))
        profile.setParams(**profileparams)
        PathLog.debug("Contour with params: {}".format(profile.getParams()))

        sections = profile.makeSections(mode=0,
                                        project=True,
                                        heights=depthparams.get_depths())
        shapelist = [sec.getShape() for sec in sections]

        params = {
            'shapes': shapelist,
            'feedrate': self.horizFeed,
            'feedrate_v': self.vertFeed,
            'verbose': True,
            'resume_height': obj.StepDown.Value,
            'retraction': obj.ClearanceHeight.Value,
            'return_end': True
        }

        if obj.Direction == 'CCW':
            params['orientation'] = 1
        else:
            params['orientation'] = 0

        if self.endVector is not None:
            params['start'] = self.endVector
        elif start is not None:
            params['start'] = start

        (pp, end_vector) = Path.fromShapes(**params)
        PathLog.debug("Generating Path with params: {}".format(params))
        PathLog.debug('pp: {}, end vector: {}'.format(pp, end_vector))
        self.endVector = end_vector

        return pp
Example #3
0
    def _buildPathArea(self, obj, baseobject):
        """build the face path using PathArea"""

        PathLog.track()
        boundary = Path.Area()
        boundary.setPlane(makeWorkplane(baseobject))
        boundary.add(baseobject)

        stepover = (self.radius * 2) * (float(obj.StepOver)/100)

        pocketparams = {'Fill': 0,
                        'Coplanar': 0,
                        'PocketMode': 1,
                        'SectionCount': -1,
                        'Angle': obj.ZigZagAngle,
                        'FromCenter': (obj.StartAt == "Center"),
                        'PocketStepover': stepover,
                        'PocketExtraOffset': 0 - obj.PassExtension.Value}

        Pattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle']
        pocketparams['PocketMode'] = Pattern.index(obj.OffsetPattern) + 1

        offsetval = self.radius
        pocketparams['ToolRadius'] = offsetval

        heights = [i for i in self.depthparams]
        boundary.setParams(**pocketparams)
        obj.AreaParams = str(boundary.getParams())
        sections = boundary.makeSections(mode=0, project=False, heights=heights)

        params = {'feedrate': self.horizFeed,
                  'feedrate_v': self.vertFeed,
                  'verbose': True,
                  'resume_height': obj.StepDown,
                  'retraction': obj.ClearanceHeight.Value}

        pp = []

        if obj.UseStartPoint and obj.StartPoint is not None:
            params['start'] = obj.StartPoint

        # store the params for debugging. Don't need the shape.
        obj.PathParams = str(params)
        PathLog.debug("Generating Path with params: {}".format(params))

        for sec in sections:
            shape = sec.getShape()
            respath = Path.fromShapes(shape, **params)
            # Insert any entry code to the layer

            # append the layer path
            pp.extend(respath.Commands)
            respath.Commands = pp

        return respath
Example #4
0
    def _buildPathArea(self, obj, baseobject):
        """build the face path using PathArea"""

        PathLog.track()
        boundary = Path.Area()
        boundary.setPlane(makeWorkplane(baseobject))
        boundary.add(baseobject)

        stepover = (self.radius * 2) * (float(obj.StepOver) / 100)

        pocketparams = {
            'Fill': 0,
            'Coplanar': 0,
            'PocketMode': 1,
            'SectionCount': -1,
            'Angle': obj.ZigZagAngle,
            'FromCenter': (obj.StartAt == "Center"),
            'PocketStepover': stepover,
            'PocketExtraOffset': 0 - obj.PassExtension.Value
        }

        Pattern = [
            'ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid',
            'Triangle'
        ]
        pocketparams['PocketMode'] = Pattern.index(obj.OffsetPattern) + 1

        offsetval = self.radius
        pocketparams['ToolRadius'] = offsetval

        heights = [i for i in self.depthparams]
        boundary.setParams(**pocketparams)
        #obj.AreaParams = str(boundary.getParams())
        #PathLog.track('areaparams: {}'.format(obj.AreaParams))
        PathLog.track('height: {}'.format(heights))
        sections = boundary.makeSections(mode=0,
                                         project=False,
                                         heights=heights)
        shapelist = [sec.getShape() for sec in sections]

        params = {
            'shapes': shapelist,
            'feedrate': self.horizFeed,
            'feedrate_v': self.vertFeed,
            'verbose': True,
            'resume_height': obj.StepDown,
            'retraction': obj.ClearanceHeight.Value
        }

        PathLog.debug("Generating Path with params: {}".format(params))
        pp = Path.fromShapes(**params)

        return pp
Example #5
0
    def _buildPathArea(self, obj, baseobject, start=None, getsim=False):
        PathLog.track()
        profile = Path.Area()
        profile.setPlane(makeWorkplane(baseobject))
        profile.add(baseobject)

        profileparams = {'Fill': 0, 'Coplanar': 2}

        if obj.UseComp is False:
            profileparams['Offset'] = 0.0
        else:
            profileparams['Offset'] = self.radius + obj.OffsetExtra.Value

        jointype = ['Round', 'Square', 'Miter']
        profileparams['JoinType'] = jointype.index(obj.JoinType)

        if obj.JoinType == 'Miter':
            profileparams['MiterLimit'] = obj.MiterLimit

        heights = [i for i in self.depthparams]
        PathLog.debug('depths: {}'.format(heights))
        profile.setParams(**profileparams)
        obj.AreaParams = str(profile.getParams())

        PathLog.debug("Contour with params: {}".format(profile.getParams()))
        sections = profile.makeSections(mode=0, project=True, heights=heights)
        shapelist = [sec.getShape() for sec in sections]

        params = {
            'shapes': shapelist,
            'feedrate': self.horizFeed,
            'feedrate_v': self.vertFeed,
            'verbose': True,
            'resume_height': obj.StepDown.Value,
            'retraction': obj.ClearanceHeight.Value,
            'return_end': True
        }

        if obj.Direction == 'CCW':
            params['orientation'] = 0
        else:
            params['orientation'] = 1

        if self.endVector is not None:
            params['start'] = self.endVector
        elif obj.UseStartPoint:
            params['start'] = obj.StartPoint

        obj.PathParams = str(
            {key: value
             for key, value in params.items() if key != 'shapes'})

        (pp, end_vector) = Path.fromShapes(**params)
        PathLog.debug('pp: {}, end vector: {}'.format(pp, end_vector))
        self.endVector = end_vector

        simobj = None
        if getsim:
            profileparams['Thicken'] = True
            profileparams['ToolRadius'] = self.radius - self.radius * .005
            profile.setParams(**profileparams)
            sec = profile.makeSections(mode=0, project=False,
                                       heights=heights)[-1].getShape()
            simobj = sec.extrude(FreeCAD.Vector(0, 0,
                                                baseobject.BoundBox.ZMax))

        return pp, simobj