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

Tooltips of Add node operator in Blender 3.3 #4700

Closed
Durman opened this issue Oct 7, 2022 · 6 comments · Fixed by #4703
Closed

Tooltips of Add node operator in Blender 3.3 #4700

Durman opened this issue Oct 7, 2022 · 6 comments · Fixed by #4703

Comments

@Durman
Copy link
Collaborator

Durman commented Oct 7, 2022

Problem statement

Blender 3.3 silently added description class method for AddNodeOperator - https://developer.blender.org/D14963 https://developer.blender.org/T101657

Now it overrides our approach of adding tooltips. It's a coincidence that we did not loos tooltips completely because their approach is similar, it also uses node doc strings.

Our current approach is a class factory of AddNodeOperator subclasses for each node item in the menu.

sverchok/menu.py

Lines 256 to 264 in b5a8ebc

SverchNodeAddOperator.__name__ = node_class.__name__
if hasattr(node_class, "docstring"):
SverchNodeAddOperator.__doc__ = node_class.docstring.get_tooltip()
else:
SverchNodeAddOperator.__doc__ = node_class.__doc__
node_add_operators[self.get_idname()] = SverchNodeAddOperator
bpy.utils.register_class(SverchNodeAddOperator)

With the new feature we have opportunity to simplify our solution and replace the factory wit single Add operator. The question is about backward compatibility. I see 3 ways to go:

  • Add description method to our current approach. It's simplest solution and backward compatible but it want make our approach simpler.
  • Rewrite our current approach. It's more complicated, backward incompatible but it will simplify the menu code. And probably it's not a big deal to drop the feature in 3.2 3.1. 3.0 and 2.93 Blender versions.
  • Add separate solution for Blender 3.3 and higer. It's most complicated but backward compatible.
@Durman
Copy link
Collaborator Author

Durman commented Oct 7, 2022

By the way it seems this code does not work at all, at least commenting it does not break nothing.

sverchok/menu.py

Lines 273 to 282 in b5a8ebc

@staticmethod
def draw(self, layout, context):
add = draw_add_node_operator(layout, self.nodetype, label=self._label)
if add is None:
return
for setting in self.settings.items():
ops = add.settings.add()
ops.name = setting[0]
ops.value = setting[1]

@portnov
Copy link
Collaborator

portnov commented Oct 7, 2022

Can we preserve backward compatibility for a while, and plan a rewrite when, for example, 3.2 goes end-of-support?

@portnov
Copy link
Collaborator

portnov commented Oct 7, 2022

Also, I like the solution with separate Operator for each node, because with it you can easily search for nodes with standard Blender's F3 menu...

@zeffii
Copy link
Collaborator

zeffii commented Oct 8, 2022

@portnov what advantage does the F3 menu have?

@portnov
Copy link
Collaborator

portnov commented Oct 8, 2022

That everything is in one menu? You just type what you want and that's all.
Also, this is the standard way of invoking commands in Blender, so you do not have to remember another shortcut.

@Durman
Copy link
Collaborator Author

Durman commented Oct 8, 2022

I guess GN uses single operator for adding all nodes and it's still possible to add separate nodes. Maby the same is possible to implement in Sverchok somehow.

image

bpy.ops.node.add_node(type="GeometryNodeAttributeStatistic", use_transform=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants