PCL Reference Manual > Introduction > Session Files to PCL Files
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Session Files to PCL Files
Patran implements the PCL language as a tool used to implement the user interface and much of the functionality presented to the user. As individual tasks are performed by the user the PCL commands used to implement those tasks are listed to a session file with a name such as patran.ses.xx. These session files and the commands listed in them can be used to create custom functions in pcl files to provide new operations. Custom functionality of this type can be used to automate repeated tasks or used to create Tutorial applications.
A custom function can be created by copying a series of commands form a session file into a file with a .pcl extension. Place the keyword FUNCTION at the front of the file and the keyword END FUNCTION at the end of the file. Choose the dependant variables that define the inputs and outputs to the function.
The original session file will contain comments that can be discarded as needed. Patran will write many arguments as literal values. Path and file arguments passed will need to modified so that they are are relative rather than absolute.
The PCL file can then be compiled and loaded into patran were it can be used like any other PCL function.
The following session file can be used as an example of how this can be done. This session file was created using the Clevis Pin Contact Tutorial application by following the "Create the model Geometry step by step" directions.
            $# Session file patran.ses.01 started recording at 02-Mar-09 09:55:10
            $# FLEXlm initialization complete.  Acquiring license(s)...
            $# Loading dynamic library 
            $# Tutorial version: 2008; Mon Mar 31 13:57:52 PDT 2008; Tutorial shared 
            $# object version: Wed Mar 26 13:52:38 PDT 2008; Tutorial patran version: 
            $# 161062; Tutorial internal version: 31
            AAUI.mainpanel_lock_steps()
            tutorial.setup_app()
            AAUI.mainpanel_lock_steps()
            tutorial.setup_app()
            AAI.html_calls("FUNC:clevis_pin.setup_app")
            clevis_pin.setup_app()
            pcc.database_display("pcc.xio","db_open")
            AAUI.mainpanel_lock_steps()
            uil_file_new.go( "g:/patran/p3_home/template.db",  "d:\tempb\clevis.db" )
            $# Copying g:/patran/p3_home/template.db to 
            $# d:\tempb\clevis.db
            $# Template copy complete.
            $# Creating journal file d:\tempb\clevis.db.jou at 02-Mar-09 09:55:27
            AAI.html_calls("FUNC:pcc.new_db_hide;                         FUNC:pcc_geo" // @
            "m.set_analysis_preference;                         FUNC:pcc.goto_clevis;S" // @
            "TR:pcc_construct_model.xml;STR:pcc.xml;STR:db_not_open")
            pcc.new_db_hide()
            pcc_geom.set_analysis_preference()
            pcc.goto_clevis("pcc_construct_model.xml","pcc.xml","db_not_open")
            pcc.reset_clevis("pcc_construct_model.xml")
            AAI.html_calls("FUNC:pcc.goto_geometry;STR:pcc_geometry.xio")
            pcc.goto_geometry("pcc_geometry.xio")
            AASTATE.store_objectives()
            pcc_geom.settings_display(FALSE)
            $#~ STRING  s_cmnd_switch: uil_pref_picking.rectpoly_option( "1","ON" )
            AASTATE.store_objectives()
            pcc_geom.settings_hide()
            pcc_geom.pref_display(FALSE)
            $#~ STRING  s_cmnd_switch: uil_pref_geometry.switch_value( "25","ON" )
            pref_geometry_set_v4( FALSE, TRUE, FALSE, TRUE, 39.370079, FALSE, TRUE )
            AASTATE.store_objectives()
            pcc_geom.pref_hide()
            pcc_geom.pnt_inner_display(FALSE)
            STRING asm_create_grid_xyz_created_ids[VIRTUAL]
            asm_const_grid_xyz( "1", "[ 1 0 0]", "Coord 0",  @
            asm_create_grid_xyz_created_ids )
            $# 1 Point created: Point 1
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.rad_inner_display("45.0","0.0",FALSE)
            STRING sgm_sweep_curve_rev_created_ids[VIRTUAL]
            sgm_const_curve_revolve( "1", "Coord 0.3", 45., 0., "Coord 0", "Point 1",  @
            sgm_sweep_curve_rev_created_ids )
            $# 1 Curve Created: Curve 1
            sgm_const_curve_revolve( "2", "Coord 0.3", 45., 45., "Coord 0", "Point 1",  @
            sgm_sweep_curve_rev_created_ids )
            $# 1 Curve Created: Curve 2
            sgm_const_curve_revolve( "3", "Coord 0.3", 45., 90., "Coord 0", "Point 1",  @
            sgm_sweep_curve_rev_created_ids )
            $# 1 Curve Created: Curve 3
            sgm_const_curve_revolve( "4", "Coord 0.3", 45., 135., "Coord 0", "Point 1",  @
            sgm_sweep_curve_rev_created_ids )
            $# 1 Curve Created: Curve 4
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.coord_display(FALSE)
            STRING asm_create_cord_3po_created_ids[VIRTUAL]
            asm_const_coord_3point( "1", "Coord 0", 2, "[0 0 0]", "[0 0 1]", "[1 0 0]",  @
            asm_create_cord_3po_created_ids )
            $# 1 Coord created: Coord 1
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.rad_outer_display(FALSE)
            $#~ STRING  s_cmnd_switch: sgm_transform_curve_translate.trans_option( "curv","ON" )
            $# Warning reported from application Geometry
            $#     Curvilinear transformation requires parametric cubic geometry, 
            $# therefore, an approximation of general curve(s) into parametric cubic(s) 
            $# will occur. The results may not meet your acceptance criteria for accuracy.
            STRING sgm_transform_curve_created_ids[VIRTUAL]
            asm_transform_line_translate_1( "5", "<1 0 0>", "Coord 1", 1, TRUE, FALSE,  @
            "Curve 1 2", sgm_transform_curve_created_ids )
            $# The maximum error of 0.000516881 occurred during approximation of general 
            $# curve(s) into Parametric Cubic(s).
            $# 2 Lines created: Line 5,6
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.bdy_surf_display(FALSE)
            STRING asm_create_patch_xy_created_ids[VIRTUAL]
            asm_const_patch_xyz( "1", "<-4,2,0>", "[-2,0,0]", "Coord 0",  @
            asm_create_patch_xy_created_ids )
            $# 1 Patch created: Patch 1
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.bdy_crv_srf_display("Curve~1~2","Curve~5~6",FALSE)
            STRING sgm_surface_2curve_created_ids[VIRTUAL]
            sgm_const_surface_2curve( "2", "Curve 1 2", "Curve 5 6",  @
            sgm_surface_2curve_created_ids )
            $# 2 Surfaces Created: Surfaces 2,3
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.bdy_crv_srf_display("Curve~4","Surface~1.1",FALSE)
            STRING sgm_surface_2curve_created_ids[VIRTUAL]
            sgm_const_surface_2curve( "4", "Curve 4", "Surface 1.1",  @
            sgm_surface_2curve_created_ids )
            $# 1 Surface Created: Surface 4
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.bdy_crv_srf_display("Curve~3","Construct~2PointCurve(Evaluate~Geo" // @
            "metry(Point~8))(Evaluate~Geometry(Point~10))",FALSE)
            STRING sgm_surface_2curve_created_ids[VIRTUAL]
            sgm_const_surface_2curve( "5", "Curve 3",  @
            "Construct 2PointCurve(Evaluate Geometry(Point 8))(Evaluate Geometry(Point" // @
            " 10))", sgm_surface_2curve_created_ids )
            $# 1 Surface Created: Surface 5
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.solid_display(FALSE)
            STRING sgm_sweep_solid_nor_created_ids[VIRTUAL]
            sgm_const_solid_normal( "1", "0.25", "", "", "", FALSE, "Surface 1:5",  @
            sgm_sweep_solid_nor_created_ids )
            $# 5 Solids Created: Solids 1:5
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.mirror_bot_display(FALSE)
            STRING sgm_transform_solid_created_ids[VIRTUAL]
            ge_transform_mirror( "6", "solid", "Coord 0.2", 0., TRUE, FALSE, "Solid 1:5",  @
            sgm_transform_solid_created_ids )
            $# 5 Solids Created: Solids 6:10
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.remain_solid_display(FALSE)
            $#~ STRING  s_sel_cmnd: sgm_transform_trans_cart.eval_magnitude("VALUE_CHANGED")
            STRING sgm_transform_solid_created_ids[VIRTUAL]
            ge_transform_translate_v1( "11", "solid", "<0,0,-1>", 0.25, FALSE, "Coord 0",  @
            2, FALSE, "Solid 1 6", sgm_transform_solid_created_ids )
            $# 4 Solids Created: Solids 11:14
            AASTATE.store_objectives()
            pcc_geom.geometry_hide()
            pcc_geom.remain_clevis_display(FALSE)
            $#~ STRING  s_sel_cmnd: sgm_transform_trans_cart.eval_magnitude("VALUE_CHANGED")
            STRING sgm_transform_solid_created_ids[VIRTUAL]
            ge_transform_translate_v1( "15", "solid",  @
            "Construct 2PointVector(Evaluate Geometry(Point 10))(Evaluate Geometry(Poi" // @
            "nt 40))", 0.5, FALSE, "Coord 0", 1, FALSE, "Solid 2:5 7:10",  @
            sgm_transform_solid_created_ids )
            $# 8 Solids Created: Solids 15:22
            uil_file_close.goquit(  )
            $# Journal file stopped recording at 02-Mar-09 09:58:21
            $# Session file patran.ses.01 stopped recording at 02-Mar-09 09:58:21
