0
$\begingroup$

So i have an object properties panel but the values set are identical across every object. So for example I have an int value on a cube set to 2 but then all objects are now set to 2. How could that value be set to just that cube as selecting another object will use the same value? Code:

bl_info = {
    "name": "Test",
    "author": "",
    "version": (1, 0),
    "blender": (2, 75, 0),
    "location": "View3D > Add > Mesh > New Object",
    "description": "",
    "warning": "",
    "wiki_url": "",
    "category": "New Addon",
    }

import bpy
from bpy.types import Operator
from bpy.props import FloatVectorProperty
from bpy_extras.object_utils import AddObjectHelper, object_data_add
from mathutils import Vector
from bl_operators.presets import AddPresetBase


from bpy.props import (StringProperty,
                       BoolProperty,
                       IntProperty,
                       FloatProperty,
                       EnumProperty,
                       PointerProperty,
                       )
from bpy.types import (Panel,
                       AddonPreferences,
                       PropertyGroup,
                       )




def initprop():
    bpy.types.Scene.IntCheckpoint = bpy.props.IntProperty(
    name="Check Point",
    description="Checkpoints to prevent skipping certain paths",
    min=-1, max=99999,
    default=-1) #-1 disables a check!



def delprop():
    del bpy.types.Scene.IntCheckpoint


class ObjectPanel(bpy.types.Panel):
    bl_label = "Hello from Object context"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"

    def draw(self, context):
        scene = context.scene
        obj = context.object
        layout = self.layout
        layout.label("First row")
        row = layout.row(align=True)
        row.alignment = 'EXPAND'
        row = layout.row()
        row = layout.row()
        col = layout.column(align=True)
        scn = bpy.context.scene
        col.prop(scene, "IntCheckpoint") #This needs to be changeable for each object
        row = layout.row()







# Registration

def register():
    bpy.utils.register_module(__name__)
    initprop()


def unregister():
    bpy.utils.unregister_module(__name__)
    delprop()



if __name__ == "__main__":
    register()

The code should work in blender's text editor.

$\endgroup$
0
$\begingroup$

Your property is being created for the scenes, when you want to create it for the objects. So this:

bpy.types.Scene.IntCheckpoint

needs to be changed to this:

bpy.types.Object.IntCheckpoint

And then in your panel you'll change this:

col.prop(scene, "IntCheckpoint")

to this:

col.prop(obj, "IntCheckpoint")

So to create a property specific to a type, you have to use that type in your property declaration.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.