## 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

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

Writer's picture: Subbu AddankiSubbu Addanki

โœจ๐ŸŽฌ ๐™‰๐™š๐™ฌ ๐™๐™ค๐™ค๐™ก ๐™„๐™ฃ๐™ฉ๐™ง๐™ค: "๐™Ž๐šŒ๐™š๐™ฃ๐™š๐™‘๐™–๐™ก๐™ž๐™™๐™–๐™ฉ๐™š๐™ง๐™‹๐™ง๐™ค" ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ”

Hello VFX & Animation Professionals! ๐Ÿ‘‹

I'm excited to introduce a vital addition to your Maya toolkitโ€”SceneValidatorPro! ๐ŸŒŸ

Ensuring the integrity and consistency of your Maya scenes is crucial for seamless workflows and high-quality outputs. SceneValidatorPro revolutionizes this process by providing advanced scene validation features, allowing you to detect, analyze, and rectify potential issues effortlessly across your projects.


๐™’๐™๐™–๐™ฉ ๐™Ž๐™˜๐™š๐™ฃ๐™š๐™‘๐™–๐™ก๐™ž๐™™๐™–๐™ฉ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ” ๐™Š๐™›๐™›๐™š๐™ง๐™จ:

  • Scene Analysis:ย Automatically scans your scene for inconsistencies, such as missing textures, unused nodes, and duplicate objects.

  • Error Reporting:ย Generates detailed reports highlighting the issues found, enabling you to address them promptly.

  • Automated Fixes:ย Provides options to automatically fix common issues, streamlining your workflow and saving valuable time.

  • Custom Validation Rules:ย Allows you to define custom validation rules tailored to your project's specific needs.

  • User-Friendly Interface:ย Intuitive UI designed to make scene validation effortless and efficient for artists of all levels.



๐Ÿ› ๏ธ ๐™Ž๐™˜๐™š๐™ฃ๐™š๐™‘๐™–๐™ก๐™ž๐™™๐™–๐™ฉ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ” (๐™ข๐™–๐™ฎ๐™–.๐™˜๐™ข๐™™๐™จ ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):

import maya.cmds as cmds
import json
def load_validation_rules(rules_file="validation_rules.json"):
ย ย ย ย """
ย ย ย ย Loads custom validation rules from a JSON file.
ย ย ย ย 
ย ย ย ย :param rules_file: <str> Path to the JSON file containing validation rules.
ย ย ย ย :return: <dict> Dictionary of validation rules.
ย ย ย ย """
ย ย ย ย try:
ย ย ย ย ย ย ย ย with open(rules_file, 'r') as file:
ย ย ย ย ย ย ย ย ย ย ย ย return json.load(file)
ย ย ย ย except IOError:
ย ย ย ย ย ย ย ย cmds.warning("Validation rules file not found.")
ย ย ย ย ย ย ย ย return {}
def save_validation_rules(rules, rules_file="validation_rules.json"):
ย ย ย ย """
ย ย ย ย Saves custom validation rules to a JSON file.
ย ย ย ย 
ย ย ย ย :param rules: <dict> Dictionary of validation rules.
ย ย ย ย :param rules_file: <str> Path to the JSON file to save validation rules.
ย ย ย ย """
ย ย ย ย with open(rules_file, 'w') as file:
ย ย ย ย ย ย ย ย json.dump(rules, file, indent=4)
def analyze_scene(rules=None):
ย ย ย ย """
ย ย ย ย Analyzes the current Maya scene based on the provided validation rules.
ย ย ย ย 
ย ย ย ย :param rules: <dict> Dictionary of validation rules. If None, default rules are used.
ย ย ย ย :return: <dict> Dictionary of issues found.
ย ย ย ย """
ย ย ย ย issues = {}
ย ย ย ย 
ย ย ย ย # Default rules if none provided
ย ย ย ย if rules is None:
ย ย ย ย ย ย ย ย rules = {
ย ย ย ย ย ย ย ย ย ย ย ย "missing_textures": True,
ย ย ย ย ย ย ย ย ย ย ย ย "unused_nodes": True,
ย ย ย ย ย ย ย ย ย ย ย ย "duplicate_objects": True
ย ย ย ย ย ย ย ย }
ย ย ย ย 
ย ย ย ย if rules.get("missing_textures"):
ย ย ย ย ย ย ย ย missing_textures = []
ย ย ย ย ย ย ย ย for shader in cmds.ls(materials=True):
ย ย ย ย ย ย ย ย ย ย ย ย textures = cmds.listConnections(shader, type='file')
ย ย ย ย ย ย ย ย ย ย ย ย if not textures:
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย missing_textures.append(shader)
ย ย ย ย ย ย ย ย if missing_textures:
ย ย ย ย ย ย ย ย ย ย ย ย issues["Missing Textures"] = missing_textures
ย ย ย ย 
ย ย ย ย if rules.get("unused_nodes"):
ย ย ย ย ย ย ย ย unused_nodes = cmds.ls(type=['unknown', 'shadingEngine'])
ย ย ย ย ย ย ย ย unused_nodes = [node for node in unused_nodes if not cmds.listConnections(node)]
ย ย ย ย ย ย ย ย if unused_nodes:
ย ย ย ย ย ย ย ย ย ย ย ย issues["Unused Nodes"] = unused_nodes
ย ย ย ย 
ย ย ย ย if rules.get("duplicate_objects"):
ย ย ย ย ย ย ย ย duplicates = {}
ย ย ย ย ย ย ย ย objects = cmds.ls(transforms=True)
ย ย ย ย ย ย ย ย seen = {}
ย ย ย ย ย ย ย ย for obj in objects:
ย ย ย ย ย ย ย ย ย ย ย ย shape = cmds.listRelatives(obj, shapes=True)
ย ย ย ย ย ย ย ย ย ย ย ย if shape:
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย shape = shape[0]
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย if shape in seen:
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย duplicates.setdefault(shape, []).append(obj)
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย else:
ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย seen[shape] = obj
ย ย ย ย ย ย ย ย if duplicates:
ย ย ย ย ย ย ย ย ย ย ย ย issues["Duplicate Objects"] = duplicates
ย ย ย ย 
ย ย ย ย return issues
def generate_report(issues, report_file="scene_report.json"):
ย ย ย ย """
ย ย ย ย Generates a report of the issues found in the Maya scene.
ย ย ย ย 
ย ย ย ย :param issues: <dict> Dictionary of issues found.
ย ย ย ย :param report_file: <str> Path to the JSON file to save the report.
ย ย ย ย """
ย ย ย ย with open(report_file, 'w') as file:
ย ย ย ย ย ย ย ย json.dump(issues, file, indent=4)
ย ย ย ย cmds.inViewMessage(amg='Scene Validation Report Generated.', pos='midCenter', fade=True)
ย ย ย ย print("Scene validation report saved to '{}'.".format(report_file))
def sceneValidatorPro(rules_file=None, generate_report_flag=True):
ย ย ย ย """
ย ย ย ย Validates the current Maya scene based on predefined or custom rules.
ย ย ย ย 
ย ย ย ย :param rules_file: <str> Path to the JSON file containing validation rules.
ย ย ย ย :param generate_report_flag: <bool> Whether to generate a report.
ย ย ย ย """
ย ย ย ย rules = load_validation_rules(rules_file)
ย ย ย ย issues = analyze_scene(rules)
ย ย ย ย if issues:
ย ย ย ย ย ย ย ย print("Issues found during scene validation:")
ย ย ย ย ย ย ย ย for category, items in issues.items():
ย ย ย ย ย ย ย ย ย ย ย ย print("{}: {}".format(category, items))
ย ย ย ย ย ย ย ย if generate_report_flag:
ย ย ย ย ย ย ย ย ย ย ย ย generate_report(issues)
ย ย ย ย else:
ย ย ย ย ย ย ย ย cmds.inViewMessage(amg='No issues found in the scene.', pos='midCenter', fade=True)
ย ย ย ย ย ย ย ย print("No issues found in the scene.")
ย ย ย ย 
ย ย ย ย if not issues:
ย ย ย ย ย ย ย ย cmds.inViewMessage(amg='Scene is clean!', pos='midCenter', fade=True)
ย ย ย ย else:
ย ย ย ย ย ย ย ย cmds.inViewMessage(amg='Scene validation complete with issues.', pos='midCenter', fade=True)
# Usage example:
# Validate the scene with default rules and generate a report
# sceneValidatorPro()
# Validate the scene with custom rules
# sceneValidatorPro(rules_file='path/to/custom_rules.json')

