Isotropix Forums

Script to Alphabetically sort Browser

Clarisse Scripting related topics

Script to Alphabetically sort Browser

Unread postby devinj898 » Thu Jan 28, 2021 12:52 am

Hi,

Any chance someone has already made and would be willing to share, a Python script to alphabetized the far left section of the Browser? It would be very helpful to keep my project organized. That left panel always seems to get disorganized without me even realizing it, and I am having trouble keeping up with all the contexts not being sorted 0-9, then A-Z.

Thanks
Devin
devinj898
 
Posts: 27
Joined: Mon May 05, 2014 7:36 am

Re: Script to Alphabetically sort Browser

Unread postby anemoff » Tue Feb 02, 2021 4:01 pm

Hi,

You should be able to reorder items in a context using the following API from OfContext:
Code: Select all
move_item_index(const unsigned int old_index, const unsigned int new_index)


https://clarissewiki.com/4.0/sdk/class_ ... 6e6bcd2583

However this API modifies the project, it's not just a UI reordering, so you need to save the project after reordering.

You need to do the reindexing yourself.

Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 421
Joined: Wed Jan 13, 2016 10:10 am

Re: Script to Alphabetically sort Browser

Unread postby jboissinot » Mon Feb 08, 2021 9:50 pm

Hi,

I was actually planning to ask about this, so I'm glad that it has been discussed already, and thanks for sharing a solution on how we could it.

I did some testing on my own to explore this but I noticed something wrong. In fact, let's say that I create 3 contexts, A, B, and C, in a context.
If I print the index of all contexts, I do get 0 for A, 1 for B, and 2 for C. However, if I rename A with D, then I'm getting index 1 for C while it should still be 2. Looks like it might return the creation index and not the display index. Maybe that's normal and expected actually, I just thought that find_item_index() would return the actual position of an item in a context.

Can you clarify this to make sure that what I assume makes sense or if it's a bug with the API?

Thanks,
Jeremy
jboissinot
 
Posts: 91
Joined: Tue Jan 29, 2019 10:36 pm

Re: Script to Alphabetically sort Browser

Unread postby anemoff » Fri Feb 12, 2021 7:05 pm

I can confirm the following:
- renaming an item will reorder it and put it last
- the UI is not refreshed after renaming the item to reflect its new position (bug)

I used this little script to print the index of the selected items:

py code

for item in ix.selection:
if item.is_context():
print(item.get_name(), item.get_parent().find_item_index(item))
else:
print(item.get_name(), item.get_context().find_item_index(item))


I will investigate some more next week.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 421
Joined: Wed Jan 13, 2016 10:10 am


Return to Scripting
cron