After Object Changed Filtering

Goal

Goal: This Python script checks to see if the object that was changed is for a given category. Specifically, it checks whether a Pressure object was changed and if so, it prints its name to the log file. The script drops any events that are not associated with the Pressure object. To view the log file, from the Workbench Project page, select Extensions > View Log File.

Code

def after_object_changed(this, object_changed, property_name):# Do not edit this line
    """
    Called after an object is changed.
    Keyword Arguments : 
        this -- the datamodel object instance of the python code object you are currently editing in the tree
        object_changed -- The object that was changed
        property_name -- The property that was changed
    """


    # To access properties created using the Property Provider, please use the following command.
    # this.GetCustomPropertyByPath("your_property_group_name/your_property_name")

    # To access scoping properties use the following to access geometry scoping and named selection respectively:
    # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Geometry Selection")
    # this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Named Selection")
    
    # If you are intereseted in when pressure changes in any way, you can ignore all other object changed events
    # using the line below.
    if object_changed.DataModelObjectCategory != DataModelObjectCategory.Pressure:
        return
    
    ExtAPI.Log.WriteMessage("Pressure : " + str(property_name) + " changed.")
    
    pass