Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

Maya return object name

polycounter lvl 16
Offline / Send Message
Toast polycounter lvl 16
Hi,

this is driving me crazy.

I have a mesh that is named "Model__321".

How do I query that name?

When I do

`ls -sl`;

Maya also (inconveniently) returns the above group name to which this object is apart of:

Group__127|Model__321

I only want the Model__321 part. How is that possible?

Replies

  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    Generally you will get grouping information as part of your ls query if you have two objects with the same name but under different groups (as with duplicating/instancing groups), because two objects cannot have the same name; appending grouping information as a suffix keeps the names unique.

    To split the grouping information you can tokenize the bar character. The last index in the resulting array will be your object's name, however if you do in fact have multiple objects with the same name, you will get an "more than one object matches name" error when trying to select that object.

    You should get such an error if you try to select an object with the `select` command, if it is in fact sharing the same name elsewhere.
    1. {
    2. //stores selection
    3. string $select[] = `ls -sl`;
    4. //array for storing tokenized result
    5. string $buffer[];
    6. //removes and splits string into sections based on the character(s) in quotes
    7. tokenize $select[0] "|" $buffer;
    8. //the last location of the array is the object name
    9. print $buffer[`size $buffer`-1];
    10. }
  • Toast
    Offline / Send Message
    Toast polycounter lvl 16
    Thank you Bartalon
Sign In or Register to comment.