Edit this session file by removing all unneeded functions such as all "AASTATE.XXX", "AAUI.xxx", "AAI.xxx" and "pcc_xxx.xxx" functions. Copy the remainder into a file with a .PCL extension. Add the "FUNCTION" and "END FUNCTION" keywords around the code. Decide what you want for inputs and outputs you need for the function and edit the code into what you need as in the following example. Much of the editing will replace hard coded geometry id values with the id values returned by function calls used to make the preceding geometry.
For this example the ability to define the location of the clevis and the diameter of the hole in the clevis where chosen as inputs.
Note:  
Note that this function is incomplete. Some of the items that could be added to this function are:
Inputs to control the orientation of the clevis.
Inputs to control the size of the clevis.
Outputs to list the solids created by this function.
Error handling.
         FUNCTION create_clevis  ( r_dia, r_x, r_y, r_z  )
         
            REAL     r_dia
            REAL     r_x
            REAL     r_y
            REAL     r_z
         
            INTEGER  i_end
            INTEGER  i_strt
            REAL     r_base_x
            REAL     r_base_y
            REAL     r_base_z
            STRING   coord_id_01    [VIRTUAL]
            STRING   coord_id_02    [VIRTUAL]
            STRING   created_ids    [VIRTUAL]
            STRING   curve_id_1     [VIRTUAL]
            STRING   curve_id_2     [VIRTUAL]
            STRING   curve_id_3     [VIRTUAL]
            STRING   curve_id_4     [VIRTUAL]
            STRING   curve_id_56    [VIRTUAL]
            STRING   deleted_ids    [VIRTUAL]
            STRING   line_ids       [VIRTUAL]
            STRING   point_id       [VIRTUAL]
            STRING   s_temp         [VIRTUAL]
            STRING   s_vect         [VIRTUAL]
            STRING   solid_ids      [VIRTUAL]
            STRING   solid_ids_16   [VIRTUAL]
            STRING   solid_ids_610  [VIRTUAL]
            STRING   solid_ids_lst  [VIRTUAL]
            STRING   surface_id_1   [VIRTUAL]
            STRING   surface_id_15  [VIRTUAL]
            
            s_temp   =  "["            // str_from_real ( r_x )
            s_temp   =  s_temp // " "  // str_from_real ( r_y )
            s_temp   =  s_temp // " "  // str_from_real ( r_z ) // "]"
            
            #  Create a throw away surface to help in the construction
            #  of a coordinate system used to locate the clevis.
            #  The "#" in the first argument tells the function
            #  to use the next available surface id.
            asm_const_patch_xyz   ( "#", "<1 1 0>", s_temp, "Coord 0",  surface_id_1 )
            
            #  Create a rectangular coordinate system for a starting point
            #  This will make it easier to set the origin of our clevis.
            asm_const_coord_normal_v2( "#", "Coord 0", surface_id_1, 1, s_temp, TRUE,  coord_id_01 )
            
            asm_delete_surface( surface_id_1, deleted_ids )
            
            s_temp   =  "[" // str_from_real ( r_dia )
            s_temp   =  s_temp // " 0 0]"
            
            #  Create a starting point for an initial curve.
            asm_const_grid_xyz( "#", s_temp, coord_id_01, point_id )
            
            # Create the curves for the inner part of the clevis
            sgm_const_curve_revolve( "#", coord_id_01 // ".3", 45., 0.,  coord_id_01, point_id, curve_id_1 )
            
            sgm_const_curve_revolve( "#", coord_id_01 // ".3", 45., 45.,  coord_id_01, point_id, curve_id_2 )
            
            sgm_const_curve_revolve( "#", coord_id_01 // ".3", 45., 90.,  coord_id_01, point_id, curve_id_3 )
            
            sgm_const_curve_revolve( "#", coord_id_01 // ".3", 45., 135., coord_id_01, point_id, curve_id_4 )
            
            #  Delete the no longer needed initial point.
            asm_delete_point( point_id, deleted_ids )
            
            #  Construct a cylindrical coordinate system for use as another construction tool.
            asm_const_coord_3point( "#", coord_id_01, 2, "[0 0 0]", "[0 0 1]", "[1 0 0]", coord_id_02 )
            
            r_base_x =  2.0 - r_dia
            
            s_temp   =  "<" // str_from_real ( r_base_x )
            s_temp   =  s_temp // " 0 0>"
            
            #  Construct the outer radius curve for the clevis
            asm_transform_line_translate_1( "#", s_temp, coord_id_02, 1, TRUE, FALSE,  curve_id_1 // " " // curve_id_2, line_ids )
            
            asm_delete_coord( coord_id_02, deleted_ids )
            
            i_end       =  str_length ( line_ids )
            i_strt      =  str_index  ( line_ids, " " )
            s_temp      =  str_substr ( line_ids, i_strt, i_end )
            i_strt      =  str_to_integer ( s_temp )
            curve_id_56 =  "Curve " // str_from_integer ( i_strt ) // " "
            i_strt      =  str_index  ( line_ids, "," ) + 1
            s_temp      =  str_substr ( line_ids, i_strt, i_end )
            i_strt      =  str_to_integer ( s_temp )
            curve_id_56 =  curve_id_56 // str_from_integer ( i_strt )
            
            #  Construct a surface that will be used to define the body of the clevis.
            #  The vector and location for this surface do no need to be adjusted
            #  as they are relative to the constructed coordinate system
            #  used to locate the clevis.
            asm_const_patch_xyz( "#", "<-4 2 0>", "[-2 0 0]", coord_id_01,  created_ids )
            
            i_end          =  str_length ( created_ids )
            i_strt         =  str_index  ( created_ids, " " )
            s_temp         =  str_substr ( created_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            surface_id_1   =  "Surface "  // str_from_integer ( i_strt )
            
            sgm_const_surface_2curve( "#", curve_id_1 // " " // curve_id_2, curve_id_56, created_ids )
            
            s_temp   =  surface_id_1 // ".1"
            
            sgm_const_surface_2curve( "#", curve_id_4, s_temp, created_ids )
            
            r_base_x    =  r_x
            r_base_y    =  r_y   +  2.0
            r_base_z    =  r_z   
            
            s_vect   =  "["            // str_from_real  (  r_base_x )
            s_vect   =  s_vect // " "  // str_from_real  (  r_base_y )
            s_vect   =  s_vect // " "  // str_from_real  (  r_base_z ) // "]"
            
            r_base_x    =  r_x   + -2.0
            r_base_y    =  r_y   +  2.0
            r_base_z    =  r_z   
            
            s_temp   =  "["            // str_from_real  (  r_base_x )
            s_temp   =  s_temp // " "  // str_from_real  (  r_base_y )
            s_temp   =  s_temp // " "  // str_from_real  (  r_base_z ) // "]"
            
            #  Create a line to help construct the last surface.
            #  This line replaces 
            #  "Construct 2PointCurve(Evaluate Geometry(Point 8))(Evaluate Geometry(Point 10))"
            #  in the session file.
            asm_const_line_2point( "#", s_vect, s_temp, 0, "", 50., 1, created_ids )
            
            i_end          =  str_length ( created_ids )
            i_strt         =  str_index  ( created_ids, " " )
            s_temp         =  str_substr ( created_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            s_temp         =  "Curve "  // str_from_integer ( i_strt ) 
            
            sgm_const_surface_2curve( "#", curve_id_3, s_temp, created_ids )
            
            asm_delete_curve( curve_id_1,  deleted_ids )
            asm_delete_curve( curve_id_2,  deleted_ids )
            asm_delete_curve( curve_id_3,  deleted_ids )
            asm_delete_curve( curve_id_4,  deleted_ids )
            asm_delete_curve( curve_id_56, deleted_ids )
            asm_delete_curve( s_temp,      deleted_ids )
            
            i_end          =  str_length ( created_ids )
            i_strt         =  str_index  ( created_ids, " " )
            s_temp         =  str_substr ( created_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            surface_id_15  =  surface_id_1 // ":"  // str_from_integer ( i_strt ) 
            
            sgm_const_solid_normal( "#", "0.25", "", "", "", FALSE, surface_id_15, solid_ids )
            
            asm_delete_surface( surface_id_1,  deleted_ids )
            asm_delete_surface( surface_id_15, deleted_ids )
            
            ge_transform_mirror( "#", "solid", coord_id_01 // ".2", 0., TRUE, FALSE, solid_ids, solid_ids_610 )
            
            i_end          =  str_length ( solid_ids )
            i_strt         =  str_index  ( solid_ids, " " )
            s_temp         =  str_substr ( solid_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            solid_ids_16   =  "Solid " // str_from_integer ( i_strt ) 
            
            i_end          =  str_length ( solid_ids_610 )
            i_strt         =  str_index  ( solid_ids_610, " " )
            s_temp         =  str_substr ( solid_ids_610, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            solid_ids_16   =  solid_ids_16 // " " // str_from_integer ( i_strt ) 
            
            ge_transform_translate_v1( "#", "solid", "<0,0,-1>", 0.25, FALSE, coord_id_01, 2, FALSE, solid_ids_16, created_ids )
            
            i_end          =  str_length ( solid_ids )
            i_strt         =  str_index  ( solid_ids, " " )
            s_temp         =  str_substr ( solid_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            i_strt         =  i_strt + 1
            solid_ids_lst  =  "Solid " // str_from_integer ( i_strt ) // ":"
            
            i_end          =  str_length ( solid_ids )
            i_strt         =  str_index  ( solid_ids, ":" ) + 1
            s_temp         =  str_substr ( solid_ids, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            solid_ids_lst  =  solid_ids_lst // str_from_integer ( i_strt ) // " "
            
            i_end          =  str_length ( solid_ids_610 )
            i_strt         =  str_index  ( solid_ids_610, " " )
            s_temp         =  str_substr ( solid_ids_610, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            i_strt         =  i_strt + 1
            solid_ids_lst  =  solid_ids_lst // str_from_integer ( i_strt ) // ":"
            
            i_end          =  str_length ( solid_ids_610 )
            i_strt         =  str_index  ( solid_ids_610, ":" ) + 1
            s_temp         =  str_substr ( solid_ids_610, i_strt, i_end )
            i_strt         =  str_to_integer ( s_temp )
            solid_ids_lst  =  solid_ids_lst // str_from_integer ( i_strt )
         
            ge_transform_translate_v1( "#", "solid", "<0,0,-1>", 0.5, FALSE, coord_id_01, 1, FALSE, solid_ids_lst, created_ids )
            
            asm_delete_coord( coord_id_01, deleted_ids )
            
         END FUNCTION
         
      Finally this function can be run using a session file as follows:
      
         uil_file_close.go          (  )
         uil_file_new.go( "", "db_session_to_pcl.db" )
         $? YES 36000002
         
         ga_viewport_location_set   ( "default_viewport", 0.0, 0.0, 1 )
         ga_viewport_size_set       ( "default_viewport", 4.5, 4.5, 1 )
         
         !!compile demo_func.pcl into demo_lib.plb
         !!library demo_lib.plb
         
         create_clevis              ( 1.0, 1.0, 5.0, 1.0 )
         
         create_clevis              ( 0.5, 0.0, 0.0, 0.0 )
         
         gu_fit_view                (  )
      
End of File.