0
$\begingroup$

In a new blender file with v2.93.0 on arch linux, I go to the "Scripting" workspace and I run this in the console: bpy.types.Scene.x = bpy.props.IntProperty(name="Something"). That used to render the property as a widget in the "Scene Properties" panel but now it doesn't anymore. Any idea why this could be happening?

I'm not entirely sure which version still worked, but I think it was in 2.8x.

UPDATE: It also doesn't work with 2.83.15. How could I make this widget show up?

$\endgroup$
3
$\begingroup$

I think the property is there, the UI just hasn't been updated to display it.

You added a custom property globally to all objects that happen to be of type bpy.types.Scene. You can make the current scene aware of it by simply setting the current scene custom prop to itself.

import bpy

bpy.types.Scene.x = bpy.props.IntProperty(name="Something")

bpy.context.scene.x = bpy.context.scene.x

Note this will fire the update, set and get callbacks for this property.

It will then appear in the Custom Properties panel when you next hover your mouse over it. If you want the UI to update immediately, you can force a redraw, but it is advised against in the documentation.

bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
$\endgroup$
1
  • $\begingroup$ Thank you for that answer! Unfortunately, I can't get it to work, the UI isn't showing any new custom property for the scene. However, following your steps, I can save and load the .blend file and then the UI DOES show the "x" property. I can also access bpy.context.scene['x'] (but not bpy.context.scene.x) but bpy.types.Scene.x raises exceptions. So it seems the modified "Scene type" isn't persisted. My (actual) property also defines a update callback, like bpy.props.IntProperty(name="Something", update=myFunction). Is there a smarter way to do this? $\endgroup$
    – moritz
    Jun 15 at 20:49

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.