Python: generate code list from selection?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2018
Python: generate code list from selection?

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"]

  03 March 2018
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.
  03 March 2018
Thank you so much! And so easy...
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 02:42 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.