## 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
Writer's pictureSubbu Addanki

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

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

Hello Maya Artists and Technical Directors! ๐Ÿ‘‹

I'm excited to introduce HierarchyManagerPro, a groundbreaking tool designed to simplify and enhance the management of complex scene hierarchies in Maya. With this tool, you can effortlessly organize, reorganize, and visualize your scene structures, boosting your productivity and keeping your projects tidy! ๐ŸŒŸ


๐˜ž๐˜ฉ๐˜ข๐˜ต ๐™ƒ๐™ž๐™š๐™ง๐™–๐™ง๐™˜๐™๐™ฎ๐™ˆ๐™–๐™ฃ๐™–๐™œ๐™š๐™ง๐™‹๐™ง๐™ค Offers:

  • Visual Hierarchy Editing: Drag and drop objects to reorganize your scene hierarchy.

  • Batch Parenting/Unparenting: Manage multiple objects simultaneously.

  • Filtering and Searching: Quickly find objects in complex scenes.

  • Snapshot Hierarchies: Save and restore hierarchy states for easy experimentation.



๐Ÿ› ๏ธ ๐™ƒ๐™ž๐™š๐™ง๐™–๐™ง๐™˜๐™๐™ฎ๐™ˆ๐™–๐™ฃ๐™–๐™œ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ”ง (๐™ข๐™–๐™ฎ๐™–.๐™˜๐™ข๐™™๐™จ ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):

import maya.cmds as cmds
import json
import os
def hierarchy_manager_pro(action='list', parent=None, children=None, snapshot_name=None):
ย ย ย ย """
ย ย ย ย Manages scene hierarchy in Maya.
ย ย ย ย Parameters:
ย ย ย ย ย ย ย ย action (str): Action to perform ('list', 'parent', 'unparent', 'snapshot', 'restore').
ย ย ย ย ย ย ย ย parent (str): Parent object name.
ย ย ย ย ย ย ย ย children (list): List of child object names.
ย ย ย ย ย ย ย ย snapshot_name (str): Name for the hierarchy snapshot.
ย ย ย ย """
ย ย ย ย if action == 'list':
ย ย ย ย ย ย ย ย all_transforms = cmds.ls(type='transform')
ย ย ย ย ย ย ย ย for obj in all_transforms:
ย ย ย ย ย ย ย ย ย ย ย ย parent = cmds.listRelatives(obj, parent=True)
ย ย ย ย ย ย ย ย ย ย ย ย print("Object: {0}, Parent: {1}".format(obj, parent[0] if parent else "World"))
ย ย ย ย elif action == 'parent':
ย ย ย ย ย ย ย ย if not parent or not children:
ย ย ย ย ย ย ย ย ย ย ย ย cmds.warning("Please provide a parent and children to parent.")
ย ย ย ย ย ย ย ย ย ย ย ย return
ย ย ย ย ย ย ย ย cmds.parent(children, parent)
ย ย ย ย ย ย ย ย print("Parented {0} under {1}".format(children, parent))
ย ย ย ย elif action == 'unparent':
ย ย ย ย ย ย ย ย if not children:
ย ย ย ย ย ย ย ย ย ย ย ย cmds.warning("Please provide children to unparent.")
ย ย ย ย ย ย ย ย ย ย ย ย return
ย ย ย ย ย ย ย ย cmds.parent(children, world=True)
ย ย ย ย ย ย ย ย print("Unparented {0} to World".format(children))
ย ย ย ย elif action == 'snapshot':
ย ย ย ย ย ย ย ย if not snapshot_name:
ย ย ย ย ย ย ย ย ย ย ย ย cmds.warning("Please provide a name for the snapshot.")
ย ย ย ย ย ย ย ย ย ย ย ย return
ย ย ย ย ย ย ย ย hierarchy = {}
ย ย ย ย ย ย ย ย all_transforms = cmds.ls(type='transform')
ย ย ย ย ย ย ย ย for obj in all_transforms:
ย ย ย ย ย ย ย ย ย ย ย ย parent = cmds.listRelatives(obj, parent=True)
ย ย ย ย ย ย ย ย ย ย ย ย hierarchy[obj] = parent[0] if parent else None
ย ย ย ย ย ย ย ย snapshot_file = os.path.join(cmds.internalVar(userAppDir=True), snapshot_name + '.json')
ย ย ย ย ย ย ย ย with open(snapshot_file, 'w') as f:
ย ย ย ย ย ย ย ย ย ย ย ย json.dump(hierarchy, f, indent=4)
ย ย ย ย ย ย ย ย print("Hierarchy snapshot saved as {0}".format(snapshot_file))
ย ย ย ย elif action == 'restore':
ย ย ย ย ย ย ย ย if not snapshot_name:
ย ย ย ย ย ย ย ย ย ย ย ย cmds.warning("Please provide the name of the snapshot to restore.")
ย ย ย ย ย ย ย ย ย ย ย ย return
ย ย ย ย ย ย ย ย snapshot_file = os.path.join(cmds.internalVar(userAppDir=True), snapshot_name + '.json')
ย ย ย ย ย ย ย ย if not os.path.exists(snapshot_file):
ย ย ย ย ย ย ย ย ย ย ย ย cmds.warning("Snapshot file does not exist.")
ย ย ย ย ย ย ย ย ย ย ย ย return
ย ย ย ย ย ย ย ย with open(snapshot_file, 'r') as f:
ย ย ย ย ย ย ย ย ย ย ย ย hierarchy = json.load(f)
ย ย ย ย ย ย ย ย for obj, parent in hierarchy.items():
ย ย ย ย ย ย ย ย ย ย ย ย if cmds.objExists(obj):
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย if parent and cmds.objExists(parent):
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย cmds.parent(obj, parent)
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย else:
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย cmds.parent(obj, world=True)
ย ย ย ย ย ย ย ย print("Hierarchy restored from {0}".format(snapshot_file))
ย ย ย ย else:
ย ย ย ย ย ย ย ย cmds.warning("Invalid action specified for HierarchyManagerPro.")
# Usage Examples:
# List all objects and their parents
# hierarchy_manager_pro(action='list')
# Parent objects
# hierarchy_manager_pro(action='parent', parent='parentObj', children=['child1', 'child2'])
# Unparent objects
# hierarchy_manager_pro(action='unparent', children=['child1', 'child2'])
# Save hierarchy snapshot
# hierarchy_manager_pro(action='snapshot', snapshot_name='myHierarchy')
# Restore hierarchy snapshot
# hierarchy_manager_pro(action='restore', snapshot_name='myHierarchy')

