コード例 #1
0
 def test_basic(self):
     mate1 = Mate(Box())
     mate2 = Mate(Box())
     c = Coincident(mate1, mate2)
     # assert composition
     self.assertEqual(id(mate1), id(c.mate))
     self.assertEqual(id(mate2), id(c.to_mate))
コード例 #2
0
 def make_constraints(self):
     board = self.components["board"]
     constr = [
         Fixed(
             board.mate_origin,
             CoordSystem(origin=(0, 0,
                                 self.standoff + board.thickness / 2)),
         )
     ]
     for i, j in enumerate(board.mount_verts()):
         m = Mate(
             self,
             CoordSystem(
                 origin=(j.X, j.Y, self.standoff + board.thickness),
                 xDir=(1, 0, 0),
                 normal=(0, 0, 1),
             ),
         )
         constr.append(
             Coincident(self.components[self.screw_name(i)].mate_origin,
                        m)),
         constr.append(
             Coincident(
                 self.components[self.standoff_name(i)].mate_top(),
                 Mate(
                     self,
                     CoordSystem(
                         origin=(j.X, j.Y, self.standoff),
                         xDir=(1, 0, 0),
                         normal=(0, 0, 1),
                     ),
                 ),
             ))
     return constr
コード例 #3
0
 def test_mate(self):
     mate = Mate(Box())
     cs1 = CoordSystem(origin=(1, 1, 1))
     box = Box()
     box.world_coords = cs1
     cs2 = CoordSystem(origin=(2, 3, 4))
     coords = Mate(box, cs2)
     c = Fixed(mate, coords)  # given world_coords is from a mate
     self.assertEqual(cs1 + cs2, c.world_coords)
コード例 #4
0
ファイル: generate.py プロジェクト: gntech/cqparts
 def make_constraints(self):
     return [
         Fixed(self.components['chassis'].mate_origin),
         Coincident(
             self.components['front_axle'].mate_origin,
             Mate(self.components['chassis'], CoordSystem((self.wheelbase/2,0,0))),
         ),
         Coincident(
             self.components['rear_axle'].mate_origin,
             Mate(self.components['chassis'], CoordSystem((-self.wheelbase/2,0,0))),
         ),
     ]
コード例 #5
0
 def make_constraints(self):
     constr = [
         Fixed(self.components["mount"].mate_origin),
         Coincident(
             self.components["stepper"].mate_origin,
             self.components["mount"].mate_motor(),
         ),
     ]
     # if driven is defined
     if self.driven is not None:
         shaft_length = self.stepper().shaft_length
         constr.append(
             Coincident(
                 self.components["driven"].mate_wheel(),
                 self.components["mount"].mate_motor(offset=shaft_length),
             ))
     # if the mount is defined add the
     mnt = self.find("mount")
     if self.target is not None:
         for i, j in enumerate(self.components["mount"].mount_points()):
             m = Mate(
                 self,
                 CoordSystem(
                     origin=(j.X, j.Y, -mnt.thickness),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1),
                 ),
             )
             constr.append(
                 Coincident(self.components[self.mount_name(i)].mate_origin,
                            m))
     # screws for stepper to mount
     for i, j in enumerate(self.components["stepper"].mount_points()):
         m = Mate(
             self,
             CoordSystem(
                 origin=(
                     j.X,
                     -mnt.length / 2,
                     j.Y + mnt.height / 2 + mnt.clearance / 2 +
                     mnt.thickness,
                 ),
                 xDir=(1, 0, 0),
                 normal=(0, -1, 0),
             ),
         )
         constr.append(
             Coincident(self.components[self.screw_name(i)].mate_origin, m))
     return constr
コード例 #6
0
ファイル: mercanum.py プロジェクト: zignig/cqparts_bucket
 def mate_end(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(-self.length / 2, 0, 0),
                     xDir=(0, 0, 1),
                     normal=(1, 0, 0)),
     )
コード例 #7
0
 def mate_top(self):
     " top of the stator"
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.length / 2),
                     xDir=(0, 1, 0),
                     normal=(0, 0, 1)))
コード例 #8
0
    def test_translation(self):
        box = Box()

        # +'ve translation
        c = Fixed(Mate(box, CoordSystem()), CoordSystem(origin=(1, 2, 3)))
        (part, coords) = list(solver([c]))[0]
        self.assertEqual(coords.origin, cadquery.Vector(1, 2, 3))
        self.assertEqual(coords.xDir, cadquery.Vector(1, 0, 0))
        self.assertEqual(coords.zDir, cadquery.Vector(0, 0, 1))

        # -'ve translation
        c = Fixed(Mate(box, CoordSystem(origin=(1, 2, 3))), CoordSystem())
        (part, coords) = list(solver([c]))[0]
        self.assertEqual(coords.origin, cadquery.Vector(-1, -2, -3))
        self.assertEqual(coords.xDir, cadquery.Vector(1, 0, 0))
        self.assertEqual(coords.zDir, cadquery.Vector(0, 0, 1))
コード例 #9
0
 def mate_right(self):
     return Mate(
         self,
         CoordSystem(origin=(0, self.length / 2, 0),
                     xDir=(1, 0, 0),
                     normal=(0, 1, 0)),
     )
