@@ -222,7 +222,13 @@ def loadModel(filename):
222
222
bpy .ops .wm .alembic_import (filepath = filename )
223
223
root = bpy .data .objects ['mvgRoot' ]
224
224
root .rotation_euler .rotate_axis ('X' , math .radians (- 90.0 ))
225
- return bpy .data .objects ['mvgPointCloud' ], bpy .data .meshes ['particleShape1' ]
225
+
226
+ obj = bpy .data .objects ['mvgPointCloud' ]
227
+
228
+ mesh = None
229
+ if "particleShape1" in [c .name for c in bpy .data .meshes ]:
230
+ mesh = bpy .data .meshes ['particleShape1' ]
231
+ return obj , mesh
226
232
227
233
228
234
def setupWireframeShading (mesh , color ):
@@ -290,21 +296,27 @@ def setupPointCloudShading(obj, color, size):
290
296
# Setup nodes
291
297
nodeInput = geo .nodes .new (type = 'NodeGroupInput' )
292
298
nodeOutput = geo .nodes .new (type = 'NodeGroupOutput' )
293
- nodeM2P = geo .nodes .new (type = 'GeometryNodeMeshToPoints' )
294
299
nodeIoP = geo .nodes .new (type = 'GeometryNodeInstanceOnPoints' )
295
300
nodeCube = geo .nodes .new (type = 'GeometryNodeMeshCube' )
296
301
nodeSize = geo .nodes .new (type = 'ShaderNodeValue' )
297
302
nodeSize .outputs ['Value' ].default_value = size
298
303
nodeMat = geo .nodes .new (type = 'GeometryNodeSetMaterial' )
299
304
nodeMat .inputs [2 ].default_value = material
305
+
306
+ # Create sockets
307
+ if hasattr (geo , 'interface' ):
308
+ geo .interface .new_socket ('Geometry' , in_out = 'INPUT' , socket_type = 'NodeSocketGeometry' )
309
+ geo .interface .new_socket ('Geometry' , in_out = 'OUTPUT' , socket_type = 'NodeSocketGeometry' )
310
+ else :
311
+ geo .inputs .new ('NodeSocketGeometry' , 'Geometry' )
312
+ geo .outputs .new ('NodeSocketGeometry' , 'Geometry' )
313
+
300
314
# Connect nodes
301
- geo .links .new (nodeInput .outputs [0 ], nodeM2P .inputs ['Mesh' ])
302
- geo .links .new (nodeM2P .outputs ['Points' ], nodeIoP .inputs ['Points' ])
315
+ geo .links .new (nodeInput .outputs ['Geometry' ], nodeIoP .inputs ['Points' ])
303
316
geo .links .new (nodeCube .outputs ['Mesh' ], nodeIoP .inputs ['Instance' ])
304
317
geo .links .new (nodeSize .outputs ['Value' ], nodeIoP .inputs ['Scale' ])
305
318
geo .links .new (nodeIoP .outputs ['Instances' ], nodeMat .inputs ['Geometry' ])
306
- geo .links .new (nodeMat .outputs [0 ], nodeOutput .inputs [0 ])
307
-
319
+ geo .links .new (nodeMat .outputs [0 ], nodeOutput .inputs ['Geometry' ])
308
320
309
321
310
322
def main ():
0 commit comments