Rename ReadGeo nodes by Alembic SceneGraph

607 Views Asked by At

I have 7 shots with 2 or 3 Alembic files in each and around 20 geometries per Alembic.

As I need to export my complete 3D scene in a new Alembic, I need to rename all of the ReadGeo nodes to be easily readable in other software (like Maya).

For this, I want to give the geometry name from the Alembic Scenegraph to the ReadGeo but I don't see how to found Geo name with Python. I have started with this code:

def AlembicRename():
    for s in nuke.allNodes("ReadGeo2"):
        GeoName = # don't know how to find this
        s['name'].setValue(GeoName)

AlembicRename()

Any idea how I can find the Geometry Name?

Thank you.

2

There are 2 best solutions below

0
William Eguienta On BEST ANSWER

Solved with

myReadGeoNode['scene_view'].getSelectedItems()
6
Andy Jazz On

To access ABC's Scenegraph's hierarchy in NUKE, you should try this code:

import nuke

# 'ReadGeo2' – node's class 
nuke.createNode('ReadGeo2', 'file { /Users/swift/Desktop/scene.abc }') 

def alembicRename():
    # 'ReadGeo18' – node's name in graph 
    for s in nuke.allNodes('ReadGeo18'):
        sceneView = s['scene_view']
        hierarchy = sceneView.getAllItems()
        print hierarchy

alembicRename()

# Result: ['/root/polySphere/polySphereShape']

To find out how to extract a substring from inside a string using Python read This Post. After extracting process you can assign (polySphere, for example) name to your ReadGeo node. And do not forget: there is a Python's list containing only zero index.

s['name'].setValue(hierarchy[0])

enter image description here