Send a Warning Message

Goal

The following script sends a warning message if a contact has been changed. It retrieves the contact's name, changed property and new value.

Code

def after_object_changed(this, object_changed, property_name):# Do not edit this line
    """
    Called after an object is changed.
    Keyword Arguments : 
        this -- this python object
        object_changed -- The object that was changed
        property_name -- The property that was changed
    """
    
    # This script sends a warning message if a contact has been changed
    # It retrieves the contact name, changed property and new value
    
    # The script is working with 'after object changed' callback
    # The Python code object may be located under model, analysis or solution
    
    # The If statement allows to act only when a certain type of object has been changed
    if (object_changed.GetType()==Ansys.ACT.Automation.Mechanical.Connections.ContactRegion):
        msg = Ansys.Mechanical.Application.Message('You changed the following object : '+object_changed.Name+
        '\n Property '+property_name+' has been set to '+str(getattr(object_changed,property_name)), MessageSeverityType.Warning)
        ExtAPI.Application.Messages.Add(msg)