Пример #1
0
    def execute(self, context):

        line = context.active_object
        sphere = new_sphere(segments=self.segments)

        if isinstance(line.data, bpy.types.Curve):
            A = new_point(hide=self.hide_extra)
            B = new_point(hide=self.hide_extra)
            line_ends(A, B, line)
            sphere_from_diameter(sphere, A, B)

        else:
            (A, B) = context.selected_objects[-2:]
            sphere_from_diameter(sphere, A, B)

        return {'FINISHED'}
Пример #2
0
    def execute(self, context):

        line = context.active_object

        if isinstance(line.data, bpy.types.Curve):
            A = new_point(hide=self.hide_extra)
            B = new_point(hide=self.hide_extra)
            line_ends(A, B, line)
            circle = new_circle()
            circle_from_diameter(circle, A, B)
            add_abs_bevel(circle, self.bevel_depth)

        else:
            (A, B) = context.selected_objects[-2:]
            circle = new_circle()
            circle_from_diameter(circle, A, B)
            add_abs_bevel(circle, self.bevel_depth)

        return {'FINISHED'}
Пример #3
0
    def execute(self, context):

        if (len(context.selected_objects) == 2):
            (A, B) = context.selected_objects[-2:]
            obj = new_point(use_spheres=self.use_spheres,
                            radius=self.sphere_radius)

            midpoint(obj, A, B)

        if (len(context.selected_objects) == 1):
            A = context.active_object
            X = new_point(hide=self.hide_extra)
            Y = new_point(hide=self.hide_extra)
            line_ends(X, Y, A)
            obj = new_point(use_spheres=self.use_spheres,
                            radius=self.sphere_radius)

            midpoint(obj, X, Y)

        return {'FINISHED'}
Пример #4
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'}
Пример #5
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'}