๐Ÿ› ๏ธ ๐™ƒ๐™ž๐™š๐™ง๐™–๐™ง๐™˜๐™๐™ฎ๐™ˆ๐™–๐™ฃ๐™–๐™œ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ”ง (๐™‹๐™ฎ๐™Ž๐™ž๐™™๐™š2 ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):

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



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

  • ๐Ÿ“‚ Efficient Organization: Easily manage and visualize complex hierarchies.

  • โฑ๏ธ Time Saver: Batch operations reduce repetitive tasks.

  • ๐Ÿ” Quick Access: Filter and search functionalities streamline your workflow.

  • ๐Ÿ›ก๏ธ Safe Experimentation: Snapshot feature allows you to revert to previous hierarchy states.

โœจ Ready to Revolutionize Your Scene Management?

Try out HierarchyManagerProย today and take control of your scene hierarchies like never before! Feel free to reach out or comment below to see it in action. Let's elevate our workflows together! ๐Ÿ’ช๐ŸŽ‰

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

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

  • Customization: Enhance the UI with options to display additional object info like node types or custom attributes.

  • Integration: Adapt the tool to work seamlessly with your studio's pipeline and naming conventions.

  • Error Handling: Implement checks for locked or referenced nodes to prevent unexpected behavior.

  • Extensibility: Expand functionality to include grouping, tagging, or even automating hierarchy setups for common scenarios.

Feel free to reach out if you have any questions or need further assistance. Happy organizing! ๐ŸŽ‰๐Ÿ’ป

2 views0 comments

Comments


bottom of page