โจ๐ฏ ๐ฟ๐๐ฎ03 - ๐จ๐๐ค๐ฌ๐๐๐๐๐จ๐๐ฅ๐๐๐จ๐จ๐๐๐ ๐จ๐
Hello Maya enthusiasts and Python coders! ๐
I'm excited to share another powerful utility to elevate your Maya scripting workflowโshowHeadsUpMessage! ๐
In the dynamic world of VFX and Animation, effective communication within your pipeline is key. showHeadsUpMessage leverages Maya's headsUpDisplayย command to provide persistent, in-viewport messages that keep you informed without interrupting your creative process. Whether you're monitoring script progress, displaying critical information, or enhancing user interactions, this tool is a game-changer. Letโs dive into its features:
๐จ ๐๐ฃ๐ฉ๐ง๐ค๐๐ช๐๐๐ฃ๐ ๐๐๐๐๐จ๐๐ฅ๐๐ฉ๐ฎ๐ก๐๐๐
Our new UI, HeadsUpStyleUI, is designed to be sleek, stylish, and seamlessly integrates into your Maya workspace. Here's what it includes:
Heads-Up Display (HUD): Shows persistent messages directly in the viewport.
Status Indicator: Provides real-time updates on ongoing processes.
Clear Button: Allows users to remove the HUD message when needed.
Agave Font: Ensures all UI elements have a consistent and modern typography.
All UI elements are crafted using the elegant Agave font, ensuring a cohesive and professional look.
๐ ๏ธ ๐จ๐๐ค๐ฌ๐๐๐๐๐จ๐๐ฅ๐๐๐จ๐จ๐๐๐ ๐พ๐ค๐๐ ๐๐ฃ๐๐ฅ๐ฅ๐๐ฉ:
##1
import maya.cmds as cmds
def show_confirm_dialog(title="Confirmation", message="Operation completed successfully!"):
"""
Displays a simple confirmation dialog with an OK button.
Parameters:
title (str): The title of the dialog window.
message (str): The message displayed in the dialog.
Example:
show_confirm_dialog("Save Status", "Your file has been saved successfully.")
"""
cmds.confirmDialog(
title=title,
message=message,
button=['OK'],
defaultButton='OK',
dismissString='OK'
)
# Example Usage:
if __name__ == "__main__":
show_confirm_dialog("Process Complete", "Your animation render has finished successfully!")
##2
cmds.confirmDialog(
title='Delete Confirmation',
message='Are you sure you want to delete this asset?',
button=['Yes', 'No'],
defaultButton='Yes',
cancelButton='No',
dismissString='No'
)
##3
result = cmds.confirmDialog(
title='Save Changes',
message='Do you want to save changes before exiting?',
button=['Save', 'Don\'t Save', 'Cancel'],
defaultButton='Save',
cancelButton='Cancel',
dismissString='Cancel'
)
if result == 'Save':
# Call save function
save_project()
elif result == 'Don\'t Save':
# Proceed without saving
exit_project()
else:
# Cancel the exit process
pass |
๐จ๐๐ค๐ฌ๐๐๐๐๐จ๐๐ฅ๐๐๐จ๐จ๐๐๐ ๐๐ฎ๐๐๐๐2 ๐๐๐ง๐จ๐๐ค๐ฃ
[Todayโs Challenge is to take this simple code to next level.. I am sharing images of these advanced codes... Due to space constraints, I couldnโt share those codes here.. But checking for the other possibilities] ##4 from PySide2 import QtWidgets, QtCore, QtGui def number_of_block(): """ Determines the next available block number for the HUD.
:return: <int> The next block number. """ try: existing_blocks = mc.headsUpDisplay(query=True, blockArray=True) if existing_blocks: return max(existing_blocks) + 1 except: pass return 1 def showHeadsUpMessage(message, section='center', block=None): """ Displays a heads-up message in the Maya viewport.
:param message: <str> The message to display. :param section: <str> The section of the HUD to display the message in. :param block: <int> The block number within the section. If None, it determines the next available block. :return: <None> """ if block is None: block = number_of_block()
hud_name = 'HeadsUpStyleHUD'
# Remove existing HUD with the same name to prevent duplication if mc.headsUpDisplay(hud_name, exists=True): mc.headsUpDisplay(hud_name, remove=True)
# Add new HUD message with advanced configuration try: mc.headsUpDisplay( hud_name, section=section, block=block, label=message, event='idle', command='return "{}"'.format(message), font='fixedWidthFont', # 'fixedWidthFont' for better clarity in heads-up messages commandAlignment='left', dataFontSize='large' # Ensures the message is clear and prominent ) except Exception as e: mc.warning("Failed to create HeadsUpDisplay: {}".format(e)) # Heads-Up UI for managing messages class HeadsUpStyleUI(QtWidgets.QWidget): def __init__(self): super(HeadsUpStyleUI, self).__init__() self.setWindowTitle("HeadsUpStyleUI") self.setObjectName('HeadsUpStyleUI') self.setStyleSheet(""" QWidget#HeadsUpStyleUI { background-color: #333333; border: 2px solid #555555; border-radius: 10px; } QLabel { font-family: 'Agave'; color: #F5F5F5; /* Light text */ } QPushButton { font-family: 'Agave'; background-color: #4A4A4A; color: #FFFFFF; border: 2px solid #FF914D; border-radius: 8px; padding: 8px 15px; transition: all 0.3s ease; } QPushButton:hover { background-color: #FF914D; color: #2C2C2C; border: 2px solid #F5F5F5; } QPushButton:pressed { background-color: #FF7043; border: 2px solid #FF914D; } """) layout = QtWidgets.QVBoxLayout()
# Status message label self.messageLabel = QtWidgets.QLabel("Heads-Up: Rendering in Progress...") self.messageLabel.setAlignment(QtCore.Qt.AlignCenter) layout.addWidget(self.messageLabel) # Clear button for removing HUD self.clearButton = QtWidgets.QPushButton("Clear Heads-Up") layout.addWidget(self.clearButton) self.setLayout(layout) self.setFixedSize(350, 150) self.clearButton.clicked.connect(self.clearMessage) def clearMessage(self): """ Clears the HeadsUpDisplay message. """ try: mc.headsUpDisplay('HeadsUpStyleHUD', remove=True) self.close() print("HeadsUpDisplay message cleared.") except Exception as e: mc.warning("Failed to remove HeadsUpDisplay: {}".format(e)) # Test function to demonstrate showHeadsUpMessage def test_showHeadsUpMessage(): """ Function to test the Heads-Up Message functionality. """ showHeadsUpMessage(message="Rendering in Progress...", section='center') print("HeadsUpMessage executed successfully.") # Running the UI standalone (for testing purposes) if __name__ == "__main__": # Test the heads-up display message functionality test_showHeadsUpMessage() # Show the custom UI for managing heads-up display messages window = HeadsUpStyleUI() window.show() |
๐ ๐๐๐๐ฉ ๐จ๐๐ค๐ฌ๐๐๐๐๐จ๐๐ฅ๐๐๐จ๐จ๐๐๐ ๐๐๐๐๐ง๐จ:
Persistent In-Viewport Messaging:ย Keeps you informed with continuous updates without intrusive dialogs.
Real-Time Status Updates:ย Monitor the progress of scripts or processes directly within the viewport.
User Control:ย Easily clear messages with a single click, maintaining a clutter-free workspace.
Stylish Integration:ย Modern UI design that complements Mayaโs interface, enhancing overall user experience.
๐ง ๐๐๐ฎ ๐ฝ๐๐ฃ๐๐๐๐ฉ๐จ:
โข ๐ Enhance Workflow Efficiency:ย Stay informed about script operations in real-time, reducing the need to switch contexts.
โข ๐ Improve User Feedback:ย Provide clear and immediate feedback, making your tools more intuitive and user-friendly.
โข ๐ Boost Productivity:ย Eliminate the need for external logs or manual checks, allowing you to focus more on creative tasks.
โข ๐ก Flexible Usage:ย Ideal for a variety of tasks, from rendering notifications to process tracking, adaptable to your specific pipeline needs.
I'm sharing showHeadsUpMessageย to help Maya developers and technical artists create more interactive and efficient scripts. Say goodbye to intrusive dialogs and hello to seamless, in-context updates that keep you in the flow!
โจ Ready to Enhance Your Maya Workflow?ย โจReach out or comment below to see showHeadsUpMessage in action. Letโs elevate our Maya scripting together! ๐ช๐
#Maya #PythonScripting #MayaTools #VFX #3DAnimation #ScriptDevelopment #MayaDevelopment #Automation #WorkflowEnhancement #TechnicalArt #ScriptingTools
Subbu's Linksโข YouTube Channel: https://lnkd.in/gZyWJN_yโข Vimeo: https://vimeo.com/subbu118โข Creature Rigging: https://lnkd.in/gNpibPndโข Hyper Rig: https://www.hyper-rig.com
Comments