Isotropix Forums

Changing item names

Clarisse Scripting related topics

Changing item names

Unread postby thomasdyg » Wed Feb 18, 2015 1:25 pm

So from another post here I read that I can get or set attributes, using something like:

Code: Select all
item.attrs.display_visible[0] = not item.attrs.display_visible[0]

'display_visible' being the name of the attribute.

But if I wanted to change the name, what would the name of the name attribute look like?
(I cannot find it in the wiki documentation)


Cheers,
Thomas
thomasdyg
 
Posts: 16
Joined: Sun Feb 03, 2013 5:49 pm

Re: Changing item names

Unread postby julien » Wed Feb 18, 2015 2:58 pm

Hi,
name is not a classic attribute, and can be accessed through the get_name() method, get_full_name(), and set_name().

Code: Select all
print item.get_name()
print item.get_full_name()
item.get_name("new_name")


Have a look at OfItem methods in the documentation

Hope this helps!

regards,
User avatar
julien
 
Posts: 306
Joined: Mon Nov 18, 2013 6:30 pm

Re: Changing item names

Unread postby thomasdyg » Wed Feb 18, 2015 3:19 pm

I'm have this little snippet, which I run with a sphere selected:
Code: Select all
selected = ix.selection

for item in selected:
    print item.get_name()
    item.get_name('test')


Running it, I get:
Traceback (most recent call last):
File "<string>", line 5, in <module>
TypeError: get_name() takes exactly 1 argument (2 given)


I'm surely missing something obvious, but with my copy/paste programming skills I don't get it.
Using 'set_name', clarisse tells me the object has no such attribute.

Thomas
thomasdyg
 
Posts: 16
Joined: Sun Feb 03, 2013 5:49 pm

Re: Changing item names

Unread postby sam » Wed Feb 18, 2015 4:36 pm

Hi Thomas,

get_name() doesn't take any argument. What are you trying to achieve with item.get_name('test')? Do you want to set the name? In that case, you must use: item.set_name('test') and not get_name('test')
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1281
Joined: Fri Jan 25, 2013 11:33 pm

Re: Changing item names

Unread postby thomasdyg » Wed Feb 18, 2015 4:49 pm

I did. I change the above snippets last line to item.set_name('test'). But as I wrote i get this error:
AttributeError: 'OfObject' object has no attribute 'set_name'

I'm ultimatly trying to change the names of a number of objects (Alembic meshes, but in this test case just one sphere).
thomasdyg
 
Posts: 16
Joined: Sun Feb 03, 2013 5:49 pm

Re: Changing item names

Unread postby sam » Wed Feb 18, 2015 5:30 pm

Doh! (Julien and my bad)
You need to use item.rename("your_name"). The method set_name doesn't exist!
Sorry,
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1281
Joined: Fri Jan 25, 2013 11:33 pm

Re: Changing item names

Unread postby thomasdyg » Wed Feb 18, 2015 5:35 pm

;)
Thanks! It now works.

Thomas
thomasdyg
 
Posts: 16
Joined: Sun Feb 03, 2013 5:49 pm


Return to Scripting