The aim of the question is to calculate a node tree layout for a generated node tree.
It seems that
dimensions corresponds to some default size and that
width to the currently displayed dimensions. But these last two are not set until the node is effectively displayed somewhere in the editor (or am I wrong?).
But if you want to generate a node layout for a material or a node tree which is itself generated and which is not displayed for now, is it possible to get the
dimensions? If yes, how?
to force a layout calculation. But this works only when the node tree is displayed in the Node Editor (at least it seems to be the case).
How can we get the 'future' default dimensions so that a node tree layout could be calculated?
Edit: Some extra details
When creating a node tree, it is not displayed until it is used (instantiated) in a material and opened for editing.
In this case,
heightare some default values: 140 and 100
I've experimented and found that these values are updated when the node is displayed (and
bpy.ops.wm.redraw() is called). So that typically, the Principled and Diffuse shader nodes do not end up having the same dimensions.
But before that, the dimension values are as given above.
The complete code is hard to share here, but here are some basic snippets:
Creating a node tree (node group) is:
node_group = node_groups.new( node_group_name, 'ShaderNodeTree' )
Creating a material is:
material = materials.new( material_name )
Creating a node in both cases:
self.internal_node = node_tree_nodes.new( type = self.name )
But once the data is created, there are two cases:
The node tree is displayed in a view and
can be use to 'force' a layout update and get the dimensions (if this
bpy.ops is not called
dimensions are not updated).
Or the node tree (
bpy.data.node_groups typically) is not displayed and I can't find a way to retrieve the 'future displayed' dimensions.