Open strutcode opened 10 months ago
~Just hit @strutcode's issue. Is there some reason this isn't exposed? Else we can just add it no?~
get_editor_interface().get_selection().get_selected_nodes() allows to workaround. Not an ideal interface but workable.
Describe the project you are working on
An editor addon for better/nicer bulk editing of nodes using the property inspector
Describe the problem or limitation you are having in your project
Referencing previous proposal that was voluntarily closed: #6884
When called with multiple selected objects, an
EditorProperty
'sget_edited_object()
will return aMultiNodeEdit
instance. This works fine for the most basic case where you simply want to set a property across all objects as it seems to act as a proxy for setting/getting properties.However, this becomes quite counter-intuitive and challenging when you want to do more than simply get or set properties. The first hurdle is that MultiNodeEdit isn't a valid class for scripting:
if get_edited_object() is MultiNodeEdit: # Error: Could not find type "MultiNodeEdit" in current scope.
This one can be cleared by a somewhat ugly workaround:
if get_edited_object().get_class() == "MultiNodeEdit":
However if you next want to access the objects in question, it becomes impossible through the interface given even though it's available in the source.
get_edited_object().has_method("get_node_count") # false
get_edited_object().get_node(0) # error
Describe the feature / enhancement and how it helps to overcome the problem or limitation
It seems fairly obvious to me that since it's already exposed to scripts indirectly, this class and some of its methods should be exposed directly with documentation so that users can understand its purpose and why they've received one as a parameter.
Additionally, I don't see a good reason not to expose the already existent
get_node_count()
andget_node(index)
methods on the object so that users can intuit how to perform more advanced operations on these nodes than simply getting and setting properties.There's a possibility of also exposing
add_node
but I think it should go along with aremove_node
or similar so my intent is to keep the scope read only here.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
MultiNodeEdit
to the types exposed inregister_editor_types.cpp
get_node_count
andget_node
methods inmulti_node_edit.cpp
If this enhancement will not be used often, can it be worked around with a few lines of script?
Perhaps, but I wasn't able to find any way to do so.
Is there a reason why this should be core and not an add-on in the asset library?
This is primarily a tool to aid the development of add-ons, so a core change is likely the only path.