Created
November 9, 2017 06:30
-
-
Save davidlatwe/56046cf4a5f2ea71e36a31f8722b07c0 to your computer and use it in GitHub Desktop.
Maya 切換選取物件的可視狀態
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 抓取選取範圍 | |
| string $selects[] = `ls -sl`; | |
| // 取得選取範圍第一個物件的參數值 | |
| int $status = `getAttr ($selects[0] + ".visibility")`; | |
| // 將參數值(數字 1) 相減並取絕對值以得相反值然後設定回去 | |
| setAttr ($selects[0] + ".visibility") `abs($status - 1)`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 取得選取範圍的第一個物件 | |
| obj = cmds.ls(sl=1)[0] | |
| # 抓取該物件的參數布林值並以相反值設定回去 | |
| cmds.setAttr(obj + ".visibility", not cmds.getAttr(obj + ".visibility")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment