Exemplo n.º 1
0
 def setUp(self):
     self.clone = None
     self.doc = FreeCAD.open(FreeCAD.getHomePath() +
                             "Mod/Path/PathTests/test_holes00.fcstd")
     self.job = PathJob.Create("Job", [self.doc.Body])
Exemplo n.º 2
0
    def test02(self):
        '''Verify bones are correctly generated for a Profile.'''
        doc = FreeCAD.newDocument("TestDressupDogbone")

        # This is a real world test to make sure none of the tool chain broke
        box0 = doc.addObject('Part::Box', 'Box')
        box0.Width = 100
        box0.Length = 100
        box0.Height = 10
        box1 = doc.addObject('Part::Box', 'Box')
        box1.Width = 50
        box1.Length = 50
        box1.Height = 20
        box1.Placement = FreeCAD.Placement(
            FreeCAD.Vector(25, 25, -5),
            FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 0))
        doc.recompute()
        cut = doc.addObject('Part::Cut', 'Cut')
        cut.Base = box0
        cut.Tool = box1
        doc.recompute()

        for i in range(11):
            face = "Face%d" % (i + 1)
            f = cut.Shape.getElement(face)
            if f.Surface.Axis == FreeCAD.Vector(
                    0, 0, 1) and f.Orientation == 'Forward':
                break

        PathJob.Create('Job', [cut], None)

        profile = PathProfileFaces.Create('Profile Faces')
        profile.Base = (cut, face)
        profile.StepDown = 5
        # set start and final depth in order to eliminate effects of stock (and its default values)
        profile.setExpression('StartDepth', None)
        profile.StartDepth = 10
        profile.setExpression('FinalDepth', None)
        profile.FinalDepth = 0

        profile.processHoles = True
        profile.processPerimeter = True
        doc.recompute()

        dogbone = PathDressupDogbone.Create(profile)
        doc.recompute()

        dog = dogbone.Proxy
        locs = sorted([bone[1] for bone in dog.bones],
                      key=lambda xy: xy[0] * 1000 + xy[1])

        def formatBoneLoc(pt):
            return "(%.2f, %.2f)" % (pt[0], pt[1])

        # Make sure we get 8 bones, 2 in each corner (different heights)
        # with start point changes it passes back over the same spot multiple times, so just make sure they are in the right locations
        # self.assertEqual(len(locs), 8)
        self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[0]))
        self.assertEqual("(27.50, 27.50)", formatBoneLoc(locs[1]))
        self.assertEqual("(27.50, 72.50)", formatBoneLoc(locs[2]))
        self.assertEqual("(27.50, 72.50)", formatBoneLoc(locs[3]))
        self.assertEqual("(72.50, 27.50)", formatBoneLoc(locs[4]))
        self.assertEqual("(72.50, 27.50)", formatBoneLoc(locs[5]))
        self.assertEqual("(72.50, 72.50)", formatBoneLoc(locs[6]))
        self.assertEqual("(72.50, 72.50)", formatBoneLoc(locs[7]))

        FreeCAD.closeDocument("TestDressupDogbone")
Exemplo n.º 3
0
 def setUp(self):
     self.doc = FreeCAD.open(FreeCAD.getHomePath() + 'Mod/Path/PathTests/test_holes00.fcstd')
     self.job = PathJob.Create('Job', [self.doc.Body])