!   TITLE:  ln_cg.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This macro records the line numbers, length, end KP's, and centroidal
!   coordinates of each line in the selected set.
!
!
!   COMMAND SYNTAX:
!
!                   (1)
!           LN_CG, ln_#
!
!
!   ARGUMENTS:
!
!       (1) ln_# = line number
!
!             a.) 0 (or blank) = the current selected set of lines.
!
!             b.) N (where N > 0) = the line number N.
!
!             c.) 'comp_name' = component group character name containing
!                               the lines. [ MUST BE IN SINGLE QUOTES ]
!
!
!   DESCRIPTION:
!
!   The selected/specified line(s) are stored in an array named: LCG_DATA.
!   The array contains 9 pieces of data for each line:
!
!       1.) line number
!       2.) length
!       3.) KP # at the 1st end of the line
!       4.) KP # at the 2nd end of the line
!       5.) X-coordinate of line centroid (relative to csys = 0)
!       6.) Y-coordinate of line centroid (relative to csys = 0)
!       7.) Z-coordinate of line centroid (relative to csys = 0)
!
!   Each piece of data is stored in each column, with each row a line. The
!   array, LCG_DATA, has the following format:
!
!                                   COLUMNS
!      ROW  |   1    |  2   |   3   |   4   |   5   |   6   |   7   |
!    ----------------------------------------------------------------
!       1   |  L_#1  |  L1  |  KP11 | KP12  |  Xc1  |  Yc1  |  Zc1  |
!       2   |  L_#2  |  L2  |  KP21 | KP22  |  Xc2  |  Yc2  |  Zc2  |
!       3   |  L_#3  |  L3  |  KP31 | KP32  |  Xc3  |  Yc3  |  Xc3  |
!       .   |   .    |  .   |   .   |   .   |   .   |   .   |   .   |
!       .   |   .    |  .   |   .   |   .   |   .   |   .   |   .   |
!       N   |  L_#N  |  LN  |  KPN1 | KPN2  |  XcN  |  YcN  |  ZcN  |
!
!   The number of lines (and therefore the number of rows in LCG_DATA) are
!   output in the parameter:
!                                   NUM_LNS
!
!   Each succesive run of this macro erases the array data from the previous
!   run. If the data is to be retained from any run, the use of ARRY_TRANSFER
!   may be used to replicate the data into a new array of a different name.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
lnum__=arg1
!
configuration,0
!
*set,lcg_data(1),
!
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                 4=character array, -1=undefined
!
*get,argtyp_,parm,lnum__,type
!
*if,argtyp_,eq,0,then
    *if,lnum__,eq,0,then
        lnum__='cmplset_'
        cm,%lnum__%,line
    *elseif,lnum__,gt,0,then
        asel,s,area,,lnum__
        lnum__='cmplset_'
        cm,%lnum__%,line
    *endif
*elseif,argtyp_,eq,3,then
    cmsel,s,%lnum__%
*endif
!
cmsel,s,%lnum__%
!
entity_array,'l','lcg_data','array',,,7
num_lns=ecount
!
csys,0
!
*do,xyzz_,1,num_lns,1
    lsel,s,line,,lcg_data(xyzz_,1)
    lsum
    !
    *get,lcg_data(xyzz_,2),line,lcg_data(xyzz_,1),leng
    *get,lcg_data(xyzz_,3),line,lcg_data(xyzz_,1),kp,1
    *get,lcg_data(xyzz_,4),line,lcg_data(xyzz_,1),kp,2
    !
    *get,lcg_data(xyzz_,5),line,,cent,x
    *get,lcg_data(xyzz_,6),line,,cent,y
    *get,lcg_data(xyzz_,7),line,,cent,z
*enddo
!
configuration,1
!
cmdele,%lnum__%
*set,lnum__,
*set,ecount,
*set,argtyp_,
*set,parmtyp_,
*set,xyzz_,
!
*if,prkey_,eq,1,then
    /go
*endif