Importing a Load from External Data

The example script shown below uses the ExtAPI global variable to access the Mechanical DataModel. This example:

  • Gets a reference to a specific Imported Load object in the Outline.

  • Creates a load under the Imported Load object.

# Add imported convection
imp_load_grp=ExtAPI.DataModel.GetObjectsByName('Imported Load (A2) ')[0] # Object to which the imported load will be added
new_conv=imp_load_grp.AddImportedConvection() # Add imported convection


analysis_times=[0.,100.,200.,300.,400.,600.,800.,900.,1000.,1200.,1400.,1500.,1700.,1800.,2000.,2400.,2600.,3000.]    
fc_scaling=[0.,1.,1.,1.,0.,0.,0.,1.,0.,1.,1.,1.,2.,1.,1.,1.,.5,.25,1.,1.]
at_scaling=[.25,1.,1.,.95,.95,1.,1.,1.2,1.2,1.,1.,.95,.95,.5,.5,.2,.2,1.,1.]

fc_id='File1:HTC1' # identifier for film coefficient (should match External Data definition)
at_id='File1:Temperature1' # identifier for ambient temperature (should match External Data definition)

with Transaction(): #  avoid screen refresh until the table is filled
    row_index=0
    for row_index in range(len(analysis_times)):
        table=new_conv.GetTableByName("") # get the worksheet table. Must be done at every step to grab the full table
        row =table[row_index] # get row to be defined
        row[0]=fc_id # Identifier for film coefficient
        row[1]=at_id # identifier for ambient temperature 
        row[2]=analysis_times[row_index]
        row[3]=fc_scaling[row_index]
        row[5]=at_scaling[row_index]
        if row_index<len(analysis_times)-1:
            table.Add(None) # add a new row to the table
        row_index+=1

Referenced files in the External Data system include:

The script generates the following object and convection data: