99
1010# Here are load and delete operations
1111class 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"
1614 bl_idname = "sequence.load"
1715 bl_options = {"UNDO" }
1816
@@ -48,9 +46,7 @@ def execute(self, context):
4846
4947
5048class SIMLOADER_OT_edit (bpy .types .Operator ):
51- '''
52- This operator changes a sequnce
53- '''
49+ '''This operator changes a sequnce'''
5450 bl_label = "Edit Sequences Path"
5551 bl_idname = "sequence.edit"
5652 bl_options = {"UNDO" }
@@ -76,7 +72,6 @@ def execute(self, context):
7672 return {"CANCELLED" }
7773 fs = importer_prop .path + '/' + importer_prop .pattern
7874
79-
8075 try :
8176 fs = fileseq .findSequenceOnDisk (fs )
8277 except Exception as e :
@@ -96,22 +91,27 @@ def execute(self, context):
9691 return {"FINISHED" }
9792
9893
99-
10094class 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'''
10496 bl_label = "Reset Geometry Nodes as Point Cloud"
10597 bl_idname = "simloader.resetpt"
10698 bl_options = {"UNDO" }
10799
108100 def execute (self , context ):
109101 sim_loader = context .scene .SIMLOADER
110102 obj = bpy .data .objects [sim_loader .selected_obj_num ]
103+ warn = False
111104 for modifier in obj .modifiers :
112105 if modifier .type == "NODES" :
106+ warn = True
113107 obj .modifiers .remove (modifier )
108+ if warn :
109+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
114110 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 ()
115115 gn .node_group .nodes .new ('GeometryNodeMeshToPoints' )
116116 set_material = gn .node_group .nodes .new ('GeometryNodeSetMaterial' )
117117 set_material .inputs [2 ].default_value = context .scene .SIMLOADER .material
@@ -127,88 +127,103 @@ def execute(self, context):
127127
128128
129129class 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'''
133131 bl_label = "Reset Geometry Nodes as Mesh"
134132 bl_idname = "simloader.resetmesh"
135133 bl_options = {"UNDO" }
136134
137135 def execute (self , context ):
138136 sim_loader = context .scene .SIMLOADER
139137 obj = bpy .data .objects [sim_loader .selected_obj_num ]
138+ warn = False
140139 for modifier in obj .modifiers :
141140 if modifier .type == "NODES" :
141+ warn = True
142142 obj .modifiers .remove (modifier )
143+ if warn :
144+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
143145 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 ()
144150 bpy .ops .object .modifier_move_to_index (modifier = gn .name , index = 0 )
145151 return {"FINISHED" }
146152
147153
148154class 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'''
152156 bl_label = "Reset Geometry Nodes as Instances"
153157 bl_idname = "simloader.resetins"
154158 bl_options = {"UNDO" }
155159
156160 def execute (self , context ):
157161 sim_loader = context .scene .SIMLOADER
158162 obj = bpy .data .objects [sim_loader .selected_obj_num ]
163+ warn = False
159164 for modifier in obj .modifiers :
160165 if modifier .type == "NODES" :
166+ warn = True
161167 obj .modifiers .remove (modifier )
168+ if warn :
169+ show_message_box ("Exising geoemtry nodes of {} has been removed" .format (obj .name ), "Warning" )
162170 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 ()
163175 nodes = gn .node_group .nodes
164176 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 ]
167179
168180 instance_on_points = nodes .new ('GeometryNodeInstanceOnPoints' )
169181 cube = nodes .new ('GeometryNodeMeshCube' )
170182 realize_instance = nodes .new ('GeometryNodeRealizeInstances' )
171183 set_material = nodes .new ('GeometryNodeSetMaterial' )
172184
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+ ]
174190 set_material .inputs [2 ].default_value = context .scene .SIMLOADER .material
175191
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 ])
182197
183198 bpy .ops .object .modifier_move_to_index (modifier = gn .name , index = 0 )
184199 return {"FINISHED" }
185200
201+
186202class 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"
191205 bl_idname = "simloader.setsplitnorm"
192206 bl_options = {"UNDO" }
207+
193208 def execute (self , context ):
194209 sim_loader = context .scene .SIMLOADER
195210 obj = bpy .data .objects [sim_loader .selected_obj_num ]
196211 mesh = obj .data
197212 attr_index = sim_loader .selected_attribute_num
198- if attr_index >= len (mesh .attributes ):
213+ if attr_index >= len (mesh .attributes ):
199214 show_message_box ("Please select the attribute" )
200215 return {"CANCELLED" }
201216 mesh .SIMLOADER .split_norm_att_name = mesh .attributes [attr_index ].name
202217
203218 return {"FINISHED" }
204219
220+
205221class 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"
210224 bl_idname = "simloader.removesplitnorm"
211225 bl_options = {"UNDO" }
226+
212227 def execute (self , context ):
213228 sim_loader = context .scene .SIMLOADER
214229 obj = bpy .data .objects [sim_loader .selected_obj_num ]
@@ -220,12 +235,11 @@ def execute(self, context):
220235
221236
222237class SIMLOADER_OT_disable_selected (bpy .types .Operator ):
223- '''
224- This operator disable all selected sequence
225- '''
238+ '''This operator disable all selected sequence'''
226239 bl_label = "Disable Selected Sequence"
227240 bl_idname = "simloader.disableselected"
228241 bl_options = {"UNDO" }
242+
229243 def execute (self , context ):
230244 for obj in bpy .context .selected_objects :
231245 if obj .SIMLOADER .init and obj .SIMLOADER .enabled :
@@ -234,40 +248,35 @@ def execute(self, context):
234248
235249
236250class SIMLOADER_OT_enable_selected (bpy .types .Operator ):
237- '''
238- This operator enable all selected sequence
239- '''
251+ '''This operator enable all selected sequence'''
240252 bl_label = "Enable Selected Sequence"
241253 bl_idname = "simloader.enableselected"
242254 bl_options = {"UNDO" }
255+
243256 def execute (self , context ):
244257 for obj in bpy .context .selected_objects :
245258 if obj .SIMLOADER .init and not obj .SIMLOADER .enabled :
246259 obj .SIMLOADER .enabled = True
247260 return {"FINISHED" }
248261
249262
250-
251263class SIMLOADER_OT_refresh_seq (bpy .types .Operator ):
252- '''
253- This operator refresh the sequence
254- '''
264+ '''This operator refresh the sequence'''
255265 bl_label = "Refresh Sequence"
256266 bl_idname = "simloader.refresh"
267+
257268 def execute (self , context ):
258269 scene = context .scene
259270 obj = bpy .data .objects [scene .SIMLOADER .selected_obj_num ]
260271
261-
262272 fs = obj .SIMLOADER .pattern
263273 if obj .SIMLOADER .use_relative :
264274 fs = bpy .path .abspath (fs )
265275 fs = fileseq .findSequenceOnDisk (fs )
266- fs = fileseq .findSequenceOnDisk (fs .dirname ()+ fs .basename () + "@" + fs .extension ())
276+ fs = fileseq .findSequenceOnDisk (fs .dirname () + fs .basename () + "@" + fs .extension ())
267277 fs = str (fs )
268278 if obj .SIMLOADER .use_relative :
269279 fs = bpy .path .relpath (fs )
270280 obj .SIMLOADER .pattern = fs
271-
272281
273- return {"FINISHED" }
282+ return {"FINISHED" }
0 commit comments