!   TITLE:  ln_kp_pairs.macc (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a series of disconnected lines between pairs of
!   newly created keypoints.
!
!
!   COMMAND SYNTAX:
!
!                     (1)
!       LN_KP_PAIRS, c_acs
!
!
!   ARGUMENTS:
!
!       (1) c_acs = boolean operator to create lines in active coordinate
!                   system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!
!   DESCRIPTION:
!
!   This macro connects each pair of newly created keypoints (in sequence)
!   by a single line. Therefore, this command will create separate lines
!   between KP pairs (in sequence) only if the number of new keypoints is
!   an even number.
!
!   If the number of newly created KP's is an odd number, then the lines will
!   be disconnected between each pair of KP's, with the exception of the last
!   line, which is connected to the previous KP pair.
!
!   The lines may be created as straight lines or lines in the active C.S.
!   When specifying argument 1 as 1, be sure that the desired CS is active
!   (e.g., if arced lines are desired, then the active CS mustbe a cylindrical
!   or spherical CS, which ever is desired. If straight lines are desired,
!   then the argument needs to be 0 (or left blank).
!
!   *** IMPORTANT: The newly created lines are stored in a component group
!                  for use in subsequent boolean operations. The lines are
!                  stored in a component group named:
!
!                                   new_lns
!
!___________________________________________________________________________
!   EXAMPLES:   (Run the following blocks of code)
!
!                   mod_assemb_prep
!                   csys,1
!                   k,,5,0
!                   k,,6,30
!                   k,,5,80
!                   k,,7,125
!                   k,,3,180
!                   k,,5,220
!                   LN_KP_PAIRS,1
!
!                   mod_assemb_prep
!                   csys,1
!                   k,,5,0
!                   k,,6,30
!                   k,,5,80
!                   k,,7,125
!                   k,,3,180
!                   LN_KP_PAIRS
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
cacs_=arg1
!
init_entity_num
!
lcntr_=0
!
*if,cacs_,eq,0,then
    *do,iii_,km_prev+1,km,2
        *get,kpexist_,kp,iii_+1,ksel
        !
        *if,kpexist_,ne,0,then
            lstr,iii_,iii_+1
            lcntr_=lcntr_+1
        *else
            lstr,iii_-1,iii_
            lcntr_=lcntr_+1
        *endif
    *enddo
*elseif,cacs_,eq,1,then
    *do,iii_,km_prev+1,km,2
        *get,kpexist_,kp,iii_+1,ksel
        !
        *if,kpexist_,ne,0,then
            l,iii_,iii_+1
            lcntr_=lcntr_+1
        *else
            l,iii_-1,iii_
            lcntr_=lcntr_+1
        *endif
    *enddo
*endif
!
init_entity_num
lsel,s,line,,lm-(lcntr_-1),lm
cm,new_lns,line
init_entity_num
!
lplot
!
*set,iii_,
*set,cacs_,
*set,lcntr_,
*set,kpexist_,
!
*if,prkey_,eq,1,then
    /go
*endif