9
9
10
10
# Here are load and delete operations
11
11
class SIMLOADER_OT_load (bpy .types .Operator ):
12
- '''
13
- This operator loads a sequnce
14
- '''
15
- bl_label = "Load Sequences"
12
+ '''This operator loads a sequnce'''
13
+ bl_label = "Load Sequence"
16
14
bl_idname = "sequence.load"
17
15
bl_options = {"UNDO" }
18
16
@@ -48,9 +46,7 @@ def execute(self, context):
48
46
49
47
50
48
class SIMLOADER_OT_edit (bpy .types .Operator ):
51
- '''
52
- This operator changes a sequnce
53
- '''
49
+ '''This operator changes a sequnce'''
54
50
bl_label = "Edit Sequences Path"
55
51
bl_idname = "sequence.edit"
56
52
bl_options = {"UNDO" }
@@ -76,7 +72,6 @@ def execute(self, context):
76
72
return {"CANCELLED" }
77
73
fs = importer_prop .path + '/' + importer_prop .pattern
78
74
79
-
80
75
try :
81
76
fs = fileseq .findSequenceOnDisk (fs )
82
77
except Exception as e :
@@ -96,22 +91,27 @@ def execute(self, context):
96
91
return {"FINISHED" }
97
92
98
93
99
-
100
94
class SIMLOADER_OT_resetpt (bpy .types .Operator ):
101
- '''
102
- This operator reset the geometry nodes of the sequence as a point cloud
103
- '''
95
+ '''This operator reset the geometry nodes of the sequence as a point cloud'''
104
96
bl_label = "Reset Geometry Nodes as Point Cloud"
105
97
bl_idname = "simloader.resetpt"
106
98
bl_options = {"UNDO" }
107
99
108
100
def execute (self , context ):
109
101
sim_loader = context .scene .SIMLOADER
110
102
obj = bpy .data .objects [sim_loader .selected_obj_num ]
103
+ warn = False
111
104
for modifier in obj .modifiers :
112
105
if modifier .type == "NODES" :
106
+ warn = True
113
107
obj .modifiers .remove (modifier )
108
+ if warn :
109
+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
114
110
gn = obj .modifiers .new ("SIMLOADER_GeometryNodse" , "NODES" )
111
+ # change starting from blender 3.2
112
+ # https://developer.blender.org/rB08b4b657b64f
113
+ if bpy .app .version >= (3 ,2 ,0 ):
114
+ bpy .ops .node .new_geometry_node_group_assign ()
115
115
gn .node_group .nodes .new ('GeometryNodeMeshToPoints' )
116
116
set_material = gn .node_group .nodes .new ('GeometryNodeSetMaterial' )
117
117
set_material .inputs [2 ].default_value = context .scene .SIMLOADER .material
@@ -127,88 +127,103 @@ def execute(self, context):
127
127
128
128
129
129
class SIMLOADER_OT_resetmesh (bpy .types .Operator ):
130
- '''
131
- This operator reset the geometry nodes of the sequence as a point cloud
132
- '''
130
+ '''This operator reset the geometry nodes of the sequence as a point cloud'''
133
131
bl_label = "Reset Geometry Nodes as Mesh"
134
132
bl_idname = "simloader.resetmesh"
135
133
bl_options = {"UNDO" }
136
134
137
135
def execute (self , context ):
138
136
sim_loader = context .scene .SIMLOADER
139
137
obj = bpy .data .objects [sim_loader .selected_obj_num ]
138
+ warn = False
140
139
for modifier in obj .modifiers :
141
140
if modifier .type == "NODES" :
141
+ warn = True
142
142
obj .modifiers .remove (modifier )
143
+ if warn :
144
+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
143
145
gn = obj .modifiers .new ("SIMLOADER_GeometryNodse" , "NODES" )
146
+ # change starting from blender 3.2
147
+ # https://developer.blender.org/rB08b4b657b64f
148
+ if bpy .app .version >= (3 ,2 ,0 ):
149
+ bpy .ops .node .new_geometry_node_group_assign ()
144
150
bpy .ops .object .modifier_move_to_index (modifier = gn .name , index = 0 )
145
151
return {"FINISHED" }
146
152
147
153
148
154
class SIMLOADER_OT_resetins (bpy .types .Operator ):
149
- '''
150
- This operator reset the geometry nodes of the sequence as a point cloud
151
- '''
155
+ '''This operator reset the geometry nodes of the sequence as a point cloud'''
152
156
bl_label = "Reset Geometry Nodes as Instances"
153
157
bl_idname = "simloader.resetins"
154
158
bl_options = {"UNDO" }
155
159
156
160
def execute (self , context ):
157
161
sim_loader = context .scene .SIMLOADER
158
162
obj = bpy .data .objects [sim_loader .selected_obj_num ]
163
+ warn = False
159
164
for modifier in obj .modifiers :
160
165
if modifier .type == "NODES" :
166
+ warn = True
161
167
obj .modifiers .remove (modifier )
168
+ if warn :
169
+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
162
170
gn = obj .modifiers .new ("SIMLOADER_GeometryNodse" , "NODES" )
171
+ # change starting from blender 3.2
172
+ # https://developer.blender.org/rB08b4b657b64f
173
+ if bpy .app .version >= (3 ,2 ,0 ):
174
+ bpy .ops .node .new_geometry_node_group_assign ()
163
175
nodes = gn .node_group .nodes
164
176
links = gn .node_group .links
165
- input_node = nodes [0 ]
166
- output_node = nodes [1 ]
177
+ input_node = nodes [0 ]
178
+ output_node = nodes [1 ]
167
179
168
180
instance_on_points = nodes .new ('GeometryNodeInstanceOnPoints' )
169
181
cube = nodes .new ('GeometryNodeMeshCube' )
170
182
realize_instance = nodes .new ('GeometryNodeRealizeInstances' )
171
183
set_material = nodes .new ('GeometryNodeSetMaterial' )
172
184
173
- instance_on_points .inputs ['Scale' ].default_value = [0.05 ,0.05 ,0.05 ,]
185
+ instance_on_points .inputs ['Scale' ].default_value = [
186
+ 0.05 ,
187
+ 0.05 ,
188
+ 0.05 ,
189
+ ]
174
190
set_material .inputs [2 ].default_value = context .scene .SIMLOADER .material
175
191
176
-
177
- links .new (input_node .outputs [0 ],instance_on_points .inputs ['Points' ])
178
- links .new (cube .outputs [0 ],instance_on_points .inputs ['Instance' ])
179
- links .new (instance_on_points .outputs [0 ],realize_instance .inputs [0 ])
180
- links .new (realize_instance .outputs [0 ],set_material .inputs [0 ])
181
- links .new (set_material .outputs [0 ],output_node .inputs [0 ])
192
+ links .new (input_node .outputs [0 ], instance_on_points .inputs ['Points' ])
193
+ links .new (cube .outputs [0 ], instance_on_points .inputs ['Instance' ])
194
+ links .new (instance_on_points .outputs [0 ], realize_instance .inputs [0 ])
195
+ links .new (realize_instance .outputs [0 ], set_material .inputs [0 ])
196
+ links .new (set_material .outputs [0 ], output_node .inputs [0 ])
182
197
183
198
bpy .ops .object .modifier_move_to_index (modifier = gn .name , index = 0 )
184
199
return {"FINISHED" }
185
200
201
+
186
202
class SIMLOADER_OT_set_as_split_norm (bpy .types .Operator ):
187
- '''
188
- This operator set the vertex attribute as vertex split normals
189
- '''
190
- bl_label = "Set as Split Norm per Vertex"
203
+ '''This operator set the vertex attribute as vertex split normals'''
204
+ bl_label = "Set as split normal per Vertex"
191
205
bl_idname = "simloader.setsplitnorm"
192
206
bl_options = {"UNDO" }
207
+
193
208
def execute (self , context ):
194
209
sim_loader = context .scene .SIMLOADER
195
210
obj = bpy .data .objects [sim_loader .selected_obj_num ]
196
211
mesh = obj .data
197
212
attr_index = sim_loader .selected_attribute_num
198
- if attr_index >= len (mesh .attributes ):
213
+ if attr_index >= len (mesh .attributes ):
199
214
show_message_box ("Please select the attribute" )
200
215
return {"CANCELLED" }
201
216
mesh .SIMLOADER .split_norm_att_name = mesh .attributes [attr_index ].name
202
217
203
218
return {"FINISHED" }
204
219
220
+
205
221
class SIMLOADER_OT_remove_split_norm (bpy .types .Operator ):
206
- '''
207
- This operator remove the vertex attribute as vertex split normals
208
- '''
209
- bl_label = "Remove Split Norm per Vertex"
222
+ '''This operator remove the vertex attribute as vertex split normals'''
223
+ bl_label = "Remove split normal per Vertex"
210
224
bl_idname = "simloader.removesplitnorm"
211
225
bl_options = {"UNDO" }
226
+
212
227
def execute (self , context ):
213
228
sim_loader = context .scene .SIMLOADER
214
229
obj = bpy .data .objects [sim_loader .selected_obj_num ]
@@ -220,12 +235,11 @@ def execute(self, context):
220
235
221
236
222
237
class SIMLOADER_OT_disable_selected (bpy .types .Operator ):
223
- '''
224
- This operator disable all selected sequence
225
- '''
238
+ '''This operator disable all selected sequence'''
226
239
bl_label = "Disable Selected Sequence"
227
240
bl_idname = "simloader.disableselected"
228
241
bl_options = {"UNDO" }
242
+
229
243
def execute (self , context ):
230
244
for obj in bpy .context .selected_objects :
231
245
if obj .SIMLOADER .init and obj .SIMLOADER .enabled :
@@ -234,40 +248,35 @@ def execute(self, context):
234
248
235
249
236
250
class SIMLOADER_OT_enable_selected (bpy .types .Operator ):
237
- '''
238
- This operator enable all selected sequence
239
- '''
251
+ '''This operator enable all selected sequence'''
240
252
bl_label = "Enable Selected Sequence"
241
253
bl_idname = "simloader.enableselected"
242
254
bl_options = {"UNDO" }
255
+
243
256
def execute (self , context ):
244
257
for obj in bpy .context .selected_objects :
245
258
if obj .SIMLOADER .init and not obj .SIMLOADER .enabled :
246
259
obj .SIMLOADER .enabled = True
247
260
return {"FINISHED" }
248
261
249
262
250
-
251
263
class SIMLOADER_OT_refresh_seq (bpy .types .Operator ):
252
- '''
253
- This operator refresh the sequence
254
- '''
264
+ '''This operator refresh the sequence'''
255
265
bl_label = "Refresh Sequence"
256
266
bl_idname = "simloader.refresh"
267
+
257
268
def execute (self , context ):
258
269
scene = context .scene
259
270
obj = bpy .data .objects [scene .SIMLOADER .selected_obj_num ]
260
271
261
-
262
272
fs = obj .SIMLOADER .pattern
263
273
if obj .SIMLOADER .use_relative :
264
274
fs = bpy .path .abspath (fs )
265
275
fs = fileseq .findSequenceOnDisk (fs )
266
- fs = fileseq .findSequenceOnDisk (fs .dirname ()+ fs .basename () + "@" + fs .extension ())
276
+ fs = fileseq .findSequenceOnDisk (fs .dirname () + fs .basename () + "@" + fs .extension ())
267
277
fs = str (fs )
268
278
if obj .SIMLOADER .use_relative :
269
279
fs = bpy .path .relpath (fs )
270
280
obj .SIMLOADER .pattern = fs
271
-
272
281
273
- return {"FINISHED" }
282
+ return {"FINISHED" }
0 commit comments