Select object by name using python

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  03 March 2013
Question Select object by name using python

Hi, all...
I have a simple question... or not
I would like select an specific object by name if is possible, in the object list on cinema 4d.
In my case, select a MoText object called SELECT.
I searched in Cinema 4D Python SDK Documentation some information about BaseList2D.GetTypeName() or BaseList2D.GetBit()BIT_ACTIVE but the information is not clear. Some topics have examples showing how to use or how to apply but in the 90% not. Some body can help me?
Sorry for english
Regards, Fernando.

 
  03 March 2013
Anyone?
 
  03 March 2013
it depends on what you do refer to with 'object'. if you want to search for BaseObjects
or BaseMaterials , c4d.documents.BaseDocument provides the methods SearchMaterial()
and SearchObject(). if you meant object in a programmatically sense and want to search
baseobjects, basematerials, basetags, baseshaders and so on, there is no pre-made method
for that, you have to step for yourself through the GeListNode tree and check the names
with BaseList2D.GetName() or by simply checking the respective symbol in the objects
BaseContainer.

edit : and just for the record, the object name is a pretty bad (unsafe) identifier for
an object, better use the methods provide by maxon like linkbox and inexclude gui.

Last edited by littledevil : 03 March 2013 at 06:23 PM.
 
  03 March 2013
Thanks for reply littledevil...
I'm talking about select a MoText object highlighted with an red arrow in me image.
I found a command called GetFirstObject() and I used like this:
op = doc.GetFirstObject()
but this command select a fist object from object list.
I would like select an object by name, in my case 3 object from list called "SELECT"
How do I use SearchObject?
MyObjectName.SearchObject() ?
Regards, Fernando.
 
  03 March 2013
SearchObject() and SearchMaterial are both methods provided by BaseDocument
as i have written in my first posting. for a script where the active basedocument is
predefined as doc it would be simply:

myObject = doc.SearchObject('SomeFancyName')

it will return the first match.

Last edited by littledevil : 03 March 2013 at 08:15 PM.
 
  03 March 2013
YEAH! Thanks a lot littledevil it works!!!

Regards, Fernando.
 
  03 March 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed 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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 03:12 AM.


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