๐Ÿ› ๏ธ ๐™Ž๐™˜๐™š๐™ฃ๐™š๐™‘๐™–๐™ก๐™ž๐™™๐™–๐™ฉ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ” (๐™‹๐™ฎ๐™Ž๐™ž๐™™๐™š2 ๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ):

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

๐Ÿ” ๐™’๐™๐™–๐™ฉ ๐™Ž๐™˜๐™š๐™ฃ๐™š๐™‘๐™–๐™ก๐™ž๐™™๐™–๐™ฉ๐™š๐™ง๐™‹๐™ง๐™ค ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ” ๐™Š๐™›๐™›๐™š๐™ง๐™จ:

  • Scene Analysis:ย Automatically scans your scene for inconsistencies, such as missing textures, unused nodes, and duplicate objects.

  • Error Reporting:ย Generates detailed reports highlighting the issues found, enabling you to address them promptly.

  • Automated Fixes:ย Provides options to automatically fix common issues, streamlining your workflow and saving valuable time.

  • Custom Validation Rules:ย Allows you to define custom validation rules tailored to your project's specific needs.

  • User-Friendly Interface:ย Intuitive UI designed to make scene validation effortless and efficient for artists of all levels.

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

โ€ข ๐Ÿš€ Boost Productivity:ย Save time on analyzing and fixing scene issues manually by automating the validation process.

โ€ข ๐Ÿ› ๏ธ Enhance Workflow:ย Ideal for projects with complex scenes, ensuring consistency and efficiency across your workflows.

โ€ข ๐Ÿ“ˆ Improve Consistency:ย Ensures all selected scenes are validated uniformly, enhancing project quality and manageability.

โ€ข ๐Ÿ’ก User-Friendly Interface:ย Intuitive UI suitable for artists of all levels, making scene validation seamless and efficient.

โœจ Ready to Optimize Your Scene Management?

Try out SceneValidatorProย today and enhance your Maya workflow! Feel free to reach out or comment below to see it in action. Let's continue to elevate our Maya scripting together! ๐Ÿ’ช๐ŸŽ‰

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

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

  • Scene Analysis:ย For more advanced functionality, consider adding features to analyze scene complexity before validation.

  • Error Handling:ย The scripts include checks for rules selection and handle cases with no issues gracefully.

  • Customization:ย Extend the tool to include options like specifying different validation categories, handling specific scene components, or integrating with other scene management tools.

  • Integration:ย Add this tool to your Maya shelf or integrate it into existing scripts for quick and easy access during your workflow.

2 views0 comments

Comments


bottom of page