receiving_parts=[ap2], receiving_parts_anchors=['b2'], links=[Joint(anchor=ap2.transformed_anchors['b2'])]) a.add_part(part_to_add=ap4, part_to_add_anchors=['t4'], receiving_parts=[ap3], receiving_parts_anchors=['b3'], links=[Joint(anchor=ap3.transformed_anchors['b3'], tx=3)]) __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() display_parts = False if display_parts is True: display_anchorable_part(display, ap1, color="YELLOW") display_anchorable_part(display, ap2, color="BLUE") display_anchorable_part(display, ap3, color="RED") display_anchorable_part(display, ap4, color="GREEN") else: display_assembly(display, __assembly__) display.FitAll() start_display()
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() display_parts = False if display_parts is True: display_anchorable_part(display, ap1, color="RED") display_anchorable_part(display, ap2, color="BLUE") else: display_assembly(display, __assembly__) display.FitAll() start_display()
# # cadracks-core is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # 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"""Create a part defined in a JSON that references a Python creation script""" from os.path import join, dirname from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_anchorable_part from cadracks_core.factories import part_from_json if __name__ == "__main__": ap = part_from_json(join(dirname(__file__), "spacer_20x8x4.json")) display, start_display, add_menu, add_function_to_menu = init_display() display_anchorable_part(display, ap, color="BLUE", transparency=0.5, update=True) start_display()
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 if __name__ == "__main__": display, start_display, add_menu, add_function_to_menu = init_display() display.SetRaytracingMode() colors = ["BLUE", "CYAN", "ORANGE"] for i in range(10): ang_1 = 0.1 * i ang_2 = -0.1 * i a = build(ang_1, ang_2) # display.EraseAll() for j, p in enumerate(a._parts): display_anchorable_part(display, p, color=colors[j % len(colors)], update=False) display.Repaint() if i == 0: display.FitAll() start_display()
__shape__ = plate.shape __anchors__ = dict() for i, (x, y) in enumerate(hole_positions, 1): __anchors__[str(i)] = { "p": (x, y, e), "u": (0., 0., -1.), "v": (1., 0., 0.), "dimension": hole_d, "description": "%s mm hole" % hole_d } __properties__ = {} if __name__ == "__main__": from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_anchorable_part from cadracks_core.model import AnchorablePart from cadracks_core.factories import anchors_dict_to_list display, start_display, add_menu, add_function_to_menu = init_display() ap = AnchorablePart(shape=__shape__, name="plate_with_holes", anchors=anchors_dict_to_list(__anchors__)) display_anchorable_part(display, ap, color="BLUE") display.FitAll() start_display()
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'], links=[Joint(anchor=nut.transformed_anchors['nut_top'], tx=-5-1.6)]) if __name__ == "__main__": from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_assembly, display_anchorable_part display, start_display, add_menu, add_function_to_menu = init_display() same_colors = False if same_colors is True: display_assembly(display, __assembly__, color="BLUE") else: display_anchorable_part(display, plate_gn, color="BLUE", transparency=0) for screw in screws: display_anchorable_part(display, screw, color="RED", transparency=0) for nut in nuts: display_anchorable_part(display, nut, color="YELLOW", transparency=0) display.FitAll() start_display()
bolts.append(bolt) A.add_assembly( assembly_to_add=bolt, assembly_to_add_anchors=[ 'ISO4014_library-ISO4014_M2_grade_Bx21.head_bottom' ], receiving_assemblies=[A], receiving_assemblies_anchors=["plate_with_holes.%s" % str(i + 1)], links=[ Joint(anchor=bolt. anchors['ISO4014_library-ISO4014_M2_grade_Bx21.head_bottom']) ]) __assemblies__ = [A] for bolt in bolts: __assemblies__.append(bolt) if __name__ == "__main__": from OCC.Display.SimpleGui import init_display from cadracks_core.display import display_assembly, display_anchorable_part display, start_display, add_menu, add_function_to_menu = init_display() display_anchorable_part(display, plate_gn, color="BLUE", transparency=0) for bolt in bolts: display_assembly(display, bolt, color="RED", transparency=0) display.FitAll() start_display()