!   TITLE:  angle_line.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This macro creates a line at a specified angle from a user specified line.
!
!
!   COMMAND SYNTAX:
!
!                     (1)    (2)     (3)    (4)   (5)   (6)    (7)
!        ANGLE_LINE, plncs, line#, kp_end, angle, dist, side, sfact
!
!
!   ARGUMENTS:
!
!       (1) plncs = the coordinate system whose XY plane is parallel to
!                   the plane which wiil contain the angled line.
!
!       (2) line# =  number of the original line to construct new angled line
!                    relative to.
!
!       (3) kp_end = the end keypoint of the original line to position the
!                    angled line from.
!
!       (4) angle =  angle of the new line relative to the original line.
!
!       (5) dist =  the perpendicular distance between the end keypoint and
!                   the angled line.
!
!       (6) side = the side of the end keypoint to create the angled 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')
!
!       (7) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The angled line is created in the plane parallel to the XY plane of the
!   coordinate system specified in argument 1, 'plncs'.
!
!   This macro creates the angled line a normal distance 'dist' from
!   the specified end keypoint.  The line is created on the side specified by
!   argument 6.  TOP, BOTTOM, LEFT and RIGHT are relative positions, and
!   are 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 line is 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 = 2*(L_orig + sfact*(0.10*lnl_))
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered with each endpoint equidistant from the specified
!   end keypoint. Argument 7 allows the user to adjust the resulting length
!   of the new line if desired.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

usangln_=1
!
plncs_=arg1
origln2_=arg2
kpref_=arg3
rotang_=arg4
dist_=arg5
side_=arg6
sfact2_=arg7
!
init_entity_num
!
*if,sfact2_,le,0,then
    sfact2_=2
*endif
!
*get,acs1__,active,,csys
!
*get,plncstyp,cdsy,plncs_,attr,kcs
!
*if,plncstyp,ne,0,then
    create_cs,0,'plncs_',0,0,0,0,0,0,0
*endif
!
!
csys,plncs_
!
*get,lnl_,line,origln2_,leng
!
*get,kp11_,line,origln2_,kp,1
*get,kp12_,line,origln2_,kp,2
!
*if,kpref_,eq,kp11_,then
    kpx_=kp12_
*else
    kpx_=kp11_
*endif
!
clocal,csn+5,1,kx(kpref_),ky(kpref_),kz(kpref_),0,0,0
!
kpang_=ky(kpx_)
ang_convert,'kpang_',0
!
clocal,csn+6,0,0,0,0,kpang_,0,0
!
*if,kpang_,le,90,then
    clocal,csn+7,1,0,0,0,rotang_,0,0
*elseif,kpang_,le,180,then
    clocal,csn+7,1,0,0,0,180+rotang_,0,0
*elseif,kpang_,le,270,then
    clocal,csn+7,1,0,0,0,180+rotang_,0,0
*elseif,kpang_,le,360,then
    clocal,csn+7,1,0,0,0,rotang_,0,0
*endif
!
k,,lnl_+(sfact2_*(0.10*lnl_)),180,0
k,,lnl_+(sfact2_*(0.10*lnl_)),0,0
!
create_lines,,1
origln1_=lm
!
parallel_lines,plncs_,side_,dist_,origln1_
!
ldele,origln1_,,,1
!
init_entity_num
!
csdele,csn+5,csn+7,1
!
csys,acs1__
!
lplot
!
!
*set,kpref_,
*set,kpx_,
*set,origln1_,
*set,origln2_,
*set,ptyp2_,
*set,rotang_,
*set,sfact2_,
*set,usangln_,

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