hep creating integer value UI field

Dear blenders,
i’m a bit new with blender scripting so I can’t understand how to do what’s following.

I’m doing a random object pass index assigner.

About the part that assign a random number I haven’t any problem, where I’m in difficult is the UI building.

What I’d like to do is a simple UI where I have two value fields used as a “min” and a “max” value.
What I’d like to do is to create these value fields with a start value of 0, set the value desidered and with a “assign” button start the assignment-routine (already done and working).

If possible I don’t wnat that someone wrote the script for me…but I’d feeling happy to have some links to the right blender python support pages because it’s difficult to focus for to the right things.

Thanks in advance.


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)


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()

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():
def unregister():

if name == “main”:

hey marcatore,

we are reading your script/posts but it will take some time to find someone who has good insight in your problem.


Thank you, I’ll take a look… :slight_smile: