def make_constraints(self): constr = [ Fixed(self.components["shaft"].mate_origin, CoordSystem(origin=(0, 0, 0))), Fixed(self.components["roller"].mate_end()), ] return constr
def make_constraints(self): return [ Fixed( self.components["holder"].mate_origin, CoordSystem((0, 0, 0), (1, 0, 0), (0, 0, 1)), ), Coincident( self.components["bolt"].mate_along( 0), # self.components["holder"].mate_origin, # Put nut at end self.components["holder"].mate_bolt, ), # Fixed( # Test bolt # self.components["bolt"].mate_origin, # CoordSystem((20, 30, 0), (0, 0, 1), (1, 0, 0)).rotated((0, 0, 0)), # ), Coincident( # Move motor self.components["motor"].mate_origin, self.components["holder"].mate_motor, ), Coincident( self.components["gear"].mate_shaft, self.components["motor"].mate_gear ), Fixed( # Move riser self.components["riser_holder"].mate_origin, CoordSystem((7.5+14.7/2.0, -18.4, 0), (-1, 0, 0), (0, 0, 1)).rotated((0, 0, 180)), ), Coincident( # mount self.components["riser"].mate_holder_demo, self.components["riser_holder"].mate_origin, ), Fixed( self.components["switch"].mate_origin, CoordSystem((0, -7, 3), xDir=(0, 0, 1), normal=(-1, 0, 0)).rotated((90, 0, 0)), ) ]
def make_constraints(self): constraints = [ Fixed( self.components["glass_top"].mate_origin, CoordSystem((0, 0, self.height), (1, 0, 0), (0, 0, 1)), ), Fixed( self.components["shelf_0"].mate_origin, CoordSystem((0, 0, self.height_1), (1, 0, 0), (0, 0, 1)), ), Fixed( self.components["shelf_1"].mate_origin, CoordSystem((0, 0, self.height_2), (1, 0, 0), (0, 0, 1)), ), Coincident( self.components["leg_0"].mate_origin, self.components["glass_top"].mate_leg_0, ), Coincident( self.components["leg_1"].mate_origin, self.components["glass_top"].mate_leg_1, ), Coincident( self.components["leg_2"].mate_origin, self.components["glass_top"].mate_leg_2, ), Coincident( self.components["leg_3"].mate_origin, self.components["glass_top"].mate_leg_3, ), ] return constraints
def make_constraints(self): constr = [ Fixed(self.components["rail1"].mate_origin), Coincident(self.components["rail2"].mate_end, self.components["rail1"].mate_start), ] if self.train is not None: constr.append(Fixed(self.components["rail1"].mate_origin)) return constr
def make_constraints(self): constr = [ Fixed(self.components["p"].mate_origin), Fixed( self.components["p2"].mate_origin, CoordSystem((0, -self.spacing, 0), (1, 0, 0), (0, 0, 1)), ), Fixed(self.components["belt"].mate_origin), ] return constr
def make_constraints(self): base2 = self.components["base2"] base3 = self.components["base3"] constraints = [ Fixed(self.components["base"].mate_origin, CoordSystem( (0, 107, 0))), Fixed(base2.mate_origin, CoordSystem( (0, 147, 0))), # Embed nuts in top and make sure cutout Fixed(base3.mate_origin, CoordSystem( (0, 180, 0))), # Embed nuts in top and make sure cutout # works ] for i, size in enumerate(self.tests): bolt_b = self.components[self.bolt_on_bottom_name(size)] constraints += [ Fixed( # Space out nuts self.components[self.nut_name(size)].mate_origin, CoordSystem((i * 20, 0, 0)), ), Fixed( self.components[self.thread_name(size)].mate_origin, CoordSystem((i * 20, 15, 0)), ), Fixed( self.components[self.min_bolt_name(size)].mate_origin, CoordSystem((i * 20, 40, 0)), ), Fixed( self.components[self.bolt_name(size)].mate_origin, CoordSystem((i * 20, 65, 0)), ), Fixed( self.components[self.embedded_bolt_name(size)].mate_origin, CoordSystem((i * 20, 95, 0)), ), Fixed( self.components[self.insert_bolt_name(size)].mate_origin, CoordSystem((i * 20, 120, 10)), ), Fixed( self.components[self.tool_name(size)].mate_origin, CoordSystem((i * 20, -10, 0)), ), Coincident( self.components[self.nut_on_top_name(size)].mate_nutend, base2.mate_nut_top(i), ), Coincident( bolt_b.mate_head_end(rotation=(180, 0, 0)), base3.mate_nut_bottom(i), ), ] return constraints
def make_constraints(self): bp = self.components["battpack"] co = self.components["controller"] mc = self.components["motorcontroller"] off1 = bp.length / 2 off2 = off1 + bp.length / 2 + co.width / 2 + self.gap off3 = off2 + co.width / 2 + self.gap + mc.width / 2 constr = [ Fixed(bp.mate_flat(), self.off(off1)), Fixed(co.mate_transverse(), self.off(off2)), Fixed(mc.mate_transverse(), self.off(off3)), ] return constr
def make_constraints(self): const = [] disc = self.components["disc"] boss = self.components["boss"] motor = self.components["motor"] const.append(Fixed(disc.mate_top())) const.append(Coincident(boss.mate_origin, disc.mate_origin)) # const.append(Coincident(motor.mate_origin, boss.mate_origin)) const.append( Fixed(motor.mate_origin, CoordSystem(origin=(0, 0, -self.sl)))) # const.append(Fixed(boss.mate_origin)) if self.mount is not None: const.append(Coincident(self.mount.mate_origin, motor.mate_origin)) return const
def make_constraints(self): self._flags.append('con') (p1, p2) = (self.components['p1'], self.components['p2']) return [ Fixed(p1.mate_origin), Coincident(p2.mate_bottom, p1.mate_top), ]
def make_constraints(self): return [ Fixed(self.components["plank"].mate_bottom), Coincident( self.components["button"].mate_origin, self.components["plank"].mate_top ), ]
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))
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))
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
def make_constraints(self): return [ # trunk Fixed( self.components['trunk'].mate_origin, # lock this CoordSystem((0, 0, 0), (1, 0, 0), (0, 0, 1)), # here ), Coincident( self.components['trunk_split'].mate_origin, # lock this self.components['trunk'].mate_top, # here ), # branch L Coincident( self.components['branch_lb'].mate_origin, self.components['trunk_split'].mate_left, ), Coincident( self.components['branch_ls'].mate_origin, self.components['branch_lb'].mate_top, ), # branch RL Coincident( self.components['branch_r'].mate_origin, self.components['trunk_split'].mate_right, ), ]
def make_constraints(self): constr = [ Fixed(self.components["box"].mate_origin), Coincident(self.components["cyl"].mate_origin, self.components["box"].mate_top), ] return constr
def make_constraints(self): constr = [ Fixed(self.components["base"].mate_origin, CoordSystem(origin=(0, 0, 60))), Coincident( self.components["electronics"].mate_origin, self.components["base"].mate_back(), ), Coincident( self.components["sensors"].mate_front(), self.components["base"].mate_front(), ), Coincident( self.components["Ldrive_b"].mate_corner(flip=-1), self.components["base"].mate_RL(), ), Coincident( self.components["Rdrive_b"].mate_corner(flip=1), self.components["base"].mate_RR(), ), Coincident( self.components["Ldrive_f"].mate_corner(flip=1), self.components["base"].mate_RL(offset=self.length - self.chamfer), ), Coincident( self.components["Rdrive_f"].mate_corner(flip=-1), self.components["base"].mate_RR(offset=self.length - self.chamfer), ), ] return constr
def make_constraints(self): constraints = [ Fixed(self.components["base"].mate_origin, CoordSystem()), Fixed(self.components["switch1"].mate_origin, CoordSystem((0, -30, 0))), Fixed( self.components["switch2"].mate_origin, CoordSystem((0, 15, 0), xDir=(0, 0, 1), normal=(-1, 0, 0)).rotated((90, 0, 0)), ) # Fixed( # Space out nuts # self.components["switch2"].mate_origin, # CoordSystem((0, 0, 0), xDir=(0, 1, 0), normal=(1, 0, 0)), # ), ] return constraints
def make_constraints(self): cube_a = self.components['cube_a'] cube_b = self.components['cube_b'] return [ Fixed(cube_a.mate_bottom), Coincident(cube_b.mate_bottom, cube_a.mate_top), ]
def make_constraints(self): constr = [Fixed(self.components["hub"].mate_origin)] for i, j in enumerate(self.components["hub"].roller_mounts()): name = self.components[MercanumWheel.item_name(i)] m = Coincident(name.mate_origin, j) constr.append(m) return constr
def make_constraints(self): return [ Fixed(self.components['axle'].mate_origin, CoordSystem()), Coincident(self.components['left_wheel'].mate_origin, self.components['axle'].mate_left), Coincident(self.components['right_wheel'].mate_origin, self.components['axle'].mate_right), ]
def make_constraints(self): return [ Fixed(self.components["plank"].mate_top), Coincident( self.components["servo"].mate_wing_bottom(), self.components["plank"].mate_top, ), ]
def make_constraints(self): constr = [Fixed(self.components[Train.car_name(0)].mate_origin)] self.cars.reverse() for i in range(1, len(self.cars)): last_car = self.components[Train.car_name(i - 1)].mate_end(-1) this_car = self.components[Train.car_name(i)].mate_end(1) constr.append(Coincident(this_car, last_car)) return constr
def make_constraints(self): constr = [ Fixed( self.components["drive"].mate_origin, CoordSystem((0, 0, 0), (0, 1, 0), (1, 0, 0)), ) ] return constr
def make_constraints(self): return [ Fixed(self.components['screw'].mate_origin), Coincident( self.components['anchor'].mate_screwhead, self.components['screw'].mate_origin, ), ]
def test_basic(self): mate = Mate(Box()) cs = CoordSystem() c = Fixed(mate, cs) # assert composition self.assertEqual(id(mate), id(c.mate)) self.assertEqual(cs, c.world_coords)
def make_constraints(self): return [ Fixed(self.components['base'].mate_origin, CoordSystem()), Coincident(self.components['front_bar'].mate_origin, self.components['base'].mate_left), Coincident(self.components['back_bar'].mate_origin, self.components['base'].mate_right), ]
def make_constraints(self): return [ Fixed(self.components["riser_holder"].mate_origin, CoordSystem()), Coincident( # mount self.components["riser"].mate_holder_demo, self.components["riser_holder"].mate_origin, ), ]
def make_constraints(self): self._flags.append('con1') p1 = self.components['p1'] yield [Fixed(p1.mate_origin)] self._flags.append('con2') p2 = self.components['p2'] yield [Coincident(p2.mate_bottom, p1.mate_top)] self._flags.append('con3')
def make_constraints(self): base = self.components['base'] top = self.components['top'] fastener = self.components['fastener'] return [ Fixed(base.mate_bottom), Coincident(top.mate_bottom, base.mate_top), Coincident(fastener.mate_origin, top.mate_top), ]
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)