How to set the position of a node manually?
-
Dear people,
Is there a chance I use a custom value to set the position (location)
of a node I create with Python manually inside Graph Editor? Like use a custom value for X and Y of a Texture node. -
Hey @momoko,
Thank you for reaching out to us. Doing that, setting the position of a node, is not possible. You must rely on the auto layout which kicks in once you have finished your transaction.
Internally, nodes follow a three-tier-architecture, specfically the MVP Pattern. When you do operations on a
maxon.NodeGraphModelRef
ormaxon.GraphModelRef
you are operating on the model, i.e., data, part of that three-tier architecture. The view is the Node Editor and the presenter is a type calledGraphModelPresenter
, they handle in tandem how the data/model layer is displayed and interfacts with user inputs. Or in other words: everything GUI related where you do not have an attribute or a port in a graph node for is not possible to manipulate from the model level.You can fold and unfold nodes, hide and show their preview image because each node has an attribute for that as shown in the Node Editor. But you cannot set the position of a node or if a port bundle is unfolded or not. You would need the presenter for that, which is neither public in Python nor C++.
But the auto-layouter usually does its job nicely
Cheers,
Ferdinand -
@ferdinand Thank you. I thought that would be possible because Blender was providing that.
-
Hey @momoko,
I understood why you asked, as this is common thing to do. Even for our own other node system, Xpresso aka
GraphView
, doing this is possible in the API. I just provided an explanation as to why the Nodes Team did it like this and why they very likely will never change that (as it would break their design pattern). So that you and future readers can understand why we do this instead of just being confronted with a blunt "no"Cheers,
Ferdinand