Example #1
0
    def execute(self, context):
        A = context.active_object
        polygon = new_polygon(sides=self.sides_number,
                              length=self.sides_length,
                              hide=True)
        add_abs_bevel(polygon, self.bevel_depth)
        polygon.parent = A
        polygon.rotation_euler[2] = math.radians(self.polygon_rotate)

        vertices = []
        for i in range(int(self.sides_number)):
            s = new_point(radius=self.sphere_radius)
            position_on_curve(s, polygon, position=i / self.sides_number)
            add_driver(obj=s, prop='location', fields='Z', expr="0")
            vertices.append(s)

        for i in range(int(self.sides_number) - 1):
            line = new_line()
            segment(line, vertices[i], vertices[i + 1])
            add_abs_bevel(line, self.bevel_depth)
            line.name = "Side of polygon"

            line = new_line()
            segment(line, vertices[0], vertices[int(self.sides_number) - 1])
            add_abs_bevel(line, self.bevel_depth)
            line.name = "Side of polygon"

        return {'FINISHED'}
    def execute(self, context):

        if (len(context.selected_objects) == 3):
            A = context.active_object
            others = context.selected_objects[-3:]
            others.remove(A)
            (B, C) = others
            line = new_line(hide=self.hide_extra)
            segment(line, B, C)

            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            parallel_line(obj, A, line, hide_extra=self.hide_extra)

        if (len(context.selected_objects) == 2):
            A = context.active_object
            others = context.selected_objects[-2:]
            others.remove(A)
            line = others[0]
            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            parallel_line(obj, A, line, hide_extra=self.hide_extra)

        return {'FINISHED'}
    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'}
Example #4
0
    def execute(self, context):
        (A, B, C) = context.selected_objects[-3:]

        lines = [new_line(), new_line(), new_line()]
        segment(lines[0], A, B)
        segment(lines[1], B, C)
        segment(lines[2], C, A)

        for idx, line in enumerate(lines):
            line.name = f"Side {idx + 1}"
            add_abs_bevel(line, self.bevel_depth)

        return {'FINISHED'}
Example #5
0
    def execute(self, context):
        (A, B) = context.selected_objects[-2:]

        newline = new_line()
        line(newline, A, B, length=self.length)
        add_abs_bevel(newline, self.bevel_depth)
        newline.name = "Line"

        return {'FINISHED'}
Example #6
0
    def execute(self, context):
        (A, B) = context.selected_objects[-2:]

        line = new_line()
        segment(line, A, B)
        add_abs_bevel(line, self.bevel_depth)
        line.name = "Line Segment"

        return {'FINISHED'}
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-2:]
        others.remove(A)
        B = others[0]

        point1 = new_point()
        point2 = new_point()
        circle_tangent_points(point1, point2, B, A)

        line1 = new_line()
        add_abs_bevel(line1, self.bevel_depth)
        line2 = new_line()
        add_abs_bevel(line2, self.bevel_depth)

        circle_tangent_lines(line1, line2, B, A, hide_extra=self.hide_extra)

        return {'FINISHED'}
    def execute(self, context):

        if (len(context.selected_objects) == 2):
            (B, C) = context.selected_objects[-2:]

            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            bisecting_line_of_points(obj, B, C, hide_extra=self.hide_extra)

        if (len(context.selected_objects) == 1):
            A = context.active_object
            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            bisecting_line_of_line(obj, A, hide_extra=self.hide_extra)

        return {'FINISHED'}
    def execute(self, context):
        (A, B, C) = context.selected_objects[-3:]

        line1 = new_line(length=self.length)
        add_abs_bevel(line1, self.bevel_depth)

        euler_line(line1, A, B, C)

        return {'FINISHED'}
    def execute(self, context):
        (A, B) = context.selected_objects[-2:]
        point_r = new_point(hide=True)
        radical_intercept(point_r, A, B)
        line1 = new_line(length=self.length)
        add_abs_bevel(line1, self.bevel_depth)

        radical_axis(line1, A, B)

        return {'FINISHED'}
Example #11
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-3:]
        others.remove(A)
        (B, C) = others

        med = new_line(length=self.length)
        add_abs_bevel(med, self.bevel_depth)
        external_bisector(med, A, B, C)

        return {'FINISHED'}
Example #12
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-2:]
        others.remove(A)
        B = others[0]

        line1 = new_line(length=self.length)
        add_abs_bevel(line1, self.bevel_depth)

        polar_line(line1, A, B, hide_extra=self.hide_extra)

        return {'FINISHED'}
    def execute(self, context):

        A = context.active_object
        others = context.selected_objects[-2:]
        others.remove(A)
        B = others[0]

        inv_line = new_line(length=self.length)
        add_abs_bevel(inv_line, self.bevel_depth)
        inversion_on_cicle(inv_line, A, B)

        return {'FINISHED'}
Example #14
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-2:]
        others.remove(A)
        B = others[0]

        line1 = new_line(length=self.length)
        add_abs_bevel(line1, self.bevel_depth)

        circle_tangent_line(line1, B, A)

        return {'FINISHED'}
Example #15
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-2:]
        others.remove(A)
        B = others[0]

        line = new_line()
        ray(line, A, B, length=self.length)
        add_abs_bevel(line, self.bevel_depth)
        line.name = "Ray"

        return {'FINISHED'}
Example #16
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-3:]
        others.remove(A)
        (B, C) = others

        footp = new_point(use_spheres=self.use_spheres,
                          radius=self.sphere_radius,
                          hide=self.hide_foot)

        alt = new_line()
        add_abs_bevel(alt, self.bevel_depth)
        altitude(alt, footp, A, B, C)

        return {'FINISHED'}
Example #17
0
    def execute(self, context):

        if (len(context.selected_objects) == 3):
            A = context.active_object
            others = context.selected_objects[-3:]
            others.remove(A)
            (B, C) = others

            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            orthogonal_line_to_points(obj, A, B, C, hide_extra=self.hide_extra)

        if (len(context.selected_objects) == 2):
            A = context.active_object
            others = context.selected_objects[-2:]
            others.remove(A)
            B = others[0]
            obj = new_line(length=self.length)
            add_abs_bevel(obj, self.bevel_depth)

            orthogonal_line_to_line(obj, A, B, hide_extra=self.hide_extra)

        return {'FINISHED'}
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-3:]
        others.remove(A)
        (B, C) = others

        midp = new_point(use_spheres=self.use_spheres,
                         radius=self.sphere_radius,
                         hide=self.hide_foot)

        med = new_line()
        add_abs_bevel(med, self.bevel_depth)
        angle_bisector(med, midp, A, B, C)

        return {'FINISHED'}
    def execute(self, context):

        A = context.active_object
        others = context.selected_objects[-3:]
        others.remove(A)
        (B, C) = others

        point1 = new_point(hide=True)

        angle_divider_foot(point1, A, B, C, influ=self.division_proportion)

        line1 = new_line()
        add_abs_bevel(line1, self.bevel_depth)

        if self.use_ray:
            ray(line1, A, point1)
        else:
            line(line1, A, point1)

        return {'FINISHED'}
Example #20
0
    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)
        bpy.ops.object.mode_set(mode='EDIT')
        cone.location.z -= self.cone_length / 2
        bpy.ops.object.mode_set(mode='OBJECT')

        copy_location(cone, A)
        damped_track(cone, axis='-X', target=B)
        A.hide_viewport = self.hide_endpoint

        return {'FINISHED'}
Example #21
0
    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'}
Example #22
0
    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'}
    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'}
Example #24
0
    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'}
Example #25
0
    def execute(self, context):
        A = context.active_object
        others = context.selected_objects[-3:]
        others.remove(A)
        B, C = others

        arc = new_arc(angle=360, sides=64, hide=self.hide_arc)

        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, B)
            ray(side2, A, C)

        uniform_scale(arc, self.radius)

        add_abs_bevel(arc, self.bevel_depth)
        align_to_plane_of(arc, A, B, C)

        if self.other_angle:
            B, C = C, B

        add_driver(
            obj=arc.data,
            prop='bevel_factor_start',
            vars_def={
                'ax': ('transform', A, 'location', 'X'),
                'ay': ('transform', A, 'location', 'Y'),
                'az': ('transform', A, 'location', 'Z'),
                'bx': ('transform', B, 'location', 'X'),
                'by': ('transform', B, 'location', 'Y'),
                'bz': ('transform', B, 'location', 'Z'),
                'cx': ('transform', C, 'location', 'X'),
                'cy': ('transform', C, 'location', 'Y'),
                'cz': ('transform', C, 'location', 'Z'),
            },
            expr='gb_drive_angle_bevel(True,ax,ay,az,bx,by,bz,cx,cy,cz)')

        add_driver(
            obj=arc.data,
            prop='bevel_factor_end',
            vars_def={
                'ax': ('transform', A, 'location', 'X'),
                'ay': ('transform', A, 'location', 'Y'),
                'az': ('transform', A, 'location', 'Z'),
                'bx': ('transform', B, 'location', 'X'),
                'by': ('transform', B, 'location', 'Y'),
                'bz': ('transform', B, 'location', 'Z'),
                'cx': ('transform', C, 'location', 'X'),
                'cy': ('transform', C, 'location', 'Y'),
                'cz': ('transform', C, 'location', 'Z'),
            },
            expr='gb_drive_angle_bevel(False,ax,ay,az,bx,by,bz,cx,cy,cz)')

        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, position=0)
        position_on_curve(end2, arc, position=1)

        add_driver(obj=end1.constraints[-1],
                   prop='offset_factor',
                   vars_def={
                       'bev': ("datapath", arc, "data.bevel_factor_start"),
                   },
                   expr="bev")

        add_driver(obj=end2.constraints[-1],
                   prop='offset_factor',
                   vars_def={
                       'bev': ("datapath", arc, "data.bevel_factor_end"),
                   },
                   expr="bev")

        return {'FINISHED'}