def execute(self, context): A = context.active_object others = context.selected_objects[-2:] others.remove(A) B = others[0] arc_neo = new_arc(angle=360, sides=64, hide=self.hide_arc) copy_location(arc_neo, A) copy_rotation(arc_neo, A) locked_track(arc_neo, 'Z', 'X', B) for i in range(3): arc_neo.scale[i] = self.radius add_abs_bevel(arc_neo, self.bevel_depth) if not self.other_angle: arc_neo.data.bevel_factor_start = 0 arc_neo.data.bevel_factor_end = self.arc_angle / 360 end1 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius, hide=self.hide_endpoints) end1.name = "Arc endpoint" end2 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius, hide=self.hide_endpoints) end2.name = "Arc endpoint" position_on_curve(end1, arc_neo, position=0) position_on_curve(end2, arc_neo, position=self.arc_angle / 360) if self.display_sides: side1 = new_line() add_abs_bevel(side1, self.bevel_depth) side2 = new_line() add_abs_bevel(side2, self.bevel_depth) ray(side1, A, end1) ray(side2, A, end2) else: arc_neo.data.bevel_factor_start = self.arc_angle / 360 arc_neo.data.bevel_factor_end = 1 end1 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius, hide=self.hide_endpoints) end1.name = "Arc endpoint" end2 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius, hide=self.hide_endpoints) end2.name = "Arc endpoint" position_on_curve(end1, arc_neo, position=self.arc_angle / 360) position_on_curve(end2, arc_neo, position=1) if self.display_sides: side1 = new_line() add_abs_bevel(side1, self.bevel_depth) side2 = new_line() add_abs_bevel(side2, self.bevel_depth) ray(side1, A, end1) ray(side2, A, end2) return {'FINISHED'}
def execute(self, context): line = context.active_object A = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) A.name = 'Point' add_driver(obj=A, prop='location', fields='XYZ', expr="0") position_on_curve(A, line, position=self.position_c) copy_rotation(A, line) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects others.remove(A) B = others[0] drive_rot = new_empty(hide=False) drive_rot.name = "Rotation driver (X loc)" drive_rot.location[0] = self.angle_rot e_rot = new_empty(hide=self.hide_extra) e_rot.name = "e_rotttttttttttttttttttttttt" e_loc = new_empty(hide=self.hide_extra) e_loc.name = "e_loc" e_center_X_track = new_empty(hide=self.hide_extra) e_center_X_track.name = "e_center_track" e_center_X_rotated = new_empty(hide=self.hide_extra) e_center_X_rotated.name = "e_center_rotated" e_rot.parent = A ###e_rot.rotation_euler[2] = math.radians(self.angle_rot) add_driver(e_rot, 'rotation_euler', 'Z', vars_def={ 'x': ('transform', drive_rot, 'location', 'X'), }, expr="x") copy_location(e_center_X_track, B) copy_rotation(e_center_X_track, B) locked_track(e_center_X_track, 'Z', 'X', A) e_center_X_rotated.parent = e_center_X_track ###e_center_X_rotated.rotation_euler[2] = math.radians(self.angle_rot) add_driver(e_center_X_rotated, 'rotation_euler', 'Z', vars_def={ 'x': ('transform', drive_rot, 'location', 'X'), }, expr="x") e_loc.parent = e_center_X_rotated add_driver_distance(e_loc, 'location', 'X', A, B) copy_rotation(e_loc, e_rot) dupli_A = duplicate(A) dupli_A.name = "Rotated object" copy_location(dupli_A, e_loc) copy_rotation(dupli_A, e_loc) copy_scale(dupli_A, A) # Option to change bevel if (isinstance(A.data, bpy.types.Curve)): add_abs_bevel(dupli_A, self.bevel_depth) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects[-2:] others.remove(A) B = others[0] e_new = new_empty(hide=True) e_new.location[0] = self.bevel_depth e_new.location[1] = self.cone_length e_new.location[2] = self.cone_radius line = new_line() segment(line, B, A) add_abs_bevel(line, self.bevel_depth) line.name = "Vector" add_driver( obj=line.data, prop='bevel_factor_end', vars_def={ 'd': ('distance', A, B), 'b1': ('transform', B, 'location', '-'), 'a1': ('transform', A, 'location', '-'), 'bev': ('transform', e_new, 'location', 'X'), 'dep': ('transform', e_new, 'location', 'Y'), 'r1': ('transform', e_new, 'location', 'Z'), }, expr="1 - dep/d" ) cone = new_cone(radius1=self.cone_radius, depth=self.cone_length) copy_location(cone, A) copy_rotation(cone, A) locked_track(obj=cone, lock='Z', axis='-X', target=B) A.hide_viewport = self.hide_endpoint return {'FINISHED'}
def execute(self, context): _A, _B = context.selected_objects[-2:] A = objects.new_plane(hide=self.hide_extra) constraints.copy_transforms(A, _A, transforms='LR') B = objects.new_plane(hide=self.hide_extra) constraints.copy_transforms(B, _B, transforms='LR') # A point on the normal of Plane A A_norm = objects.new_empty(hide=self.hide_extra) A_norm.name = "A Norm" objects.uniform_scale(A_norm, 0.1) objects.set_parent(A_norm, A, keep_inverse=False) A_norm.location[2] = 1.0 # Empty located a A, but in the same orientation as B B_rot_at_A = objects.new_empty(hide=self.hide_extra) B_rot_at_A.name = "B_rot_at_A" constraints.copy_location(B_rot_at_A, A) constraints.copy_rotation(B_rot_at_A, B) # (B_norm_at_a - A) gives the normal direction of B B_norm_at_a = objects.new_empty(hide=self.hide_extra) B_norm_at_a.name = "B_norm_at_a" objects.set_parent(B_norm_at_a, B_rot_at_A, keep_inverse=False) B_norm_at_a.location[2] = 1.0 intersection_line = objects.new_line(axis='Z', length=self.length) objects.move_origin_center(intersection_line) objects.add_abs_bevel(intersection_line, self.bevel_depth) geometry.align_to_plane_of(intersection_line, A, A_norm, B_norm_at_a) constraints.project_along_axis(intersection_line, 'Y', B, opposite=True) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects[-3:] others.remove(A) (B_test, arc_old_test) = others if 'Arc' in B_test.data.name: arc_old = B_test B = arc_old_test if 'Arc' in arc_old_test.data.name: arc_old = arc_old_test B = B_test empty1 = new_point(hide=True) empty1.parent = arc_old empty1.location[1] = -1 fl_arc_old = new_point(hide=True) copy_location(fl_arc_old, arc_old) locked_track(fl_arc_old, 'X', 'Y', empty1) arc_neo = new_arc(angle=360, sides=64, hide=self.hide_arc) uniform_scale(arc_neo, self.radius) add_abs_bevel(arc_neo, self.bevel_depth) copy_location(arc_neo, A) if self.other_side: copy_rotation(arc_neo, fl_arc_old) else: copy_rotation(arc_neo, arc_old) locked_track(arc_neo, 'Z', 'X', B) add_driver( obj=arc_neo.data, prop='bevel_factor_start', vars_def={ 'bev': ('datapath', arc_old, 'data.bevel_factor_start'), }, expr='bev' ) add_driver( obj=arc_neo.data, prop='bevel_factor_end', vars_def={ 'bev': ('datapath', arc_old, 'data.bevel_factor_end'), }, expr='bev' ) end1 = new_point(radius=self.sphere_radius, hide=self.hide_endpoints) end1.name = "Arc endpoint" end2 = new_point(radius=self.sphere_radius, hide=self.hide_endpoints) end2.name = "Arc endpoint" position_on_curve(end1, arc_neo, position=0) position_on_curve(end2, arc_neo, position=1) add_driver( obj=end1.constraints[-1], prop='offset_factor', vars_def={ 'bev': ("datapath", arc_neo, "data.bevel_factor_start"), }, expr="bev" ) add_driver( obj=end2.constraints[-1], prop='offset_factor', vars_def={ 'bev': ("datapath", arc_neo, "data.bevel_factor_end"), }, expr="bev" ) if self.display_sides: side1 = new_line() add_abs_bevel(side1, self.bevel_depth) side2 = new_line() add_abs_bevel(side2, self.bevel_depth) ray(side1, A, end1) ray(side2, A, end2) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects[-4:] others.remove(A) (O_test, L_test, R_test) = others if 'Sphere' in O_test.data.name: O = O_test if 'Sphere' in L_test.data.name: O = L_test if 'Sphere' in R_test.data.name: O = R_test others.remove(O) (L_test, R_test) = others if 'Line' in L_test.data.name: L = L_test R = R_test if 'Line' in R_test.data.name: L = R_test R = L_test # A: object to transform, O: origin, L: line, R: circle if not (isinstance(A.data, bpy.types.Curve)): new = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) new.name = "Homothetic object" if 'Line' in A.data.name: new = new_line() new.name = "Homothetic object" add_abs_bevel(new, self.bevel_depth) if 'Circle' in A.data.name: new = new_circle() new.name = "Homothetic object" add_abs_bevel(new, self.bevel_depth) copy_rotation(new, A) add_driver(obj=new, prop='location', fields='XYZ', vars_def={ 's': ('transform', L, 'scale', 'X'), 'r': ('transform', R, 'scale', 'X'), 'b1': ('transform', O, 'location', '-'), 'a1': ('transform', A, 'location', '-'), }, expr="b1 + (s/r)*(a1-b1)") if 'Circle' in A.data.name: add_driver(obj=new, prop='scale', fields='XYZ', vars_def={ 's': ('transform', L, 'scale', 'X'), 'r': ('transform', R, 'scale', 'X'), 's1': ('transform', A, 'scale', 'X'), }, expr="(s/r)*s1") if self.display_center: center = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) copy_location(center, new) copy_rotation(center, new) if 'Line' in A.data.name: add_driver(obj=new, prop='scale', fields='XYZ', vars_def={ 's': ('transform', L, 'scale', 'X'), 'r': ('transform', R, 'scale', 'X'), 's1': ('transform', A, 'scale', 'X'), }, expr="(s/r)*s1") end1 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) end2 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) line_ends(end1, end2, new) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects[-2:] others.remove(A) B = others[0] e_help = new_empty(hide=self.hide_extra) e_help.name = "Object defining drivers" e_help.location[0] = self.ratio if self.display_inside: new_inside = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) new_inside.name = "Segment divider inside" copy_rotation(new_inside, A) add_driver( obj=new_inside, prop='location', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 'b1': ('transform', B, 'location', '-'), 'a1': ('transform', A, 'location', '-'), }, expr="b1 + (x1 / (1+x1)) * (a1-b1)" ) if self.display_outside: if self.ratio > 1: new_outside = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) new_outside.name = "Segment divider outside" copy_rotation(new_outside, A) add_driver( obj=new_outside, prop='location', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 'b1': ('transform', B, 'location', '-'), 'a1': ('transform', A, 'location', '-'), }, expr="b1 + (x1/(x1-1))*(a1-b1)" ) if self.ratio < 1: new_outside = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) new_outside.name = "Segment divider outside" copy_rotation(new_outside, A) add_driver( obj=new_outside, prop='location', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 'b1': ('transform', B, 'location', '-'), 'a1': ('transform', A, 'location', '-'), }, expr="b1 - (x1/(1-x1))*(a1-b1)" ) return {'FINISHED'}
def execute(self, context): A = context.active_object others = context.selected_objects[-2:] others.remove(A) B = others[0] e_help = new_empty(hide=self.hide_extra) e_help.name = "Object defining drivers" e_help.location[0] = self.ratio if not (isinstance(A.data, bpy.types.Curve)): new = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) new.name = "Homothetic object" # Can try to duplicate instead and then clear all constraints if 'Line' in A.data.name: new = new_line() new.name = "Homothetic object" add_abs_bevel(new, self.bevel_depth) if 'Circle' in A.data.name: new = new_circle() new.name = "Homothetic object" add_abs_bevel(new, self.bevel_depth) copy_rotation(new, A) add_driver(obj=new, prop='location', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 'b1': ('transform', B, 'location', '-'), 'a1': ('transform', A, 'location', '-'), }, expr="b1 + x1*(a1-b1)") if 'Circle' in A.data.name: add_driver(obj=new, prop='scale', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 's1': ('transform', A, 'scale', 'X'), }, expr="x1*s1") if self.display_center: center = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) copy_location(center, new) copy_rotation(center, new) if 'Line' in A.data.name: add_driver(obj=new, prop='scale', fields='XYZ', vars_def={ 'x1': ('transform', e_help, 'location', 'X'), 's1': ('transform', A, 'scale', 'X'), }, expr="x1*s1") end1 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) end2 = new_point(use_spheres=self.use_spheres, radius=self.sphere_radius) line_ends(end1, end2, new) return {'FINISHED'}