Skip to content

Commit e583e68

Browse files
Merge pull request #163 from BrendanParmer/v3.5
NodeToPython v3.5
2 parents 4412ce9 + 63aba42 commit e583e68

File tree

13 files changed

+1947
-2104
lines changed

13 files changed

+1947
-2104
lines changed

LICENSE

Lines changed: 674 additions & 21 deletions
Large diffs are not rendered by default.

NodeToPython/LICENSE

Lines changed: 674 additions & 21 deletions
Large diffs are not rendered by default.

NodeToPython/OLD_LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2024 Brendan Parmer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NodeToPython/blender_manifest.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version = "1.0.0"
22

33
id = "node_to_python"
4-
version = "3.4.0"
4+
version = "3.5.0"
55
name = "Node To Python"
66
tagline = "Turn node groups into Python code"
77
maintainer = "Brendan Parmer <[email protected]>"
@@ -12,11 +12,10 @@ website = "https://github.com/BrendanParmer/NodeToPython"
1212
tags = ["Development", "Compositing", "Geometry Nodes", "Material", "Node"]
1313

1414
blender_version_min = "4.2.0"
15-
blender_version_max = "4.5.0"
1615

1716
license = [
18-
"SPDX:MIT",
17+
"SPDX:GPL-3.0-or-later",
1918
]
2019

2120
[permissions]
22-
files = "Creates and writes to files in a specified directory"
21+
files = "Creates and writes to files in a user-specified directory"

NodeToPython/compositor/operator.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -93,45 +93,46 @@ def _initialize_compositor_node_tree(self, ntp_nt, nt_name):
9393
self._write(f"{ntp_nt.var}.{bool_setting} = True")
9494

9595

96-
def _set_color_balance_settings(self, node: CompositorNodeColorBalance
97-
) -> None:
98-
"""
99-
Sets the color balance settings so we only set the active variables,
100-
preventing conflict
101-
102-
node (CompositorNodeColorBalance): the color balance node
103-
"""
104-
if node.correction_method == 'LIFT_GAMMA_GAIN':
105-
lst = [NTPNodeSetting("correction_method", ST.ENUM),
106-
NTPNodeSetting("gain", ST.VEC3, max_version_=(3, 5, 0)),
107-
NTPNodeSetting("gain", ST.COLOR, min_version_=(3, 5, 0)),
108-
NTPNodeSetting("gamma", ST.VEC3, max_version_=(3, 5, 0)),
109-
NTPNodeSetting("gamma", ST.COLOR, min_version_=(3, 5, 0)),
110-
NTPNodeSetting("lift", ST.VEC3, max_version_=(3, 5, 0)),
111-
NTPNodeSetting("lift", ST.COLOR, min_version_=(3, 5, 0))]
112-
elif node.correction_method == 'OFFSET_POWER_SLOPE':
113-
lst = [NTPNodeSetting("correction_method", ST.ENUM),
114-
NTPNodeSetting("offset", ST.VEC3, max_version_=(3, 5, 0)),
115-
NTPNodeSetting("offset", ST.COLOR, min_version_=(3, 5, 0)),
116-
NTPNodeSetting("offset_basis", ST.FLOAT),
117-
NTPNodeSetting("power", ST.VEC3, max_version_=(3, 5, 0)),
118-
NTPNodeSetting("power", ST.COLOR, min_version_=(3, 5, 0)),
119-
NTPNodeSetting("slope", ST.VEC3, max_version_=(3, 5, 0)),
120-
NTPNodeSetting("slope", ST.COLOR, min_version_=(3, 5, 0))]
121-
elif node.correction_method == 'WHITEPOINT':
122-
lst = [NTPNodeSetting("correction_method", ST.ENUM),
123-
NTPNodeSetting("input_temperature", ST.FLOAT),
124-
NTPNodeSetting("input_tint", ST.FLOAT),
125-
NTPNodeSetting("output_temperature", ST.FLOAT),
126-
NTPNodeSetting("output_tint", ST.FLOAT)]
127-
else:
128-
self.report({'ERROR'},
129-
f"Unknown color balance correction method "
130-
f"{enum_to_py_str(node.correction_method)}")
131-
return
132-
133-
color_balance_info = self._node_infos['CompositorNodeColorBalance']
134-
self._node_infos['CompositorNodeColorBalance'] = color_balance_info._replace(attributes_ = lst)
96+
if bpy.app.version < (4, 5, 0):
97+
def _set_color_balance_settings(self, node: CompositorNodeColorBalance
98+
) -> None:
99+
"""
100+
Sets the color balance settings so we only set the active variables,
101+
preventing conflict
102+
103+
node (CompositorNodeColorBalance): the color balance node
104+
"""
105+
if node.correction_method == 'LIFT_GAMMA_GAIN':
106+
lst = [NTPNodeSetting("correction_method", ST.ENUM),
107+
NTPNodeSetting("gain", ST.VEC3, max_version_=(3, 5, 0)),
108+
NTPNodeSetting("gain", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0)),
109+
NTPNodeSetting("gamma", ST.VEC3, max_version_=(3, 5, 0)),
110+
NTPNodeSetting("gamma", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0)),
111+
NTPNodeSetting("lift", ST.VEC3, max_version_=(3, 5, 0)),
112+
NTPNodeSetting("lift", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0))]
113+
elif node.correction_method == 'OFFSET_POWER_SLOPE':
114+
lst = [NTPNodeSetting("correction_method", ST.ENUM),
115+
NTPNodeSetting("offset", ST.VEC3, max_version_=(3, 5, 0)),
116+
NTPNodeSetting("offset", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0)),
117+
NTPNodeSetting("offset_basis", ST.FLOAT),
118+
NTPNodeSetting("power", ST.VEC3, max_version_=(3, 5, 0)),
119+
NTPNodeSetting("power", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0)),
120+
NTPNodeSetting("slope", ST.VEC3, max_version_=(3, 5, 0)),
121+
NTPNodeSetting("slope", ST.COLOR, min_version_=(3, 5, 0), max_version_=(4, 5, 0))]
122+
elif node.correction_method == 'WHITEPOINT':
123+
lst = [NTPNodeSetting("correction_method", ST.ENUM, max_version_=(4, 5, 0)),
124+
NTPNodeSetting("input_temperature", ST.FLOAT, max_version_=(4, 5, 0)),
125+
NTPNodeSetting("input_tint", ST.FLOAT, max_version_=(4, 5, 0)),
126+
NTPNodeSetting("output_temperature", ST.FLOAT, max_version_=(4, 5, 0)),
127+
NTPNodeSetting("output_tint", ST.FLOAT, max_version_=(4, 5, 0))]
128+
else:
129+
self.report({'ERROR'},
130+
f"Unknown color balance correction method "
131+
f"{enum_to_py_str(node.correction_method)}")
132+
return
133+
134+
color_balance_info = self._node_infos['CompositorNodeColorBalance']
135+
self._node_infos['CompositorNodeColorBalance'] = color_balance_info._replace(attributes_ = lst)
135136

136137
def _process_node(self, node: Node, ntp_nt: NTP_NodeTree):
137138
"""
@@ -143,8 +144,9 @@ def _process_node(self, node: Node, ntp_nt: NTP_NodeTree):
143144
"""
144145
node_var: str = self._create_node(node, ntp_nt.var)
145146

146-
if node.bl_idname == 'CompositorNodeColorBalance':
147-
self._set_color_balance_settings(node)
147+
if bpy.app.version < (4, 5, 0):
148+
if node.bl_idname == 'CompositorNodeColorBalance':
149+
self._set_color_balance_settings(node)
148150

149151
self._set_settings_defaults(node)
150152
self._hide_hidden_sockets(node)

0 commit comments

Comments
 (0)