โจ๐ฌ ๐๐ค๐ค๐ก ๐๐ฃ๐ฉ๐ง๐ค: "๐พ๐ก๐๐๐ฃ๐ช๐ฅ๐๐ค๐ค๐ก" ๐งน
Hello VFX & Animation Professionals! ๐
I'm excited to introduce a valuable addition to your Maya toolkitโCleanupTool! ๐
Over time, Maya scenes can become cluttered with unused nodes, empty groups, orphaned shaders, and other unnecessary elements that bloat file size and slow down performance. CleanupTool helps you tidy up your scenes by automatically identifying and removing these unwanted items, ensuring your projects run smoothly.
๐๐๐๐ฉ ๐พ๐ก๐๐๐ฃ๐ช๐ฅ๐๐ค๐ค๐ก ๐๐๐๐๐ง๐จ:
Automated Cleanup:ย Removes unused nodes, empty groups, orphaned shaders, and more.
Selective Cleaning:ย Choose which types of nodes to clean for granular control.
Performance Boost:ย Streamlines your scene for faster load times and smoother interactions.
๐ ๏ธ ๐พ๐ก๐๐๐ฃ๐ช๐ฅ๐๐ค๐ค๐ก ๐งน (๐ข๐๐ฎ๐.๐๐ข๐๐จ ๐๐๐ง๐จ๐๐ค๐ฃ):
import maya.cmds as mc def cleanupScene(delete_unused_nodes=True, delete_empty_groups=True, DEBUG=False): """ Cleans up the Maya scene by deleting unused nodes, empty transform groups, and unused shaders, while preserving constraints and effectors.
:param delete_unused_nodes: <bool> Deletes unused nodes if True. :param delete_empty_groups: <bool> Deletes empty transform groups if True. :param DEBUG: <bool> If True, prints detailed debugging information. :return: <None> """ if delete_unused_nodes: # Delete 'unknown' nodes unknown_nodes = mc.ls(type='unknown') if unknown_nodes: try: mc.delete(unknown_nodes) print("Deleted 'unknown' nodes.") if DEBUG: print("List of deleted 'unknown' nodes:", unknown_nodes) except Exception as e: if DEBUG: print("Failed to delete 'unknown' nodes:", e)
# Delete 'unknownDag' nodes unknownDag_nodes = mc.ls(type='unknownDag') if unknownDag_nodes: try: mc.delete(unknownDag_nodes) print("Deleted 'unknownDag' nodes.") if DEBUG: print("List of deleted 'unknownDag' nodes:", unknownDag_nodes) except Exception as e: if DEBUG: print("Failed to delete 'unknownDag' nodes:", e)
# Delete 'unknownTransform' nodes unknownTransform_nodes = mc.ls(type='unknownTransform') if unknownTransform_nodes: try: mc.delete(unknownTransform_nodes) print("Deleted 'unknownTransform' nodes.") if DEBUG: print("List of deleted 'unknownTransform' nodes:", unknownTransform_nodes) except Exception as e: if DEBUG: print("Failed to delete 'unknownTransform' nodes:", e)
if delete_empty_groups: all_transforms = mc.ls(type='transform') for obj in all_transforms: # Skip default Maya transforms if obj in ['root', 'persp', 'front', 'side', 'top', 'back', 'left', 'right']: continue
if mc.objExists(obj): children = mc.listRelatives(obj, children=True) if not children: # Check if the group has any connections connections = mc.listConnections(obj, connections=True, plugs=True) or [] if connections: if DEBUG: print("Skipping deletion of group '{}' because it has connections.".format(obj)) continue # Check for critical node types connected to this group connected_nodes = mc.listConnections(obj, type=True, plugs=False) or []
# Define node types that should prevent deletion critical_node_types = ['constraint', 'ikEffector', 'joint', 'controller', 'blendShape', 'nurbsCurve']
has_critical = False for connected_node in connected_nodes: node_type = mc.nodeType(connected_node) if node_type in critical_node_types: has_critical = True if DEBUG: print("Skipping deletion of group '{}' because it has a connected '{}' node.".format(obj, node_type)) break if has_critical: continue # If no connections and no critical nodes, delete the empty group try: mc.delete(obj) print("Deleted empty group: '{}'".format(obj)) except Exception as e: if DEBUG: print("Failed to delete group '{}': {}".format(obj, e))
print("Scene cleanup completed.") # Example usage: # To run without debugging information cleanupScene() # To run with debugging information # cleanupScene(DEBUG=True) |
๐ ๏ธ ๐พ๐ก๐๐๐ฃ๐ช๐ฅ๐๐ค๐ค๐ก ๐งน (๐๐ฎ๐๐๐๐2 ๐๐๐ง๐จ๐๐ค๐ฃ):
[Todayโs Challenge is to take this simple code to next level.. I am sharing images of these advanced codes...] |
๐ ๐๐๐๐ฉ ๐พ๐ก๐๐๐ฃ๐ช๐ฅ๐๐ค๐ค๐ก ๐๐๐๐๐ง๐จ:
Streamlined Scenes:ย Keeps your scenes clean and organized by removing unnecessary elements.
Improved Performance:ย Reduces file size and memory usage, leading to faster load times.
User-Friendly Interface:ย Simple and intuitive UI for quick scene cleanup.
๐ง ๐๐๐ฎ ๐ฝ๐๐ฃ๐๐๐๐ฉ๐จ:
โข ๐ Boost Efficiency:ย Save time by automating the tedious task of manual cleanup.
โข ๐ ๏ธ Enhance Workflow:ย Focus on creative work without worrying about scene clutter.
โข ๐ Optimize Performance:ย Ensure your scenes run smoothly, even with complex projects.
โข ๐ก User-Friendly:ย Accessible for artists of all levels, with easy-to-use options.
โจ Ready to Keep Your Scenes Clean and Efficient?
Try out CleanupToolย today and enhance your Maya workflow! Feel free to reach out or comment below to see it in action. Letโs elevate our Maya scripting together! ๐ช๐
๐๐ช๐๐๐ช'๐จ ๐๐๐ฃ๐ ๐จ :
โข YouTube Channel: https://www.youtube.com/@118subbuโข Vimeo:ย https://vimeo.com/subbu118โข Creature Rigging:ย https://www.creaturerigging.comโข Python Scripting:ย https://www.pythonscripting.comโข Hyper Rig:ย https://www.hyper-rig.com
#HappyScripting #MayaUI #CleanupTool #PipelineOptimization #Maya #PythonScripting #MayaTools #VFX #3DAnimation #ScriptDevelopment #Automation #WorkflowEnhancement #TechnicalArt #ScriptingTools
๐ ๏ธ๐ผ๐๐๐๐ฉ๐๐ค๐ฃ๐๐ก ๐๐๐ฅ๐จ:
Backup Your Scene:ย Before running cleanup operations, it's good practice to save a backup of your scene.
Selective Cleanup:ย Use the checkboxes to control which elements are deleted, giving you flexibility.
Extend Functionality:ย Customize the script to include additional cleanup options like deleting unused nodes or optimizing meshes.
Comments