"""
Contains helper methods for Mechanical.
"""

import System
import clr

def PhysicsTypeName(type):
    """
    Get the phisics type name from his type number.
    """
    if type == 0 : return 'Unknown'
    if type == 1 : return 'Mechanical'
    if type == 2 : return 'Thermal'
    if type == 3 : return 'Electromagnetic'
    if type == 4 : return 'ExplicitCDI'
    if type == 5 : return 'ElectricCond'
    if type == 6 : return 'ElectricTherm'
    if type == 7 : return 'Customizable'
    return 'Unknown'
    
def AnalysisTypeName(type):
    """
    Get the analysis type name from his type number.
    """
    if type == 0 : return 'Static'
    if type == 1 : return 'Harmonic'
    if type == 2 : return 'Transient'
    if type == 3 : return 'Spectrum'
    if type == 4 : return 'Buckling'
    if type == 5 : return 'Modal'
    if type == 6 : return 'Initial Contact'
    if type == 7 : return 'MBD'
    if type == 8 : return 'Shape'
    if type == 9 : return 'Response Spectrum'
    if type == 10 : return 'Explicit'
    if type == 11 : return 'Design Assessment'
    return 'Unknown'

def ClearMesh(ExtAPI):
    """
    Clear the current mechanical mesh.
    """
    ds = ExtAPI.DataModel.InternalObject["ds"]
    treeObjectSelection = AnsUINTColl()
        
    protoGroup = ds.Tree.FirstActiveBranch.PrototypeGroup
    numProtos = protoGroup.Prototypes.Count

    for i in range (1, numProtos+1):
        id = protoGroup.Prototypes.Item(i).ID
        treeObjectSelection.Add(id)

    ds.Tree.FirstActiveBranch.MeshControlGroup.CleanPartOrBody(treeObjectSelection)
    
