In Blender when I select an object and I change any setting, the other objects are not affected, but when I create a panel with properties from bpy.props, changing an intProperty on one changes it on the others
Look at this example: I made a custom panel with 2 properties
I create 2 object A and B with property "Resolution" = 12, then on object A I change resolution to 20
when clicking on object B I see that resolution is 20 as well, but I want it to be still 12.
I understand that this is because I have only registered one set of properties, that are all the same, so is there a way to register different properties for each object, and create a panel that shows only the properties of the active one?
(custom ID props could be a workaround, but I would prefer to use a custom panel because it's cleaner and drivers are way worse to trigger update functions)
here there is the part of the code related to properties:
class MyProperties(bpy.types.PropertyGroup):
sphere_resolution: IntProperty(
name="Resolution",
description="resolution of the sphere",
default=8,
min=3,
update=updateResolution #function that changes the subdivisions of the sphere
)
sphere_transform: FloatProperty(
name="Transformation",
description="curvature of the Radial Sphere: = 0 is a plane, 1 is a sphere",
default=1.0,
min=0.0,
max=1.0
)
operator to create the objects. Each object should have its own properties
class MESH_OT_CreateRadialSphere(bpy.types.Operator):
bl_idname = "mesh.create_radial_sphere"
bl_label = "Radial Sphere"
def execute(self, context):
# stuff
return {'FINISHED'}
create panel. Here there should be the properties of the active object, if the active object was created by the create operator, and changing a value should only affect the active object
class MESH_PT_sphere_topologies(bpy.types.Panel):
bl_idname = "MESH_PT_sphere_topologies"
bl_label = "Sphere Topologies"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
@classmethod
def poll(self, context):
# stuff
def draw(self, context):
layout = self.layout
mytool = context.scene.SphereTopology
layout.prop(mytool, "sphere_resolution")
layout.prop(mytool, "sphere_transform")
classes = (
MESH_OT_CreateRadialSphere,
MESH_PT_sphere_topologies,
MyProperties
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.SphereTopology = PointerProperty(type=MyProperties)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.Scene.SphereTopology


SphereTopologyclass tobpy.types.Objectrather than tobpy.types.Sceneelse you only have one instance of yourMyPropertygroup (per Scene), and only one shared value – Gorgious Nov 23 '20 at 16:16