Parameterize Coordinate System Transformation

Goal

The following script demonstrates how to parameterize a coordinate system transformation.

Code PyCode_OnAfterObjectChanged

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

    # We ignore any changes other than changes made to the this python code object itself
    # We listen for any changes made to this object so we can sync up paramterized properties
    # with the coordinate system, everytime the design point updates happen
    if this.DataModelObjectCategory != object_changed.DataModelObjectCategory:
        return
    
    my_coordinate_system = ExtAPI.DataModel.GetObjectsByName("my CS")[0]
    coordinate_system_props=my_coordinate_system.Properties
    
    # Sync up the paramterized properties on this object with the coordinate system
    for prop in coordinate_system_props:
        if prop.Name.find("Transform") != -1:
            newVal=this.GetCustomPropertyByPath("CS Transformations/"+prop.Caption)
            prop.InternalValue=newVal

PyCode_OnBeforeSolve

def before_solve(this, analysis):# Do not edit this line
    """
    Called before solving the parent analysis.
    Keyword Arguments : 
        this -- the datamodel object instance of the python code object you are currently editing in the tree
        analysis -- Static Structural
    """
    
    # Log out the values of properties with the name that contain "Transform"
    # to demonstrate the values for the coordinate system are parameterized
    
    import os
    import os.path
    sys.path.append(os.getenv("TB_WORKING_DIRECTORY"))
    WDIR = os.getenv("TB_WORKING_DIRECTORY")
    fo2 = open(WDIR + "/DS_PYTHON_SNIPPET_019_Generated.log","a")
    
    fo2.writelines(" ==== Scenario Starts here ==== " + "\n" )
    fo2.writelines("Property Values for Coordinate System set through Parameter Set:" + "\n" )
    my_coordinate_system = ExtAPI.DataModel.GetObjectsByName("my CS")[0]
    coordinate_system_props=my_coordinate_system.Properties
    # Log out the values of the properties
    for prop in coordinate_system_props:
        if prop.Name.find("Transform") != -1:
            fo2.writelines(prop.Caption + " = " + str(prop.InternalValue) + "\n")
    fo2.writelines("Property Values for Coordinate System in UI:" + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[17].Caption + " = " + str(my_coordinate_system.VisibleProperties[17].StringValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[18].Caption + " = " + str(my_coordinate_system.VisibleProperties[18].StringValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[19].Caption + " = " + str(my_coordinate_system.VisibleProperties[19].StringValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[20].Caption + " = " + str(my_coordinate_system.VisibleProperties[20].InternalValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[21].Caption + " = " + str(my_coordinate_system.VisibleProperties[21].InternalValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[22].Caption + " = " + str(my_coordinate_system.VisibleProperties[22].InternalValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[23].Caption + " = " + str(my_coordinate_system.VisibleProperties[23].StringValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[24].Caption + " = " + str(my_coordinate_system.VisibleProperties[24].StringValue) + "\n" )
    fo2.writelines(my_coordinate_system.VisibleProperties[25].Caption + " = " + str(my_coordinate_system.VisibleProperties[25].StringValue) + "\n" )
    fo2.writelines(" ==== Scenario Ends here ==== " + "\n" )
    fo2.close()