Distinguish selected components from symmetry

Distinguish selected components from symmetry

contact
Contributor Contributor
765 Views
5 Replies
Message 1 of 6

Distinguish selected components from symmetry

contact
Contributor
Contributor

Hello!

I'm struggling to reliable find the selected components (faces / edges / vertices) when symmetry is enabled.

MRichSelection provides getSelection() and getSymmetry() functions, but these always return the components on the "positive" and "negative" side of symmetry respectively, irrelevant to where the user actually clicked (and the tool manipulator is now displayed).
So no matter whether you click "on the left side" or "on the right side" of an object, getSelection() will always give you "the left side" and getSymmetry() will always give you "the right side".
I would like to get "the side where the user clicked", but there seems to be no way to find that out.
Maya seems to know the difference because it displays the manipulator (eg. move tool) where I click, and never at the opposing side.
Is this a bug? Is there a work-around?

Thanks in advance!

0 Likes
Accepted solutions (1)
766 Views
5 Replies
Replies (5)
Message 2 of 6

lanh.hong
Alumni
Alumni
Accepted solution

Hi,

 

When symmetry is enabled, there is a "positive" and a "negative" side to the symmetry. That's why you get the same results with MRichSelection.getSelection() and MRichSelection.getSymmetry() no matter which side you click on.

 

There is something called an "active" side to the symmetry which is the side that you click on. You can use the filterExand command with symActive flag turned on as a workaround. 

 

Regards,

Lanh


Lanh Hong
Developer Technical Services
Autodesk Developer Network



Message 3 of 6

contact
Contributor
Contributor

Thank you so much!
Using the filterExpand command works.

0 Likes
Message 4 of 6

olarn
Advocate
Advocate

Hi

I ran in to the same problem and filterExpand didn't even work with MGlobal::executeCommand, it just return an empty string. Are there absolutely no way to do this in the api?

 

related:

https://forums.autodesk.com/t5/maya-programming/getting-true-component-type-symmetry-selection-via/t...

 

@lanh.hong 

0 Likes
Message 5 of 6

lanh.hong
Alumni
Alumni

Hi olarn,

 

Unfortunately, that's how MRichSelection currently works. getSelection() gets the normal side and getSymmetry() gets the symmetry side. There's no API that gets the active side, but you can use the filterExpand command instead.

 

When using the filterExpand command, make sure to use the correct selection mask with symActive flag.

 

 


Lanh Hong
Developer Technical Services
Autodesk Developer Network



0 Likes
Message 6 of 6

olarn
Advocate
Advocate

Hi,

Thanks for the information. Turns out it was empty because I was asking for MString instead of MStringArray. (Perhaps a warning somewhere in executeCommandStringResult or Mstring overload docs would be nice)

 

Also I noticed that  symPositive flag always return components along the negative side of the chosen axis. Would this behavior change under some circumstance I'm not aware of?

By the way, the symPositive/Negative doc says:

only return the components on the positive side of the object relative to the current symmetry plane

But the normal of symmetry plane(both world and object) as queried from getSymmetryPlane never changes.

 

0 Likes