Tutorial Toolkit Code Examples > Load Cases > Introduction
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Introduction
This chapter provides code examples for the PCL function described in Volume 1. These examples are designed so that they can be cut and pasted into a file and, by following the instructions listed with each example, executed in MSC.Patran.
 
db_activate_load_case
()
#  Purpose          :  This file provides an example of 2 calls to the
#                      function db_activate_load_case()
#
#                      This function activates the specified load 
#                      case.
#
#                      In this example, a load case (new_lc1) is
#                      created. Then the load case is activated by  
#                      using this function. The name of the active
#                      load case is verified before and after
#                      activation by using the function
#                      db_get_active_load_case().
#
#                      Before running this session file run spool.ses
#                      to create spool.db
#
#                      This file can be run by starting a session of
#                      MSC.Patran, and running this session file
#                      through the “File”,”Session”,”Play” pulldown
#                      menus on the menu bar.
#
#  The function db_activate_load_case()
#  has the following arguments:
#
#  db_activate_load_case
#    ( lc_name ),
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_lc_name[16]
STRING   s_active_lc[16]
INTEGER  i_return_value
#---------------------------------------------------------------------
#  Open the database “spool.db”
uil_file_open.go(“spool.db”)
 
#  Create load Case “new_lc1”
loadcase_create2( “new_lc1”, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”], [0, 0]        @
                  , [1., 1.], ““, 0., FALSE )
 
#  Get active load_case
db_get_active_load_case(s_active_lc)
dump s_active_lc
 
#  Session file paused. Press “Resume” to continue..
sf_pause()
 
#  Activate load case “new_lc1”
s_lc_name = “new_lc1”
i_return_value =                                        @
   db_activate_load_case                                @
   ( s_lc_name )
dump i_return_value
 
#  Get active load_case
db_get_active_load_case(s_active_lc)
dump s_active_lc
 
#  Session file paused. Press “Resume” to continue..
sf_pause()
 
#  Activate load case “spool_loads”
s_lc_name = “spool_loads”
i_return_value =                                         @
   db_activate_load_case                                 @
   ( s_lc_name )
dump i_return_value
 
#  Delete load Case “new_lc1”
loadcase_delete( “new_lc1”, FALSE )
#---------------------------------------------------------------------
db_delete_load_case
()
#  Purpose          :  This file provides an example of a call to the
#                      function db_delete_load_case()
#
#                      This function deletes the specified load case.
#
#                      In this example, a load case (new_lc1) is
#                      created. Then the load case is deleted after
#                      a pause. Observation on list of available load
#                      cases is carried out before and after deletion
#
#                      Before running this session file run spool.ses
#                      to create spool.db
#
#                      This file can be run by starting a session of
#                      MSC.Patran, and running this session file
#                      through the “File”,”Session”,”Play” pulldown
#                      menus on the menu bar.
#
#  The function db_delete_load_case()
#  has the following arguments:
#
#  db_delete_load_case
#    ( lc_name ),
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_lc_name[16]
INTEGER  i_return_value
#---------------------------------------------------------------------
#  Open the database “spool.db”
uil_file_open.go(“spool.db”)
 
#  Create load Case “new_lc1”
s_lc_name = “new_lc1”
loadcase_create2( s_lc_name, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”], [0, 0]        @
                  , [1., 1.], ““, 0., FALSE )
 
#  Activate “Load Cases” of Application radio button and observe
#  the names of available load cases
 
#  Session file paused. Press “Resume” to continue..
sf_pause()
 
#  Delete load Case “new_lc1”
i_return_value =                                  @
   db_delete_load_case                            @
   ( s_lc_name )
dump i_return_value
 
#  It can be observed that the load case “new_lc1” getting removed
#  the list of available load cases
#---------------------------------------------------------------------
db_find_load_case_id
()
#  Purpose          :  This file provides an example of 2 calls to the
#                      function db_find_load_case_id()
#
#                      This function gets the load case ids from the
#                      database in one structure.
#
#                      In this example, 2 load cases (new_lc1,new_lc2)
#                      are created. Then the model is submitted for
#                      analysis as indicated in comments.
#
#                      The given are the details of load-cases used in
#                      this example.
#
#                        Load case name       id     Sequence no.
#                                                    for analysis
#
#                         Default              1          1
#                         spool_loads          2          4
#                         new_lc1              3          2
#                         new_lc2              4          3
#
#                      Before running this session file run spool.ses
#                      to create spool.db
#
#                      This file can be run by starting a session of
#                      MSC.Patran, and running this session file
#                      through the “File”,”Session”,”Play” pulldown
#                      menus on the menu bar.
#
#  The function db_find_load_case_id()
#  has the following arguments:
#
#  db_find_load_case_id
#    ( job_name,
#      lc_seq_no,
#      lc_id )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_job_name[16]
INTEGER  i_lc_seq_no
INTEGER  i_lc_id
INTEGER  i_return_value
#---------------------------------------------------------------------
#  Open the database “spool.db”
uil_file_open.go(“spool.db”)
 
#  Create load Case “new_lc1”
loadcase_create2( “new_lc1”, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”], [0, 0]        @
                  , [1., 1.], ““, 0., FALSE )
 
#  Create load Case “new_lc2”
loadcase_create2( “new_lc2”, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”,                @
                  “fillet_pressure”], [0, 0, 0],         @
                  [1., 1., 1.], ““, 0., FALSE )
 
#---------------------------------------------------------------------
#  Submit the model for analysis in MSC.Nastran by following the
#  given steps
#
#  1. Pick “MSC.Nastran” from “Preferences”, “Analysis...”
#     from Pulldown menus. Press “O.K” button.
#
#  2. Pick “Analysis” from Application radio buttons and
#     perform the following operations in the form.
#     (a)Give job-name as “spool”
#     (b)Select “Subcase Select” for fixing solution sequence
#     (c)Select the load cases(as sub-cases) in following order
#         “default”,”new_lc1”, “new_lc2”,”spool_loads”
#     (d)Press “Apply”
#
#  Note : Permit deletion of earlier existing job files if any.
#         Ignore the Warnings if any.
#
#---------------------------------------------------------------------
#  Session file paused. Press “Resume” to continue..
sf_pause()
 
#  Get the load case id
s_job_name = “spool”
i_lc_seq_no = 1
i_return_value =                                  @
   db_find_load_case_id                           @
   ( s_job_name,                                  @
     i_lc_seq_no,                                 @
     i_lc_id )
dump i_return_value
dump i_lc_id
 
#  Get the load case id
i_lc_seq_no = 2
i_return_value =                                  @
   db_find_load_case_id                           @
   ( s_job_name,                                  @
     i_lc_seq_no,                                 @
     i_lc_id )
dump i_return_value
dump i_lc_id
 
#---------------------------------------------------------------------
db_get_lc_id_given_job_seq
()
#  Purpose          :  This file provides an example of 2 calls to the
#                      function db_get_lc_id_given_job_seq()
#
#                      This function gets the load case ids from the
#                      database in one structure for a given
#                      analysis id.
#
#                      In this example, 2 load cases(new_lc1,new_lc2)
#                      are created. Then the model is submitted for
#                      analysis as indicated in comments.
#
#                      The given are the details of load-cases used in
#                      this example.
#
#                        Load case name       id     Sequence no.
#                                                    for analysis
#
#                         Default              1          1
#                         spool_loads          2          4
#                         new_lc1              3          2
#                         new_lc2              4          3
#
#
#                      Before running this session file run spool.ses
#                      to create spool.db
#
#                      This file can be run by starting a session of
#                      MSC.Patran, and running this session file
#                      through the “File”,”Session”,”Play” pulldown
#                      menus on the menu bar.
#
#  The function db_get_lc_id_given_job_seq()
#  has the following arguments:
#
#  db_get_lc_id_given_job_seq
#    ( ac_id,
#      job_name,
#      lc_seq,
#      lc_id )
#
#---------------------------------------------------------------------
#  Variable Declarations
INTEGER  i_ac_id
INTEGER  i_at_id
STRING   s_job_name[16]
INTEGER  i_lc_seq
INTEGER  i_lc_id
INTEGER  i_return_value
#---------------------------------------------------------------------
#  Open the database “spool.db”
uil_file_open.go(“spool.db”)
 
#  Create load Case “new_lc1”
loadcase_create2( “new_lc1”, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”], [0, 0]        @
                  , [1., 1.], ““, 0., FALSE )
 
#  Create load Case “new_lc2”
loadcase_create2( “new_lc2”, “Static”, ““, 1.,           @
                  [“TZ_fixed”, “400_psi”,                @
                  “fillet_pressure”], [0, 0, 0],         @
                  [1., 1., 1.], ““, 0., FALSE )
 
#---------------------------------------------------------------------
#  Submit the model for analysis in MSC.Nastran by following the
#  given steps
#
#  1. Pick “MSC.Nastran” from “Preferences”, “Analysis...”
#     from Pulldown menus.
#
#  2. Pick “Analysis” from Application radio buttons and
#     perform the following operations in the form.
#     (a)Give job-name as “spool”
#     (b)Select “Subcase Select” for fixing solution sequence
#     (c)Select the load cases(as sub-cases) in following order
#         “new_lc1”, “new_lc2”,”spool_loads”
#     (d)Press “Apply”
#
#  Note : Permit deletion of earlier existing job files if any.
#         Ignore the warnings if any.
#---------------------------------------------------------------------
#  Session file paused. Press “Resume” to continue..
sf_pause()
 
#  Get the analysis code and type id
ep_u_get_at_and_ac(i_at_id,i_ac_id)
 
#  Get the load case id
s_job_name = “spool”
i_lc_seq = 1
i_return_value =                                  @
   db_get_lc_id_given_job_seq                     @
   ( i_ac_id,                                     @
     s_job_name,                                  @
     i_lc_seq,                                    @
     i_lc_id )
dump i_return_value
dump i_lc_id
 
#  Get the load case id
i_lc_seq = 2
i_return_value =                                  @
   db_get_lc_id_given_job_seq                     @
   ( i_ac_id,                                     @
     s_job_name,                                  @
     i_lc_seq,                                    @
     i_lc_id )
dump i_return_value
dump i_lc_id
 
#---------------------------------------------------------------------