IDLabMedia / blender-lightfield-addon

Blender addon to configure and render light fields
MIT License
35 stars 4 forks source link

Update it for 3.4+? #5

Open BUGProtectionAssociation opened 1 year ago

BUGProtectionAssociation commented 1 year ago

May too old...3.4 3.5 can't use as normal

`Traceback (most recent call last):
  File "G:\blender\35\3.5\scripts\modules\addon_utils.py", line 369, in enable
    mod.register()
  File "G:\blenderplus\3.0\addons\blender-lightfield-addon-main\__init__.py", line 130, in register
    bpy.utils.register_class(cls)
ValueError: register_class(...): already registered as a subclass 'LightfieldVisual'

image

mcourteaux commented 1 year ago

Thanks for reporting this. I don't find immediately a fix, but I can confirm it still works in Blender 3.4.

mavills commented 1 year ago

https://wiki.blender.org/wiki/Reference/Release_Notes/3.5/Python_API#Breaking_changes

Overriding of default operators appears to be unconventional and caused some problems when having registered a lot of overrides. They removed this functionality.

In addition to that, the error we see here is due to the class already being registed, but this is simply a consequence of the addon failing the first time. The error is different right after startup, and continues to show this one in subsequent tries.

  1. The workaround here is to customize the user's keymapping by looking up their keymap settings and copying those over to your addon ones (with the operator name changed ofcourse). Disable the default (user mapping) -> good to go. https://docs.blender.org/api/current/bpy.types.KeyConfigurations.html#bpy.types.KeyConfigurations

Not the cleanest, but does the trick.

Here, the default delete action is disabled (x) and I added (manually) our custom, renamed, delete action. image For code, see https://blender.stackexchange.com/questions/196483/create-keyboard-shortcut-for-an-operator-using-python

  1. Another option is to re-add the commented depgraph handler and check if the dependency graph updated the lightfield object, but this is probably pretty heavy performance wise.

Option 1 seems best and simplest here, don't see a reason not to go for it. do not forget to override both outliner and 3d view delete.

mavills commented 1 year ago

I see that you can even override the default delete action in the preferences, image

This way you do not have to mess with the users bindings! Just search through all keymaps for object.delete and outliner.delete, and change the respective KeyMap's action to your custom operator delete.

3020 commented 1 year ago

Any news or updates for 3.6?

mavills commented 1 year ago

Unfortunately no, I am no longer active on this project. What would be your usecase? Maybe I can see if we can fix what you need/get you a head start in fixing it!

stanthemaker commented 8 months ago

I see that you can even override the default delete action in the preferences, image

This way you do not have to mess with the users bindings! Just search through all keymaps for object.delete and outliner.delete, and change the respective KeyMap's action to your custom operator delete.

Hi. I am using blender 4.0.2. I followed the instructions and overrode 4 keymaps delete settings in object mode, as well as 2 in outliner. However, it doesn't do the trick. image I have also looked up the source file (operator.py) and found an operator that looks relevant to your solution. image I am new to the blender, and I hope you can provide a more detailed solution.