Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensionsused - no longer populated with user extesions - help requested #2253

Closed
ronh991 opened this issue May 28, 2024 · 13 comments · Fixed by #2255 or #2313
Closed

Extensionsused - no longer populated with user extesions - help requested #2253

ronh991 opened this issue May 28, 2024 · 13 comments · Fixed by #2255 or #2313
Labels
bug Something isn't working

Comments

@ronh991
Copy link

ronh991 commented May 28, 2024

Describe the bug
The extensions used is no longer being populated with my user extensions. this was working as expected April 24. Is there a requirement for use extensions to be added to the extensionsused dsection. The extensions are part of all the other sections as needed. Just the extensions used is not

To Reproduce
Steps to reproduce the behavior:
Make and hook to add in a functionality for a user extension.

Expected behavior
userextension section is populated

Screenshots
pre April 24

	"extensionsUsed":[
		"ASOBO_normal_map_convention",
		"ASOBO_unique_id",
		"KHR_materials_specular",
		"KHR_materials_ior",
		"ASOBO_material_detail_map",
		"ASOBO_material_windshield",
		"ASOBO_material_shadow_options",
		"ASOBO_material_fresnel_fade",
		"ASOBO_material_glass",
		"ASOBO_material_blend_gbuffer"
	],

latest export

	"extensionsUsed":[
		"KHR_materials_clearcoat",
		"KHR_materials_specular",
		"KHR_materials_ior"
	],

.blend file/ .gltf (mandatory)
not available as you do not have the code that adds the extensions - Help request only

Version

  • OS: win10

  • Blender Version Blender 4.2 aebf

     "generator":"Khronos glTF Blender I/O v4.2.40 and Asobo Studio MSFS Blender I/O v2.2.3",
     "version":"2.0"
    

Additional context
Add any other context about the problem here.

@ronh991
Copy link
Author

ronh991 commented May 28, 2024

I have tracked this to the new extensions - rather than legacy add-ons. it is no longer registering my panel that triggers the user extensions to be added to the addon

@ronh991 ronh991 closed this as completed May 28, 2024
@ronh991 ronh991 reopened this May 28, 2024
@ronh991
Copy link
Author

ronh991 commented May 28, 2024

It seems there was a removal of the GLTF_PT_export_user_extensions panel class

@julienduroure
Copy link
Collaborator

Ah, yes, confirmed.

@julienduroure julienduroure added the bug Something isn't working label May 28, 2024
@julienduroure
Copy link
Collaborator

There is no more panel Classes for UI, Blender changed that, and it seems we forgot to update / find a solution for user extension.
Investigation in progress

@julienduroure
Copy link
Collaborator

Hello,
Blender changes will need you to update all your user extension addon UI.
You can see example addon to know how to update:

Your addon will also need a manifest file to be able to be installed.

@ronh991
Copy link
Author

ronh991 commented May 30, 2024

thanks, appreciate the quick response to this issue. Will work on the fix. I have the addon working with the toml manifest file already, just needed your update.

@eoineoineoin
Copy link
Member

Have noticed a few problems with the draw() method in user extensions:

The header.props(props, 'enabled') adds a bunch of whitespace which looks bad and makes the labels hard to read
2024-07-26_10-26

If the panel is collapsed, the line:

header, body = layout.panel("GLTF_addon_example_importer", default_closed=False)

Will return body=None, which breaks the example plugins. The following is printed to the console:

AttributeError: 'NoneType' object has no attribute 'active'
Traceback (most recent call last):
  File "/usr/share/blender/4.2/scripts/addons_core/io_scene_gltf2/__init__.py", line 1318, in draw
    export_panel_user_extension(context, layout)
  File "/usr/share/blender/4.2/scripts/addons_core/io_scene_gltf2/__init__.py", line 1715, in export_panel_user_extension
    draw(context, layout)
  File "/home/eoin/.config/blender/4.2/scripts/addons/example_gltf_exporter_extension/__init__.py", line 54, in draw
    body.active = props.enabled
    ^^^^^^^^^^^

Probably, the draw() needs to read:

def draw(context, layout):
    header, body = layout.panel("GLTF_addon_example_exporter", default_closed=False)

    props = bpy.context.scene.ExampleExtensionProperties

    header.prop(props, 'enabled')
    if body != None:
        body.prop(props, 'float_property', text="Some float value")

Finally, the method for extracting the draw() method is not great; if an addon provides a gltf2ImportUserExtension, the modules' draw() is registered in importer_extension_layout_draw:

if hasattr(sys.modules[addon_name], 'glTF2ImportUserExtension') or hasattr(sys.modules[addon_name], 'glTF2ImportUserExtensions'):

Similarly, if a module provides a gltf2ExportUserExtension, the same draw() function is registered in exporter_extension_layout_draw:

if hasattr(sys.modules[addon_name], 'glTF2ExportUserExtension') or hasattr(sys.modules[addon_name], 'glTF2ExportUserExtensions'):
)

However, if an addon provides both an importer and an exporter, then there's no way to determine what you should be drawing, so both the import and export options will show up in both the import and export windows.

@marwie
Copy link

marwie commented Aug 9, 2024

We have the same issue regarding the UI showing up in import AND export. Having a way to determine which window is open would help a lot

@julienduroure
Copy link
Collaborator

Hello,
Thanks.
Right, we have to fix that!
I will have a look soon

@julienduroure
Copy link
Collaborator

Hello,

I propose to split the "draw" method into "draw_import" and "draw_export".
A fallback is kept for "draw", that will be displayed for both.
Please check #2313
I plan to merge it soon

@julienduroure
Copy link
Collaborator

Any feedback before I merge it?
@marwie @eoineoineoin @ronh991

@marwie
Copy link

marwie commented Sep 3, 2024

I was just thinking if the info should be inside a third parameter instead of extra functions (some context object) but I'm not sure if this would have any benefit. draw_import and export is very explicit which is good!

@eoineoineoin
Copy link
Member

Looks good to me, thanks!

julienduroure added a commit that referenced this issue Sep 12, 2024
Fix #2253 - distinct import & export draw
julienduroure added a commit that referenced this issue Sep 26, 2024
Fix #2253 - distinct import & export draw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants