## popup message -A disappearing message def popupMessage(function_name): """ Displays an in-view message indicating that a function has been copied to the clipboard. :param function_name: #The name of the function that has been copied. :return: """ mc.inViewMessage(amg="Copied!!\nFunction name '{0}' has been copied to the clipboard.".format(function_name), pos='midCenter', fade=True) # Test function is provided to test main function popupMessage def test_popupMessage(): popupMessage(function_name='exampleFunction') # Since mc.inViewMessage affects the UI, manual verification is required. print("popupMessage executed successfully.") test_popupMessage()
top of page

โœจ๐ŸŽฏ ๐˜ฟ๐™–๐™ฎ09 -100-๐˜ฟ๐™–๐™ฎ๐™จ ๐˜พ๐™ค๐™™๐™š ๐˜พ๐™๐™–๐™ก๐™ก๐™š๐™ฃ๐™œ๐™š ๐Ÿš€๐ŸŽจ

Writer's picture: Subbu AddankiSubbu Addanki

โœจ๐ŸŽฌ ๐™๐™ค๐™ค๐™ก ๐™„๐™ฃ๐™ฉ๐™ง๐™ค: "AttributeReorder" ๐Ÿ”„

Hello VFX & Animation Professionals! ๐Ÿ‘‹

I'm excited to introduce an enhanced version of AttributeReorder, now featuring a stylish and advanced PySide2 UI! ๐ŸŒŸ

Reordering attributes in the Channel Box can significantly improve readability and workflow efficiency, especially when dealing with custom attributes. This updated AttributeReorder tool allows you to reorder selected attributes directly from the Channel Box, with a polished interface inspired by high-quality UI examples.

๐˜ž๐˜ฉ๐˜ข๐˜ต ๐˜ผ๐™ฉ๐™ฉ๐™ง๐™ž๐™—๐™ช๐™ฉ๐™š๐™๐™š๐™ค๐™ง๐™™๐™š๐™ง Offers:

  • Advanced UI:ย A polished and intuitive interface for reordering attributes.

  • Interactive Reordering:ย Easily reorder selected attributes using 'Move Up' and 'Move Down' buttons.

  • Integration with Channel Box:ย Works seamlessly with attributes selected in the Channel Box.

๐Ÿ› ๏ธ ๐˜ผ๐™ฉ๐™ฉ๐™ง๐™ž๐™—๐™ช๐™ฉ๐™š๐™๐™š๐™ค๐™ง๐™™๐™š๐™ง ๐Ÿ”„ (๐™ข๐™–๐™ฎ๐™–.๐™˜๐™ข๐™™๐™จ ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):




import maya.cmds as mc

def move_selected_attributes(direction='up'):
ย ย ย ย """
ย ย ย ย Moves the selected attributes in the Channel Box up or down.
ย ย ย ย Parameters:
ย ย ย ย ย ย ย ย direction (str): 'up' or 'down' to move attributes.
ย ย ย ย """
ย ย ย ย channel_box = 'mainChannelBox'
ย ย ย ย selected_attrs = mc.channelBox(channel_box, query=True, selectedMainAttributes=True)
ย ย ย ย selected_objs = mc.channelBox(channel_box, query=True, mainObjectList=True)

ย ย ย ย if not selected_objs or not selected_attrs:
ย ย ย ย ย ย ย ย mc.warning("Please select attributes in the Channel Box.")
ย ย ย ย ย ย ย ย return

ย ย ย ย obj = selected_objs[0]

ย ย ย ย # Get all user-defined attributes
ย ย ย ย user_attrs = mc.listAttr(obj, userDefined=True) or []
ย ย ย ย if not user_attrs:
ย ย ย ย ย ย ย ย mc.warning("No user-defined attributes found on the object.")
ย ย ย ย ย ย ย ย return

ย ย ย ย # Create new order based on direction
ย ย ย ย new_order = user_attrs[:]
ย ย ย ย for attr in selected_attrs:
ย ย ย ย ย ย ย ย index = new_order.index(attr)
ย ย ย ย ย ย ย ย if direction == 'up' and index > 0:
ย ย ย ย ย ย ย ย ย ย ย ย new_order[index], new_order[index - 1] = new_order[index - 1], new_order[index]

