forked from BrendanParmer/NodeToPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.py
More file actions
220 lines (207 loc) · 8.19 KB
/
Copy pathoptions.py
File metadata and controls
220 lines (207 loc) · 8.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import bpy
class NTPOptions(bpy.types.PropertyGroup):
"""
Property group used during conversion of node group to python
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# General properties
mode: bpy.props.EnumProperty(
name = "Mode",
items = [
('SCRIPT', "Script", "Copy just the node group to the Blender clipboard"),
('ADDON', "Addon", "Create a full add-on")
]
)
include_group_socket_values : bpy.props.BoolProperty(
name = "Include group socket values",
description = "Generate group socket default, min, and max values",
default = True
)
set_dimensions : bpy.props.BoolProperty(
name = "Set dimensions",
description = "Set dimensions of generated nodes",
default = True
)
indentation_type: bpy.props.EnumProperty(
name="Indentation Type",
description="Whitespace to use for each indentation block",
items = [
('SPACES_2', "2 Spaces", ""),
('SPACES_4', "4 Spaces", ""),
('SPACES_8', "8 Spaces", ""),
('TABS', "Tabs", "")
],
default = 'SPACES_4'
)
if bpy.app.version >= (3, 4, 0):
set_unavailable_defaults : bpy.props.BoolProperty(
name = "Set unavailable defaults",
description = "Set default values for unavailable sockets",
default = False
)
#Script properties
include_imports : bpy.props.BoolProperty(
name = "Include imports",
description="Generate necessary import statements",
default = True
)
# Addon properties
dir_path : bpy.props.StringProperty(
name = "Save Location",
subtype='DIR_PATH',
description="Save location if generating an add-on",
default = "//"
)
name_override : bpy.props.StringProperty(
name = "Name Override",
description="Name used for the add-on's, default is node group name",
default = ""
)
description : bpy.props.StringProperty(
name = "Description",
description="Description used for the add-on",
default=""
)
author_name : bpy.props.StringProperty(
name = "Author",
description = "Name used for the author/maintainer of the add-on",
default = "Node To Python"
)
version: bpy.props.IntVectorProperty(
name = "Version",
description="Version of the add-on",
default = (1, 0, 0)
)
location: bpy.props.StringProperty(
name = "Location",
description="Location of the addon",
default="Node"
)
menu_id: bpy.props.StringProperty(
name = "Menu ID",
description = "Python ID of the menu you'd like to register the add-on "
"to. You can find this by enabling Python tooltips "
"(Preferences > Interface > Python tooltips) and "
"hovering over the desired menu",
default="NODE_MT_add"
)
license: bpy.props.EnumProperty(
name="License",
items = [
('SPDX:GPL-2.0-or-later', "GNU General Public License v2.0 or later", ""),
('SPDX:GPL-3.0-or-later', "GNU General Public License v3.0 or later", ""),
('SPDX:LGPL-2.1-or-later', "GNU Lesser General Public License v2.1 or later", ""),
('SPDX:LGPL-3.0-or-later', "GNU Lesser General Public License v3.0 or later", ""),
('SPDX:BSD-1-Clause', "BSD 1-Clause \"Simplified\" License", ""),
('SPDX:BSD-2-Clause', "BSD 2-Clause \"Simplified\" License", ""),
('SPDX:BSD-3-Clause', "BSD 3-Clause \"New\" or \"Revised\" License", ""),
('SPDX:BSL-1.0', "Boost Software License 1.0", ""),
('SPDX:MIT', "MIT License", ""),
('SPDX:MIT-0', "MIT No Attribution", ""),
('SPDX:MPL-2.0', "Mozilla Public License 2.0", ""),
('SPDX:Pixar', "Pixar License", ""),
('SPDX:Zlib', "Zlib License", ""),
('OTHER', "Other", "User is responsible for including the license "
"and adding it to the manifest.\n"
"Please note that by using the Blender Python "
"API your add-on must comply with the GNU GPL. "
"See https://www.blender.org/about/license/ for "
"more details")
],
default = 'SPDX:GPL-3.0-or-later'
)
should_create_license: bpy.props.BoolProperty(
name="Create License",
description="Should NodeToPython include a license file",
default=True
)
category: bpy.props.EnumProperty(
name = "Category",
items = [
('Custom', "Custom", "Use an unofficial category"),
('3D View', "3D View", ""),
('Add Curve', "Add Curve", ""),
('Add Mesh', "Add Mesh", ""),
('Animation', "Animation", ""),
('Bake', "Bake", ""),
('Compositing', "Compositing", ""),
('Development', "Development", ""),
('Game Engine', "Game Engine", ""),
('Geometry Nodes', "Geometry Nodes", ""),
("Grease Pencil", "Grease Pencil", ""),
('Import-Export', "Import-Export", ""),
('Lighting', "Lighting", ""),
('Material', "Material", ""),
('Mesh', "Mesh", ""),
('Modeling', "Modeling", ""),
('Node', "Node", ""),
('Object', "Object", ""),
('Paint', "Paint", ""),
('Pipeline', "Pipeline", ""),
('Physics', "Physics", ""),
('Render', "Render", ""),
('Rigging', "Rigging", ""),
('Scene', "Scene", ""),
('Sculpt', "Sculpt", ""),
('Sequencer', "Sequencer", ""),
('System', "System", ""),
('Text Editor', "Text Editor", ""),
('Tracking', "Tracking", ""),
('UV', "UV", ""),
('User Interface', "User Interface", ""),
],
default = 'Node'
)
custom_category: bpy.props.StringProperty(
name="Custom Category",
description="Custom category",
default = ""
)
class NTPOptionsPanel(bpy.types.Panel):
bl_label = "Options"
bl_idname = "NODE_PT_ntp_options"
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
bl_context = ''
bl_category = "NodeToPython"
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@classmethod
def poll(cls, context):
return True
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
ntp_options = context.scene.ntp_options
option_list = [
"mode",
"include_group_socket_values",
"set_dimensions",
"indentation_type"
]
if bpy.app.version >= (3, 4, 0):
option_list.append("set_unavailable_defaults")
if ntp_options.mode == 'SCRIPT':
script_options = [
"include_imports"
]
option_list += script_options
elif ntp_options.mode == 'ADDON':
addon_options = [
"dir_path",
"name_override",
"description",
"author_name",
"version",
"location",
"menu_id",
"license",
"should_create_license",
"category"
]
option_list += addon_options
if ntp_options.category == 'CUSTOM':
option_list.append("custom_category")
for option in option_list:
layout.prop(ntp_options, option)