After some days in research I’ve done as follow but I can’t do an user interface for this.
What I’d like to do is to have in the tools panel the min and max value and a button to assign randomly to the selected objects.
At the moment the script works only for the assignement part but in the console I have this error
File “U:\Scripts\blender\Marcatore est_script.blend\Text”, line 36, in draw
TypeError: UILayout.prop(): error with argument 1, “data” - Function.data expec
ted a AnyType type, not RNAMeta
The line 36 is this (below there is the script)
row.prop(BuildUI,“minID”)
I can’t understand what’s wrong
Anyone could help me to build the user interface for this?
Thanks in advance for your help.
Here the script
bl_info = { “name”: “Set Random Object Pass Index”,
“author”: “Riccardo Barducco (marcatore)”,
“version”: (1, 0),
“blender”: (2, 69, 0),
“location”: “View3D > Panel > Random Object Pass Index”,
“description”: “Set a random object pass index”,
“warning”: “”,
“wiki_url”: “”,
“tracker_url”: “”,
“category”: “Object”}
import bpy, random
from bpy.props import IntProperty
class BuildUI(bpy.types.Panel):
“”“Creates a Panel in the scene context of the properties editor”""
bl_label = “Random object pass index”
bl_idname = “object.random_pass_index_UI”
bl_space_type = ‘VIEW_3D’
bl_region_type = ‘TOOLS’
minID = 0
maxID = 6
def draw(self, context):
layout = self.layout
scene = context.scene
row = layout.row()
row.prop(BuildUI,"minID")
class SetRandomObjectPassIndex(bpy.types.Operator):
“”“Set Object Pass Index”""
bl_idname = “object.random_pass_index”
bl_label = “Random Pass Index”
bl_options = {‘REGISTER’, ‘UNDO’}
def execute(self, context):
scene = bpy.context
obj = scene.selected_objects
for obj in scene.selected_objects:
print (obj)
randNum = random.randint(BuildUI.minID, BuildUI.maxID)
obj.pass_index = randNum
return {'FINISHED'}
def register():
bpy.utils.register_class(SetRandomObjectPassIndex)
bpy.utils.register_class(BuildUI)
bpy.ops.object.random_pass_index()
def unregister():
bpy.utils.unregister_class(SetRandomObjectPassIndex)
bpy.utils.unregister_class(BuildUI)
bpy.ops.object.random_pass_index()
if name == “main”:
register()