Long Key names in Blender

Hi @TomSvilans,

I ran into a funny issue with a colleague today, where a property key longer than 63 characters was causing the import into Blender to fail.

A KeyError was thrown here: https://github.com/speckleworks/SpeckleBlender/blob/a92538027a18ebe256161fe188beb844004b06b3/bpy_speckle/convert/init.py#L100, with the explaination that the key was too long (>63 characters, I think).

I wrapped that line in a try/except clause like so:

    blender_object[key_name] = prop[key]
except KeyError:

and the stream imported fine (with some data presumably missing, but we haven’t missed it yet :stuck_out_tongue: )

This is definitely a hacky workaround - I’ll submit these changes in a PR on github to carry on the discussion.

I apologize for not have the specific error message, etc… I saw the error on a colleauge’s screen via Teams, so I don’t have it at hand.

p.s. here in the PR: https://github.com/speckleworks/SpeckleBlender/pull/17

1 Like

Thanks, David, I’ll try to take a look at it soon. What a funny and frustrating limitation!

1 Like

@daviddekoning I’ve merged the PR, thanks for that :slight_smile: I haven’t had a chance to look into the Blender docs to see if there is a work-around or some limitation that could be side-stepped.

The reason they get so long is that, since custom properties in Blender are just a dictionary, I prepend the key name with its parent key recursively, to allow the wrangling of the original property dictionary structure later on. I hazily recall this being because of not being able to nest dictionaries within custom Blender props, but I need to verify this. Either way, it is not optimal.

Do let me know if you have a better approach for this!

1 Like

Actually, while I’m at it, it seems you can put a dict as a custom prop, however it just won’t be editable from the Custom Properties panel, which probably isn’t that big of a deal, unless you want to fiddle with the values in the UI, as well as through scripts (similar thing discussed here).

You can still access the property dictionary values, and it should also be possible using drivers and the rest of the fun Blender stuff.

I will log it as an issue / to-do.

1 Like

thanks @TomSvilans. @dodowd - do you plan to edit custom properties in the UI, or just via python code?

@daviddekoning @TomSvilans - Hi both! Thanks so much for the help with this.

I would hope we can edit these within the blender UI and then push them back to Revit via speckle. There are quite a few reasons around this but it comes down to usability and interoperability.

Hi @dodowd this would indeed be the goal…

At the moment, you can edit nested custom props dictionaries through the Outliner, if you set it to Data API mode (instead of Scenes). You get all of the object properties, though, so you need to scroll down to the custom props, and it doesn’t automatically switch the focus to another object when you select it, so you need to manually scroll up and find that particular object. Highly annoying for moving around multiple objects, but it gives you the nested property tree.

Under object settings, you can adjust individual custom properties (floats, ints, strings), but dictionaries are just a text blob, which makes them impractical to adjust.

Implementing a better custom property tree view would be useful not only for Speckle but for generally working with Blender custom props, however this is a bigger task. I don’t have the bandwidth at the moment to do it, but perhaps it can be chipped away at over the next while.