Converting script that duplicates objects along a curve on an addon

Hello, the script is ready, just need to finish turning into a new tab with options for Blender. In other words, make a addon.

import bpy
import mathutils
from mathutils import Vector


dist = 35.0 # Distance between duplicate objects
curve = bpy.context.active_object.data # Referencing the selected object
# qt = 0 #(To see in System Console)
bpy.context.active_object.select = False # Unselect curve
bpy.context.scene.objects.active = bpy.context.selected_objects[0] # Activing the penultimate selected object


for c in range(0,len(curve.splines)): # For each spline on the curve


    dx = 0.0 # Length of initial calculation of section


    for e in range(0,len(curve.splines[c].bezier_points)): # For each point on the spline


        vetorx = curve.splines[c].bezier_points[e].co-curve.splines[c].bezier_points[e-1].co # Vector spline section
        dx += vetorx.length # Defined length calculation equal total length of the spline section


        while dx > dist: # While calculating the total length of the section is larger than the set distance proceed:
            
            x = dx - dist # Calculating the remaining length of the section
            
            obj = bpy.context.scene.objects.active.copy()
            bpy.context.scene.objects.link(obj)
            # bpy.ops.object.duplicate(linked=True) # Duplicating selected objects
            obj.location = curve.splines[c].bezier_points[e].co - (vetorx/vetorx.length)*x # Putting in the correct position
            obj.rotation_mode = 'QUATERNION'
            obj.rotation_quaternion = mathutils.Vector.to_track_quat(vetorx, 'X', 'Z') # Tracking the selected objects
            
            dx = x # Defining the new length calculation remainder of the section
            # qt+=1
            # print('duplicate', qt)
3 Likes