コード例 #10
0
ファイル: roller.py プロジェクト: zignig/cqparts_bucket
 def mate_tip(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.length),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
コード例 #11
0
 def mate_holder(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, 0),
                     # xDir=(1, 0, 0), normal=(0, 0, 1),
                     ),
     )
コード例 #12
0
 def mate_gear(self):
     """This is at the centre and end of the drive shaft"""
     return Mate(
         self,
         CoordSystem(origin=(8.5, 0, 26.75),
                     xDir=(1, 0, 1),
                     normal=(0, 0, -1)))
コード例 #13
0
 def pulley_B_mate(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(-offset, -self.spacing, 0),
                     xDir=(0, 1, 0),
                     normal=(1, 0, 0)),
     )
コード例 #14
0
ファイル: coupling.py プロジェクト: zignig/cqparts_bucket
 def mate_output(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.gap / 2),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
コード例 #15
0
 def mate_bottom(self, explode=0):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, -2 * explode),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1)),
     )
コード例 #16
0
 def mate_two(self):
     return Mate(
         self,
         CoordSystem(origin=(0, -11, 0),
                     # xDir=(1, 0, 0), normal=(0, -1, 0),
                     ),
     )
コード例 #17
0
 def mate_holder(self):
     return Mate(
         self,
         CoordSystem(origin=(-90, 17.5, 128),
                     xDir=(1, 0, 0),
                     normal=(0, -1, 0)),
     )
コード例 #18
0
 def mate_beam2(self):
     return Mate(
         self,
         CoordSystem(origin=(10, 17.5, 128),
                     xDir=(0, -1, 0),
                     normal=(-1, 0, 0)),
     )
コード例 #19
0
 def test_world_coords(self):
     cs1 = CoordSystem(origin=(1, 2, 3))
     cs2 = CoordSystem(origin=(1, 1, 1))
     box = Box()
     box.world_coords = cs2
     m = Mate(box, cs1)
     self.assertEqual(m.world_coords, cs1 + cs2)
コード例 #20
0
ファイル: pencil_case.py プロジェクト: zignig/cqparts_bucket
 def mate_top(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.height),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1)),
     )
コード例 #21
0
 def mate_top(self):
     " connect to the end of the top cap"
     return Mate(
         self,
         CoordSystem(origin=(0, 0, -self.length / 2),
                     xDir=(0, 1, 0),
                     normal=(0, 0, -1)))
コード例 #22
0
 def mate_centre(self):
     """Assumes rotating around Z axis"""
     return Mate(
         self,
         CoordSystem(origin=(0, 0, +self.width / 2),
                     #            xDir=(1, 0, 0), normal=(0, -1, 0),
                     ))
コード例 #23
0
ファイル: stepper.py プロジェクト: zignig/cqparts_bucket
 def mate_tip(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.shaft_length),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
コード例 #24
0
    def test_rotation(self):
        box = Box()

        # +'ve rotation
        c = Fixed(Mate(box, CoordSystem()), CoordSystem(xDir=(1, 0.1, 0)))
        (part, coords) = list(solver([c]))[0]
        self.assertEqual(coords.origin, cadquery.Vector())
        self.assertEqual(coords.xDir, cadquery.Vector(1, 0.1, 0).normalized())
        self.assertEqual(coords.zDir, cadquery.Vector(0, 0, 1))

        # -'ve rotation
        c = Fixed(Mate(box, CoordSystem(xDir=(1, 0.1, 0))), CoordSystem())
        (part, coords) = list(solver([c]))[0]
        self.assertEqual(coords.origin, cadquery.Vector())
        self.assertEqual(coords.xDir, cadquery.Vector(1, -0.1, 0).normalized())
        self.assertEqual(coords.zDir, cadquery.Vector(0, 0, 1))
コード例 #25
0
 def mate_motor(self):
     return Mate(
         self,
         CoordSystem(origin=(self.motor_offset, 0, 0),
                     xDir=(0, 0, 1),
                     normal=(-1, 0, 0)),
     )
コード例 #26
0
ファイル: servo_horns.py プロジェクト: zignig/cqparts_bucket
 def mate_top(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.thickness),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
コード例 #27
0
 def mate_left(self):
     return Mate(
         self,
         CoordSystem(origin=(0, self.seperation / 2, 0),
                     xDir=(1, 0, 0),
                     normal=(0, -1, 0)),
     )
コード例 #28
0
 def mate_end(self):
     # center of +x face
     return Mate(self, CoordSystem(
         origin=(self.length / 2, 0, 0),
         xDir=(0, 0, -1),
         normal=(-1, 0, 0),
     ))
コード例 #29
0
ファイル: block_tree.py プロジェクト: zignig/cqparts
 def mate_top(self):
     # Mate point at the top of the cylinder, twist applied
     return Mate(
         self,
         CoordSystem.from_plane(
             self.local_obj.faces(">Z").workplane().plane.rotated(
                 (0, 0, self.twist))))
コード例 #30
0
 def mate_bottom(self):
     " bottom of the stator"
     return Mate(
         self,
         CoordSystem(origin=(0, 0, -self.length / 2),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1)))