Skip to content

Commit

Permalink
Merge pull request #99 from BrendanParmer/LinkOrdering
Browse files Browse the repository at this point in the history
Link ordering
  • Loading branch information
BrendanParmer committed Mar 17, 2024
2 parents 824aea9 + 0e6e68c commit e467dc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion geometry/node_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,9 @@
],

'FunctionNodeRotateEuler' : [
NTPNodeSetting("rotation_type", ST.ENUM, min_version = (4, 1, 0)),
NTPNodeSetting("space", ST.ENUM),
NTPNodeSetting("type", ST.ENUM)
NTPNodeSetting("type", ST.ENUM, max_version = (4, 1, 0))
],

'FunctionNodeRotateVector' : [],
Expand Down
14 changes: 12 additions & 2 deletions ntp_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def _create_node(self, node: Node, node_tree_var: str) -> str:
if node.mute:
self._write(f"{node_var}.mute = True")

# hide
if node.hide:
self._write(f"{node_var}.hide = True")
return node_var

def _set_settings_defaults(self, node: Node) -> None:
Expand All @@ -292,14 +295,18 @@ def _set_settings_defaults(self, node: Node) -> None:
attr_name = setting.name
st = setting.st

is_version_valid = (bpy.app.version >= setting.min_version and
bpy.app.version < setting.max_version)
if not hasattr(node, attr_name):
if (bpy.app.version >= setting.min_version and
bpy.app.version < setting.max_version):
if is_version_valid:
self.report({'WARNING'},
f"NodeToPython: Couldn't find attribute "
f"\"{attr_name}\" for node {node.name} of type "
f"{node.bl_idname}")
continue
elif not is_version_valid:
continue

attr = getattr(node, attr_name, None)
if attr is None:
continue
Expand Down Expand Up @@ -1168,6 +1175,9 @@ def _init_links(self, node_tree: NodeTree) -> None:
links = node_tree.links
if links:
self._write(f"#initialize {nt_var} links")
if hasattr(links[0], "multi_input_sort_id"):
# generate links in the correct order for multi input sockets
links = sorted(links, key=lambda link: link.multi_input_sort_id)

for link in links:
in_node_var = self._node_vars[link.from_node]
Expand Down

0 comments on commit e467dc8

Please sign in to comment.