def build(ang_1=0., ang_2=0.): r"""Build the robotic arm Parameters ---------- ang_1 : float Rotation of base plate on base ang_2 : float Angle of arm to base plate """ assembly = Assembly(root_part=b, name="main") at, jo = assembly.add_part( part_to_add=bp, part_to_add_anchors=["Plate_axis"], receiving_parts=[b], receiving_parts_anchors=["A1"], links=[Joint(anchor=b.transformed_anchors['A1'], rx=ang_1)]) at1, jo1 = assembly.add_part( part_to_add=a1, part_to_add_anchors=["E1"], receiving_parts=[bp], receiving_parts_anchors=["Arm_axis"], links=[Joint(anchor=bp.transformed_anchors['Arm_axis'], ry=ang_2)]) return assembly
def make_wheel_assembly(): r"""Wheel assembly creation""" rim_path = r_("shelf/wheel/CAR-WHEEL-RIM-D416_l174_mm---.stepzip") rim = anchorable_part_from_stepzip(stepzip_filepath=rim_path) tyre_path = r_("shelf/wheel/CAR-WHEEL-TYRE-D575_l178_mm-RUBBER--.stepzip") tyre = anchorable_part_from_stepzip(stepzip_filepath=tyre_path) wheel_assembly = Assembly(root_part=rim, name="wheel_assembly") wheel_assembly.add_part( part_to_add=tyre, part_to_add_anchors=['AXIS_SIDE_d383#mm_'], receiving_parts=[rim], receiving_parts_anchors=['AXIS_TYRE_d412#mm_'], links=[Joint(anchor=rim.transformed_anchors['AXIS_TYRE_d412#mm_'])]) return wheel_assembly
shape=BRepPrimAPI_MakeBox(10, 10, 10).Shape(), anchors=[Anchor(p=(5, 5, 10), u=(0, 0, 1), v=(0, 1, 0), name='t1')], name='ap1') m = gp_Trsf() m.SetTranslation(gp_Vec(100, 0, 0)) trf = BRepBuilderAPI_Transform(m) s2 = BRepPrimAPI_MakeBox(20, 20, 20).Shape() trf.Perform(s2, False) ap2 = AnchorablePart( shape=trf.Shape(), anchors=[Anchor(p=(110, 10, 20), u=(0, 0, 1), v=(0, 1, 0), name='t2')], name='ap2') a = Assembly(root_part=ap1, name='simple assembly') a.add_part(part_to_add=ap2, part_to_add_anchors=['t2'], receiving_parts=[ap1], receiving_parts_anchors=['t1'], links=[Joint(anchor=ap1.transformed_anchors['t1'], rx=1)]) __assembly__ = a if __name__ == "__main__": from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_anchorable_part, display_assembly display, start_display, add_menu, add_function_to_menu = init_display()
name='top'), Anchor(p=(5, 5, 0), u=(0, 0, -1), v=(0, 1, 0), name='bottom') ], name='ap1') ap2 = ap1.copy(new_name='ap2') ap3 = ap1.copy(new_name='ap3') ap4 = ap1.copy(new_name='ap4') # ap5 = ap1.copy(new_name='ap5') # ap6 = ap1.copy(new_name='ap6') # We create an assembly of 2 anchorable parts a = Assembly(root_part=ap1, name='a') a.add_part(part_to_add=ap2, part_to_add_anchors=['bottom'], receiving_parts=[ap1], receiving_parts_anchors=['top'], links=[Joint(anchor=ap1.anchors['top'])]) # We create another assembly of 2 anchorable parts b = Assembly(root_part=ap3, name='b') b.add_part( part_to_add=ap4, part_to_add_anchors=['bottom'], receiving_parts=[ap3], receiving_parts_anchors=['top'], links=[ Joint(
name='top'), Anchor(p=(5, 5, 0), u=(0, 0, -1), v=(0, 1, 0), name='bottom') ], name='ap1') ap2 = ap1.copy(new_name='ap2') ap3 = ap1.copy(new_name='ap3') ap4 = ap1.copy(new_name='ap4') ap5 = ap1.copy(new_name='ap5') ap6 = ap1.copy(new_name='ap6') # We create an assembly of 2 anchorable parts a = Assembly(root_part=ap1, name='a') a.add_part(part_to_add=ap2, part_to_add_anchors=['top'], receiving_parts=[ap1], receiving_parts_anchors=['top'], links=[Joint(anchor=ap1.anchors['top'])]) # We create another assembly of 2 anchorable parts b = Assembly(root_part=ap3, name='b') b.add_part( part_to_add=ap4, part_to_add_anchors=['top'], receiving_parts=[ap3], receiving_parts_anchors=['top'], links=[ Joint(
ap4 = AnchorablePart(shape=shape_1, anchors=[ Anchor(p=(5, 5, 10), u=(0, 0, 1), v=(0, 1, 0), name='top4'), Anchor(p=(5, 5, 0), u=(0, 0, -1), v=(0, 1, 0), name='bottom4') ], name='ap4') # We create an assembly of 2 anchorable parts a = Assembly(root_part=ap1, name='a') a.add_part(part_to_add=ap2, part_to_add_anchors=['top2'], receiving_parts=[ap1], receiving_parts_anchors=['top1'], links=[Joint(anchor=ap1.anchors['top1'], tx=0, rx=0, ry=0, rz=0)]) # print("assembly a has %i parts and %i anchors" % # (len(a._parts), len(a.anchors))) # We create another assembly of 2 anchorable parts b = Assembly(root_part=ap3, name='b') b.add_part( part_to_add=ap4, part_to_add_anchors=['top4'], receiving_parts=[ap3], receiving_parts_anchors=['top3'],
def make_chassis_assembly(): r"""Chassis assembly creation""" p1_base = anchorable_part_from_stepzip( r_("shelf/chassis/CAR-CHASSIS-BASE-2.38_0.179_1.18-STEEL--.stepzip")) p2_l = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-ARCHLEFT-705_515_184_mm-STEEL--.stepzip")) p2_r = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-ARCHRIGHT-705_515_184_mm-STEEL--.stepzip")) p4 = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-ARCHSTRUT-127_126_796_mm-STEEL--.stepzip")) p5 = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-SEATSSUPPORT-410_151_1174_mm-STEEL--.stepzip")) p6 = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-DASHBOARDSUPPORT-107_535_1184_mm-STEEL--.stepzip")) p7_l = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-SUSPENSION-ARCHLEFT-526_535_284_mm-STEEL--.stepzip")) p7_r = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-SUSPENSION-ARCHRIGHT-526_535_284_mm-STEEL--.stepzip")) p8 = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-ARCHSTRUT-111_130_746_mm-STEEL--.stepzip")) p9 = anchorable_part_from_stepzip( r_("shelf/chassis/" "CAR-CHASSIS-DASHBOARDSUPPORTREINFORCEMENT-205_525_75_mm-STEEL--.stepzip" )) chassis_assembly = Assembly(root_part=p1_base, name="chassis_assembly") chassis_assembly.add_part( part_to_add=p2_l, part_to_add_anchors=['D3'], receiving_parts=[p1_base], receiving_parts_anchors=['A2-L'], links=[ Joint(anchor=p1_base.transformed_anchors['A2-L'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p2_r, part_to_add_anchors=['D3'], receiving_parts=[p1_base], receiving_parts_anchors=['A2-R'], links=[ Joint(anchor=p1_base.transformed_anchors['A2-R'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p4, part_to_add_anchors=['B4'], receiving_parts=[p2_r], receiving_parts_anchors=['B2'], links=[Joint(anchor=p2_r.transformed_anchors['B2'])]) chassis_assembly.add_part( part_to_add=p5, part_to_add_anchors=['F1'], receiving_parts=[p1_base], receiving_parts_anchors=['F2-R'], links=[ Joint(anchor=p1_base.transformed_anchors['F2-R'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p6, part_to_add_anchors=['A1'], receiving_parts=[p1_base], receiving_parts_anchors=['G3-L'], links=[ Joint(anchor=p1_base.transformed_anchors['G3-L'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p7_l, part_to_add_anchors=['A4'], receiving_parts=[p1_base], receiving_parts_anchors=['K3-L'], links=[ Joint(anchor=p1_base.transformed_anchors['K3-L'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p7_r, part_to_add_anchors=['A4'], receiving_parts=[p1_base], receiving_parts_anchors=['K3-R'], links=[ Joint(anchor=p1_base.transformed_anchors['K3-R'], rx=radians(180)) ]) chassis_assembly.add_part( part_to_add=p8, part_to_add_anchors=['A1'], receiving_parts=[p7_l], receiving_parts_anchors=['B1'], links=[Joint(anchor=p7_l.transformed_anchors['B1'])]) chassis_assembly.add_part(part_to_add=p9, part_to_add_anchors=['A1'], receiving_parts=[p1_base], receiving_parts_anchors=['H2'], links=[ Joint( anchor=p1_base.transformed_anchors['H2'], rx=radians(180)) ]) return chassis_assembly
"libraries/ISO4032_library.json") plate_gn = anchorable_part_from_py_script(py_script_path=plate_with_holes_script) print("Plate gn : %s" % plate_gn) screws = [anchorable_part_from_library( library_file_path=iso_4014_library_filepath, part_id="ISO4014_M2_grade_Bx21") for _ in range(4)] nuts = [anchorable_part_from_library( library_file_path=iso_4032_library_filepath, part_id="ISO4032_Nut_M2.0") for _ in range(4)] __assembly__ = Assembly(root_part=plate_gn, name="Plate and bolts") for i, screw in enumerate(screws, 1): __assembly__.add_part(part_to_add=screw, part_to_add_anchors=['head_bottom'], receiving_parts=[plate_gn], receiving_parts_anchors=[str(i)], links=[Joint(anchor=screw.transformed_anchors['head_bottom'])]) for i, (screw, nut) in enumerate(zip(screws, nuts), 1): __assembly__.add_part(part_to_add=nut, part_to_add_anchors=['nut_top'], receiving_parts=[screw], receiving_parts_anchors=['head_bottom'],
anchors=[ Anchor(p=(5, 5, 10), u=(0, 0, 1), v=(0, 1, 0), name='top1'), Anchor(p=(5, 5, 0), u=(0, 0, -1), v=(0, 1, 0), name='bottom1') ], name='ap1') ap2 = ap1.copy(new_name="ap2") # We create an assembly of 2 anchorable parts a = Assembly(root_part=ap1, name='a') a.add_part(part_to_add=ap2, part_to_add_anchors=['bottom1'], receiving_parts=[ap1], receiving_parts_anchors=['top1'], links=[Joint(anchor=ap1.anchors['top1'], rx=radians(10))]) # We create another assembly of 2 anchorable parts b = a.copy(new_name='b') __assemblies__ = [a, b] if __name__ == "__main__": display, start_display, add_menu, add_function_to_menu = init_display() # Choose to show the assemblies before one is added to the other (True),
AnchorablePart(shape=trf.Shape(), anchors=[ Anchor(p=(5 + randx, 5 + randy, 10 + randz), u=(0, 0, 1), v=(0, 1, 0), name='top'), Anchor(p=(5 + randx, 5 + randy, 0 + randz), u=(0, 0, -1), v=(0, 1, 0), name='bottom') ], name='ap')) new_cubes = deepcopy(cubes) a = Assembly(root_part=new_cubes[0], name='cubes pile') for i, ap in enumerate(new_cubes[1:]): a.add_part(part_to_add=ap, part_to_add_anchors=['bottom'], receiving_parts=[new_cubes[i]], receiving_parts_anchors=['top'], links=[Joint(anchor=ap.transformed_anchors['bottom'], tx=-5)]) if __name__ == "__main__": from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_anchorable_part display, start_display, add_menu, add_function_to_menu = init_display() for ap in cubes:
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with cadracks-core. If not, see <https://www.gnu.org/licenses/>. r"""Minimalistic assembly example""" from cadracks_core.factories import anchorable_part_from_py_script from cadracks_core.model import Assembly from cadracks_core.joints import CylindricalJoint from os.path import join, dirname minimal_filepath = join(dirname(__file__), "minimal.py") p1 = anchorable_part_from_py_script(minimal_filepath) p2 = p1.copy(new_name="p2") j = CylindricalJoint(anchor=p1.anchors['top'], ty=10, tz=10) a = Assembly(root_part=p1, name='a') a.add_part(part_to_add=p2, part_to_add_anchors=['top'], receiving_parts=[p1], receiving_parts_anchors=['top'], links=[j]) j.set_joint(tx=10, rx=0) __assembly__ = a
py_script_path=plate_with_holes_script) print("Plate gn : %s" % plate_gn) screws = [ anchorable_part_from_library(library_file_path=iso_4014_library_filepath, part_id="ISO4014_M2_grade_Bx21") for _ in range(4) ] nuts = [ anchorable_part_from_library(library_file_path=iso_4032_library_filepath, part_id="ISO4032_Nut_M2.0") for _ in range(4) ] A = Assembly(root_part=plate_gn, name="Global assembly") bolts = [] for i in range(4): bolt = Assembly(root_part=screws[i], name="Bolt_%i" % i) bolt.add_part(part_to_add=nuts[i], part_to_add_anchors=['nut_top'], receiving_parts=[screws[i]], receiving_parts_anchors=['head_bottom'], links=[ Joint(anchor=nuts[i].transformed_anchors['nut_top'], tx=5 + 1.6) ]) bolts.append(bolt)
def make_front_suspension_assembly(): r"""Front suspension assembly creation""" p1_0 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-BEARING-l54.7_d37_mm---.stepzip")) p1_1 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-BEARING-l54.7_d37_mm---.stepzip")) p2 = anchorable_part_from_stepzip( r_("shelf/suspension/front/" "CAR-SUSPENSION-FORK-320_44_270_mm---.stepzip")) p3 = anchorable_part_from_stepzip( r_("shelf/suspension/front/" "CAR-SUSPENSION-LINK-28_23_124_mm---.stepzip")) p4 = anchorable_part_from_stepzip( r_("shelf/suspension/front/" "CAR-DIRECTION-BALLHEAD-D23_d10_l70_mm---.stepzip")) p5 = anchorable_part_from_stepzip( r_("shelf/suspension/front/" "CAR-SUSPENSION-HUB-107_212_84_mm---.stepzip")) p6 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-DISCSUPPORT-117_117_70_mm---.stepzip")) p7 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-AXLE-DISC-d227_h46_mm-STEEL--.stepzip")) p8 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-CYLINDER-l320_d42---.stepzip")) p9 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-PISTON-l381_d33_d16-STEEL--.stepzip")) p10 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-HAT-102_40_70_mm---.stepzip")) p11 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-HEAD-60_48_67_mm---.stepzip")) p12 = anchorable_part_from_stepzip( r_("shelf/suspension/common/" "CAR-SUSPENSION-NECK-d28_l51_mm---.stepzip")) front_suspension_assembly = Assembly(root_part=p2, name="front_suspension_assembly") front_suspension_assembly.add_part( part_to_add=p1_0, part_to_add_anchors=['wide_out'], receiving_parts=[p2], receiving_parts_anchors=['out1'], links=[Joint(anchor=p2.transformed_anchors['out1'])]) front_suspension_assembly.add_part( part_to_add=p1_1, part_to_add_anchors=['wide_out'], receiving_parts=[p2], receiving_parts_anchors=['out2'], links=[Joint(anchor=p2.transformed_anchors['out2'])]) front_suspension_assembly.add_part( part_to_add=p3, part_to_add_anchors=['main'], receiving_parts=[p2], receiving_parts_anchors=['in_inside'], links=[Joint(anchor=p2.transformed_anchors['in_inside'], tx=-71.396)]) front_suspension_assembly.add_part( part_to_add=p4, part_to_add_anchors=['cone'], receiving_parts=[p3], receiving_parts_anchors=['perp'], links=[Joint(anchor=p3.transformed_anchors['perp'], tx=6.2)]) front_suspension_assembly.add_part( part_to_add=p5, part_to_add_anchors=['ball'], receiving_parts=[p4], receiving_parts_anchors=['ball'], links=[Joint(anchor=p4.transformed_anchors['ball'])]) front_suspension_assembly.add_part( part_to_add=p8, part_to_add_anchors=['side2_top'], receiving_parts=[p5], receiving_parts_anchors=['side1_top'], links=[ Joint(anchor=p5.transformed_anchors['side1_top'], rx=radians(180 - 14.556)) ]) front_suspension_assembly.add_part( part_to_add=p9, part_to_add_anchors=['bottom'], receiving_parts=[p8], receiving_parts_anchors=['top'], links=[Joint(anchor=p8.transformed_anchors['top'], tx=-216.148)]) front_suspension_assembly.add_part( part_to_add=p12, part_to_add_anchors=['bottom'], receiving_parts=[p9], receiving_parts_anchors=['top'], links=[Joint(anchor=p9.transformed_anchors['top'], tx=1.24)]) front_suspension_assembly.add_part( part_to_add=p11, part_to_add_anchors=['bottom'], receiving_parts=[p12], receiving_parts_anchors=['bottom'], links=[Joint(anchor=p12.transformed_anchors['bottom'])]) front_suspension_assembly.add_part( part_to_add=p10, part_to_add_anchors=['axis_bottom'], receiving_parts=[p11], receiving_parts_anchors=['wide_flat'], links=[Joint(anchor=p11.transformed_anchors['wide_flat'])]) front_suspension_assembly.add_part( part_to_add=p6, part_to_add_anchors=['axis_drive'], receiving_parts=[p5], receiving_parts_anchors=['wheel_axis'], links=[Joint(anchor=p5.transformed_anchors['wheel_axis'])]) front_suspension_assembly.add_part( part_to_add=p7, part_to_add_anchors=['inside'], receiving_parts=[p6], receiving_parts_anchors=['axis_disc'], links=[Joint(anchor=p6.transformed_anchors['axis_disc'])]) return front_suspension_assembly