def add_connection(self, reversed_angle=False): faces_list = selection.get_freecad_faces_objects_list() if len(faces_list) == 0 or len(faces_list) % 2 == 1: raise ValueError( "Please select at least two faces (multiple of two)") for index in range(0, len(faces_list) - 1, 2): current_last_object = self.get_last_object() if faces_list[index]["freecad_object"].Name == current_last_object: face_1 = faces_list[index] face_2 = faces_list[index + 1] else: raise ValueError( "Please select a face belonging to the last part") hinge = HingesProperties(freecad_face_1=face_1['face'], freecad_face_1_name=face_1['name'], freecad_object_1=face_1['freecad_object'], freecad_face_2=face_2['face'], freecad_face_2_name=face_2['name'], freecad_object_2=face_2['freecad_object'], reversed_angle=reversed_angle) link_clearance = self.global_properties_widget.get_properties( ).link_clearance if link_clearance != 0.: hinge.compute_min_link(link_clearance) widget = LivingHingeWidget(hinge) self.hinges.append(hinge) self.connection_widget_list.append(widget) self.draw_connections() return
def add_tabs(self): self.check_is_in_active_view() faces = selection.get_freecad_faces_objects_list() last_index = None if self.check_faces(faces) is False: return for face in faces: try: item = self.tabsList.append(face['face'], face['freecad_object'], face['name'], self.tab_type_box.currentText()) last_index = self.model.append_tab(face['freecad_object'].Name, item.name, item.real_name) except ValueError as e: FreeCAD.Console.PrintMessage(e) return self.force_selection(last_index) return
def add_tabs(self): self.check_is_in_active_view() faces = selection.get_freecad_faces_objects_list() last_index = None if self.check_faces(faces) is False: return for face in faces: try: item = self.tabsList.append(face['face'], face['freecad_object'], face['name'], self.tab_type_box.currentText()) last_index = self.model.append_tab(face['freecad_object'].Name, item.name, item.real_name) except ValueError as e: FreeCAD.Console.PrintError(e) return self.force_selection(last_index) return
def add_same_tabs(self): self.check_is_in_active_view() faces = selection.get_freecad_faces_objects_list() index = None if self.check_faces(faces) is False or len(faces) == 0: return try: face = faces[0] item = self.tabsList.append(face, self.tab_type_box.currentText()) index = self.model.append_tab(item.freecad_obj_name, item.tab_name, item.face_name) for face in faces[1:]: sub_item = self.tabsList.append_link(face, item.tab_name) self.model.append_tab(sub_item.freecad_obj_name, sub_item.tab_name, sub_item.face_name, True) except ValueError as e: FreeCAD.Console.PrintError(e) return self.force_selection(index) return
def add_same_tabs(self): self.check_is_in_active_view() faces = selection.get_freecad_faces_objects_list() index = None if self.check_faces(faces) is False or len(faces) == 0: return try: face = faces[0] item = self.tabsList.append(face['face'], face['freecad_object'], face['name'], self.tab_type_box.currentText()) index = self.model.append_tab(face['freecad_object'].Name, item.name, item.real_name) for face in faces[1:]: item = self.tabsList.append_link(face['face'], face['freecad_object'], face['name'], "%s.%s" % (faces[0]['freecad_object'].Name, faces[0]['name'])) self.model.append_tab(face['freecad_object'].Name, item.name, item.real_name, True) except ValueError as e: FreeCAD.Console.PrintMessage(e) return self.force_selection(index) return
def IsActive(self): nb_connection = len(selection.get_freecad_faces_objects_list()) return nb_connection > 1 and nb_connection % 2 == 0