def split(self): # Middle control. middle_control_a = self.create_point(self.builder, "_".join([self.name, "MID_A"])) middle_control_b = self.create_point(self.builder, "_".join([self.name, "MID_B"])) # Snap the middle locations to the middle of power line. world_pos = copy(self.matrix_world) world_loc = world_pos.decompose()[0] mid_a_pos = mathutils.Vector([ world_pos[0][2] * 0.4, world_pos[1][2] * 0.4, world_pos[2][2] * 0.4 ]) middle_a_location = world_loc + mid_a_pos middle_control_a.location = middle_a_location mid_b_pos = mathutils.Vector([ world_pos[0][2] * 0.6, world_pos[1][2] * 0.6, world_pos[2][2] * 0.6 ]) middle_b_location = world_loc + mid_b_pos middle_control_b.location = middle_b_location # Create new powerline. new_powerline = self.builder.add_part(self.object_id, build_rigs=False) # Create additional controls. prev_start_control_name = self.object["start_control"] prev_end_control_name = self.object["end_control"] prev_start_control = blend_utils.get_item_by_name( prev_start_control_name) prev_end_control = blend_utils.get_item_by_name(prev_end_control_name) # Remove constraints of the original power line. self.remove_constraints() # Assign new controls to the power lines. self.build_rig(prev_start_control, middle_control_a) new_powerline.build_rig(middle_control_b, prev_end_control) # Select the middle controller. blend_utils.select([middle_control_a, middle_control_b])
def divide(self): # Middle control. middle_control = self.create_point(self.builder, "_".join([self.name, "MID"])) # Snap the middle location to the middle of power line. world_pos = copy(self.matrix_world) world_loc = world_pos.decompose()[0] at_vec = mathutils.Vector( [world_pos[0][2] / 2, world_pos[1][2] / 2, world_pos[2][2] / 2]) middle_location = world_loc + at_vec middle_control.location = middle_location # Create new powerline. new_powerline = self.builder.add_part(self.object_id, build_rigs=False) # Create additional controls. prev_start_control_name = self.object["start_control"] prev_end_control_name = self.object["end_control"] prev_start_control = blend_utils.get_item_by_name( prev_start_control_name) prev_end_control = blend_utils.get_item_by_name(prev_end_control_name) # Remove constraints of the original power line. self.remove_constraints() # Assign new controls to the power lines. self.build_rig(prev_start_control, middle_control) new_powerline.build_rig(middle_control, prev_end_control) # Select the middle controller. blend_utils.select(middle_control)
def select(self, value=True, add=False): blend_utils.select(self.object)
def select(self): blend_utils.select(self.control)