!   TITLE:  tv_parallel_lines.mac (CALCULATION)
!
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This macro creates a series of lines parallel to a set of selected lines.
!
!
!   ARGUMENTS:
!
!       (1) plncs = the coordinate system whose XY plane is parallel to
!                   the plane which wiil contain the parrallel lines. Default
!                   is active coordinate system.
!
!       (2) side = the side to the selected line to create the parallel line.
!
!                       't' = top
!                       'b' = bottom
!                       'l' = left
!                       'r' = right
!
!               *** NOTE: For vertical and horizontal lines, it is safest to
!                         specify the sides as follows:
!
!                           vertical - left ('l') or right ('r')
!                           horizontal - top ('t') or bottom ('b')
!
!
!       (3) dist =  the distance between parallel lines
!
!       (4) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The parrallel line(s) area created in the plane parallel to the XY plane
!   of the plane coordinate system specified in argument 1, 'plncs'.
!
!   This macro creates the parallel line(s) a normal distance 'dist' from
!   the selected lines.  The lines are created on the side specified by
!   argument 2.  TOP, BOTTOM, LEFT and RIGHT are relative positions, and
!   rae based on the perspective of the user.  This 'perspective' is deter-
!   mined from the plane coordinate system specified in argument 1. From,
!   this coordinate system, TOP is the region in the +Y direction; BOTTOM is
!   the region in the -Y direction; LEFT is the region in the -X direction
!   and RIGHT is the region in the +X direction.  Therefore, the perspective
!   of the user is the XY plane with the +Z axis pointing out of the graphics
!   window.
!
!   The length of the new lines are determined by the scaling factor, 'sfact',
!   specified in argument 4.  If left blank, the default value is 2.
!
!   The length of the new line is determined by the following formula:
!
!                       L_new = L_orig + 2*(sfact * dist)
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered parallel with the original line, with each end
!   greater in length by the amount (sfact * dist). Argument 4 allows the
!   user to adjust the resulting lengths of the new lines if desired.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

*get,acs1__,active,,csys
!
*ask,plncs_,'Enter Plane C.S. #',acs1__
!
multipro,'start',4
    *cset,1,3,origln_,'Enter Line #',0
    *cset,4,6,sid_,'Side 1=L, 2=R, 3=T, 4=B',2
    *cset,7,9,dist_,'Enter Line Distance(s)',0
    *cset,10,12,sfact_,'Enter Scaling Factor For Length',2
    *cset,61,62,'Creates a set of lines parallel',' to a selected set of lines,'
    *cset,63,64,'offset by a specified distance.',' Enter pertinent information.'
multipro,'end'
!
*if,sid_,eq,1,then
    side_='l'
*elseif,sid_,eq,2,then
    side_='r'
*elseif,sid_,eq,3,then
    side_='t'
*elseif,sid_,eq,4,then
    side_='b'
*endif
!
*get,plncstyp,cdsy,plncs_,attr,kcs
!
*if,plncstyp,ne,0,then
    plncs_=csn+5
    clocal,plncs_,0,0,0,0,0,0,0
*endif
!
*if,origln_,eq,0,then
    cm,origlns_,line
    entity_array,'l','parln_','array'
    lnmax_=ecount
*else
    lsel,s,line,,origln_
    cm,origlns_,line
    entity_array,'l','parln_','array'
    lnmax_=ecount
*endif
!
*do,aaa_,1,lnmax_,1
    csys,plncs_
    !
    *get,lnl_,line,parln_(aaa_,1),leng
    !
    *get,kp11_,line,parln_(aaa_,1),kp,1
    *get,kp12_,line,parln_(aaa_,1),kp,2
    !
    clocal,csn+6,1,kx(kp11_),ky(kp11_),kz(kp11_),0,0,0
    !
    kpang_=ky(kp12_)
    ang_convert,'kpang_',0
    !
    *if,kpang_,le,89,then
        k,,1,90,0
    *elseif,kpang_,le,179,then
        k,,1,180,0
    *elseif,kpang_,le,269,then
        k,,1,270,0
    *elseif,kpang_,le,359,then
        k,,1,0,0
    *elseif,kpang_,gt,359,then
        k,,1,90,0
    *endif
    !
    init_entity_num
    thrdkp_=km
    !
    cskp,csn+7,0,kp11_,kp12_,thrdkp_
    !
    *if,kpang_,le,90,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,180,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,270,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *elseif,kpang_,le,360,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *endif
    !
    k,,-sfact_*dist_,sign_*dist_,0
    k,,lnl_+(sfact_*dist_),sign_*dist_,0
    !
    create_lines,,1
    !
    kdele,thrdkp_
    init_entity_num
    !
    lplot
*enddo
!
lsel,s,line,,lm-(aaa_-1),lm,1
cm,newlns,line
!
init_entity_num
!
csdele,csn+5,csn+7,1
csys,acs1__
!
wpcsys,1,plncs_
/AUTO, 1
!
lplot
!
*msg,ui,%plncs_%
Working Plane Location: PLANE C.S. = %g
!
*set,plncs_,
*set,acs1__,
*set,origln_,
*set,plncstyp,
*set,lnmax_,
*set,parln_(1),
*set,kpang_,
*set,sign_,
*set,sfact_,
*set,lnl_,
*set,thrdkp_,
*set,dist_,
*set,aaa_,
*set,sid_,
*set,side_,
*set,kp11_,
*set,kp12_,

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