BlenderAddons icon indicating copy to clipboard operation
BlenderAddons copied to clipboard

Code to modify if you get stuck in "Needs at least two selected objects" when distributing objects

Open issacyip95 opened this issue 2 years ago • 0 comments

The issue is in the selector "bpy.selection_osc". The script will work if you modify distrubute.py in "C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\addons\oscurart_tools\object".

def ObjectDistributeOscurart(self, X, Y, Z):
    if len(bpy.context.selected_objects[:]) > 1:
        # VARIABLES
        dif = bpy.context.selected_objects[-1].location - bpy.context.selected_objects[0].location
        chunkglobal = dif / (len(bpy.context.selected_objects[:]) - 1)
        chunkx = 0
        chunky = 0
        chunkz = 0
        deltafst = bpy.context.selected_objects[0].location

        # ORDENA
        for OBJECT in bpy.context.selected_objects[:]:
            if X:
                OBJECT.location.x = deltafst[0] + chunkx
            if Y:
                OBJECT.location[1] = deltafst[1] + chunky
            if Z:
                OBJECT.location.z = deltafst[2] + chunkz
            chunkx += chunkglobal[0]
            chunky += chunkglobal[1]
            chunkz += chunkglobal[2]
    else:
        self.report({'INFO'}, "Needs at least two selected objects")

issacyip95 avatar Mar 09 '22 11:03 issacyip95