!   TITLE:  extend.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This macro extends the length of a line.
!
!
!   COMMAND SYNTAX:
!
!                        (1)   (2)     (3)
!               EXTEND, line#, kp#, ext_leng
!
!
!   ARGUMENTS:
!
!       (1) line# = number of the line to extend
!
!       (2) kp# = end keypoint number to extend from
!
!       (3) ext_leng = the amount of length to extend line
!
!
!   DESCRIPTION:
!
!   The line is extended from the specified end keypoint side.  The original
!   length of the line is extended in length by the amount specified in arg-
!   ument 3, 'ext_leng'.
!
!   If the end keypoint is attached to only 1 line, then the line number
!   need not be specified; only arguments 2 and 3. In this case, the line
!   is extended and combined with the original line to make 1 longer line.
!
!   If the end keypoint is attached to more than 1 line, then the line number
!   to be extended must be specified. When this line is extended, it is not
!   combined with the original line, and therefore the extension is an add-
!   itional line.
!
!   This command is valid for straight lines only.
!
!
!
*get,prkey_,active,0,prkey
/nopr

!
baseln_=arg1
endkp_=arg2
extl_=arg3
!
init_entity_num
!
ksel,s,kp,,endkp_
lslk,s,0
get_max_entity
lhold_=lm
*get,numlns_,line,,count
!
init_entity_num
!
*if,numlns_,eq,1,then
    baseln_=lhold_
*endif
!
*get,kp1_,line,baseln_,kp,1
*get,kp2_,line,baseln_,kp,2
!
*if,kp1_,eq,endkp_,then
    kxp_=kp2_
*else
    kxp_=kp1_
*endif
!
*get,acs1_,active,,csys
!
clocal,csn+5,1,kx(endkp_),ky(endkp_),kz(endkp_),0,0,0
kxpang_=ky(kxp_)
clocal,csn+6,0,0,0,0,kxpang_,0,0
!
k,,0,1,0
init_entity_num
kpln_=km
!
cskp,csn+7,0,endkp_,kxp_,kpln_
!
kdele,kpln_
init_entity_num
!
*if,extl_,gt,0,then
    k,,-extl_,0,0
    !
    init_entity_num
    !
    lstr,endkp_,km
    !
    init_entity_num
    !
    *if,numlns_,eq,1,then
        lcomb,baseln_,lm
        init_entity_num
    *endif
*endif
!
csdele,csn+5,csn+7,1
csys,acs1_
!
lplot
!
*set,baseln_,
*set,endkp_,
*set,kpln_,
*set,kp1_,
*set,kp2_,
*set,acs1_,
*set,extl_,
*set,lhold_,
*set,numlns_,
*set,kxp_,
*set,kxpang_,

*if,prkey_,eq,1,then
    /go
*endif