Python: generate code list from selection?


#1

Hi,
is there a possibility to write a list in python code from the selected objects in OM?

For example I select Null_01, Null_02 and Null_03 and I somehow can generate a python list with the names as string? = [“Null_01” ,“Null_02” ,“Null_03”]

Thanks!


#2

names = [o.GetName() for o in doc.GetSelection()]

doc.GetSelection() returns the selected objects as BaseObject references. From there we’re using python list comprehension to build a list with the name of each object.


#3

Ha!
Thank you so much! And so easy…