ย ย ย ย # Temporarily unlock all user-defined attributes
ย ย ย ย locked_attrs = mc.listAttr(obj, userDefined=True, locked=True) or []
ย ย ย ย if locked_attrs:
ย ย ย ย ย ย ย ย for attr in locked_attrs:
ย ย ย ย ย ย ย ย ย ย ย ย mc.setAttr('{}.{}'.format(obj, attr), lock=False)

ย ย ย ย # Reorder attributes using delete and undo technique
ย ย ย ย for attr in new_order:
ย ย ย ย ย ย ย ย mc.deleteAttr(obj, at=attr)
ย ย ย ย ย ย ย ย mc.undo()

ย ย ย ย # Re-lock previously locked attributes
ย ย ย ย if locked_attrs:
ย ย ย ย ย ย ย ย for attr in locked_attrs:
ย ย ย ย ย ย ย ย ย ย ย ย mc.setAttr('{}.{}'.format(obj, attr), lock=True)

ย ย ย ย # Refresh the Channel Box to reflect changes
ย ย ย ย mc.select(obj, replace=True)
ย ย ย ย mc.evalDeferred('mc.select("{0}", replace=True)'.format(obj))
ย ย ย ย #mc.evalDeferred('mc.select(clear=True)')

ย ย ย ย print("Attributes reordered.")

# Example usage:
# To move selected attributes up:
move_selected_attributes('up')

๐Ÿ› ๏ธ ๐˜ผ๐™ฉ๐™ฉ๐™ง๐™ž๐™—๐™ช๐™ฉ๐™š๐™๐™š๐™ค๐™ง๐™™๐™š๐™ง ๐Ÿ”„ (๐™‹๐™ฎ๐™Ž๐™ž๐™™๐™š2 ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):



[Todayโ€™s Challenge is to take this simple code to next level.. I am sharing images of these advanced codes...]

๐Ÿ” ๐™’๐™๐™–๐™ฉ ๐˜ผ๐™ฉ๐™ฉ๐™ง๐™ž๐™—๐™ช๐™ฉ๐™š๐™๐™š๐™ค๐™ง๐™™๐™š๐™ง Offers:

  • Enhanced UI:ย A polished interface with advanced styling for a better user experience.

  • Interactive Reordering:ย Use 'Move Up' and 'Move Down' buttons to reorder attributes.

  • Real-Time Feedback:ย Visual updates and messages to keep you informed.


๐Ÿ”ง ๐™†๐™š๐™ฎ ๐˜ฝ๐™š๐™ฃ๐™š๐™›๐™ž๐™ฉ๐™จ:

โ€ข ๐Ÿš€ Boost Productivity:ย Quickly reorder attributes without manual MEL scripting.

โ€ข ๐Ÿ› ๏ธ Improved Organization:ย Customize attribute order to suit your workflow.

โ€ข ๐Ÿ“ˆ Enhanced Workflow:ย Easier access to important attributes, streamlining your process.

โ€ข ๐Ÿ’ก User-Friendly Interface:ย Accessible and intuitive for artists at all levels.

โœจ Ready to Take Control of Your Attributes?

Try out AttributeReorderย today and optimize your Maya workflow! Feel free to reach out or comment below to see it in action. Letโ€™s elevate our Maya scripting together! ๐Ÿ’ช๐ŸŽ‰



๐™Ž๐™ช๐™—๐™—๐™ช'๐™จ ๐™‡๐™ž๐™ฃ๐™ ๐™จ :

๐Ÿ› ๏ธ๐˜ผ๐™™๐™™๐™ž๐™ฉ๐™ž๐™ค๐™ฃ๐™–๐™ก ๐™๐™ž๐™ฅ๐™จ:

  • Selection Order Matters:ย Use the UI to reorder attributes as per your preference.

  • User-Defined Attributes:ย This tool works best with user-defined attributes.

  • Singleton Pattern:ย The UI uses a singleton pattern to prevent multiple instances.

Feel free to reach out if you encounter any issues or need further assistance. Happy coding and scripting! ๐ŸŽ‰๐Ÿ’ป

18 views0 comments

Comentรกrios


bottom of page