Start a new topic
Answered

path hierarchy

Hi,


is there a predefined function to get the name path-hierarchy of an occurence?

For Example for 'LeftPart231'  the output would be:  'Root/MainPart123/LeftPart231'



Best Answer


Hello,


You can try this Python script: 

occurrence = scene.getSelectedOccurrences()[-1]
path = core.getProperty(occurrence, 'Name')

while True:
  occurrence = scene.getParent(occurrence)
  path = core.getProperty(occurrence, 'Name') + '/' + path
  if occurrence == scene.getRoot(): break
  
print(path)



It prints the path of the selected occurrence.

Best,
Nicolas




Hi Nicolas,


thx for the script. In the meantime I made a similar script. But yours a bit shorter :)

 

Greetings,

Sebastian

Answer


Hello,


You can try this Python script: 

occurrence = scene.getSelectedOccurrences()[-1]
path = core.getProperty(occurrence, 'Name')

while True:
  occurrence = scene.getParent(occurrence)
  path = core.getProperty(occurrence, 'Name') + '/' + path
  if occurrence == scene.getRoot(): break
  
print(path)



It prints the path of the selected occurrence.

Best,
Nicolas



Login or Signup to post a comment