1
$\begingroup$

I had need of a URDF visuzlizer on some Windows machines heavily controlled by our IT, so I used the portable zip Blender and made some custom scripts to view and manipulate the URDF. This worked great in 2.90, but now in 2.93 the sliders that I was adding dynamically don't show up any more.enter image description here

I believe my problem is in one of three places.

  1. Where I dynamically create the class: (Edit to add suggestions by @batFINGER)
        # Dynamically create the same class
        JointControllerProperties = type(
            # Class name
            "JointControllerProperties",

            # Base class
            (bpy.types.PropertyGroup, ), {
                "__annotations__": robot.annotations
            },
        )
        URDF_PT_JointControllerPanel.set_joint_names(robot.joint_names)
        bpy.utils.register_class(JointControllerProperties)
        bpy.types.Scene.joint_tool = PointerProperty(type=JointControllerProperties)
        bpy.utils.register_class(URDF_PT_JointControllerPanel)
  1. where I'm adding the annotations for the slider:
    def GenerateJointAnnotations(self):
        # Generate annotations for dynamically creating the joint sliders.
        # Form should be (dictionary of tuples):
        # annotations: {
        #   'joint0': (
        #        FloatProperty, {
        #            'name': 'j0',
        #            'description': 'desc',
        #            'default': 0,
        #            'min': joint_min,
        #            'max': joint_max,
        #            'update': float_callback}),
        #    <repeated for each joint>
        self.annotations = {}
        for joint in blender_joints:
            if blender_joints[joint]['type'] == 'fixed':
                print('INFO: Fixed joint. Skipping ', joint)
                continue

            self.joint_names.append(joint)
            self.annotations[joint] = (FloatProperty,
            {
                'name': joint,
                'description': joint,
                'default': 0,
                'min': blender_joints[joint]['limit'][0],
                'max': blender_joints[joint]['limit'][1],
                'update': float_callback
            })
        return
  1. Where I'm drawing the widget
    def draw(self, context):
        layout = self.layout
        layout.label(text = 'joint angles')
        scene = context.scene
        joint_tool = scene.joint_tool

        if (len(URDF_PT_JointControllerPanel.joint_names) > 0):
            for joint in URDF_PT_JointControllerPanel.joint_names:
                layout.prop(joint_tool, joint)

        layout.separator()

Error with @batFINGER's suggestion:

rna_uiItemR: property not found: JointControllerProperties.SY
/home/andy/.config/blender/2.93/scripts/addons/blender_urdf_visualization/joint_controller.py:28

I'm guessing my dictionary is no longer correct either, but can't find an example of what this should look like.

Any help would be appreciated... I don't know the blender API well enough to find out where I'm going wrong.

EDIT: Chagnes thanks to @batFINGER's comments and answer can be seen here.

$\endgroup$
4
  • 1
    $\begingroup$ Hello, does it throw an error in the console ? View > System Console $\endgroup$
    – Gorgious
    Sep 28 at 21:01
  • $\begingroup$ no, I launch from command line on Ubuntu but don't get anything but the info msgs I print out... I was under the assumption any error msgs would also print out there. Is that not true? $\endgroup$ Sep 28 at 21:11
  • 2
    $\begingroup$ Suspect it is same issue as blender.stackexchange.com/questions/239407/… Prob requires setting dictionary to __annotations__ of the property group $\endgroup$
    – batFINGER
    Sep 29 at 0:50
  • $\begingroup$ Thanks @batFINGER, I think that's got me going in the right direction... now I'm at least getting some error msgs in the console: rna_uiItemR: property not found: JointControllerProperties.SY joint_controller.py:28 $\endgroup$ Sep 29 at 3:58
4
$\begingroup$

Set the __annotations__ dictionary

Further to comment

Suspect it is same issue as Python Operator worked until 2.93, now throws " not _PropertyDeferred" error Prob requires setting dictionary to annotations of the property group

Wrote, before, pasted after edit to question, anyway shows on the right track. Test example.

import bpy

from bpy.types import PropertyGroup
from bpy.props import FloatProperty, PointerProperty
context = bpy.context

annos = {f"float{i}" : FloatProperty(default=i) for i in range(10)}

Foo = type("Foo",
        (PropertyGroup,),
        {"__annotations__" : annos}
        )
        
bpy.utils.register_class(Foo)
bpy.types.Scene.foo = PointerProperty(type=Foo)

Python console

>>> bpy.app.version
(2, 93, 0)

>>> C.scene.foo.float9
9.0

Which after checking is pretty much the example outlined in 2.93 release notes from (probable duplicate) link posted

See the difference to

        self.annotations[joint] = (FloatProperty,
        {
            'name': joint,
            'description': joint,
            'default': 0,
            'min': blender_joints[joint]['limit'][0],
            'max': blender_joints[joint]['limit'][1],
            'update': float_callback
        })

in that you are setting akin to a partial function (FooProperty, propsdict)

instead of to FooProperty(**propsdict) to wire up the groups properties as demonstrated above.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks! working perfectly again. $\endgroup$ Sep 29 at 13:55

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.