!   TITLE:  angle_line_kp.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This macro creates an angled line relative to a user specified line and
!   passing through a user specified keypoint.
!
!
!   COMMAND SYNTAX:
!
!                        (1)   (2)  (3)    (4)
!        ANGLE_LINE_KP, line#, kp, angle, sfact
!
!
!   ARGUMENTS:
!
!       (1) line# =  number of the original line to construct new angled line
!                    relative to.
!
!       (2) int_kp = the keypoint that the angled line passes thru (intercepts).
!
!       (3) angle =  angle of the new line relative to the original line.
!
!       (4) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The angled line is created in the plane containing the original line
!   and the intercept keypoint, and creates an angle with that original line
!   equal to that specified in argument 4.
!
!   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
!   keypoint. Argument 4 allows the user to adjust the resulting length
!   of the new line if desired.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

origln_=arg1
kpint_=arg2
rotang_=arg3
sfact_=arg4
!
init_entity_num
!
*if,sfact_,le,0,then
    sfact_=2
*endif
!
*get,acs1__,active,,csys
!
!
*get,lnl_,line,origln_,leng
!
*get,kp1_,line,origln_,kp,1
*get,kp2_,line,origln_,kp,2
!
cskp,csn+5,0,kp1_,kp2_,kpint_
!
clocal,csn+6,1,kx(kpint_),ky(kpint_),kz(kpint_),rotang_,0,0
!
k,,lnl_+(sfact_*(0.10*lnl_)),180,0
k,,lnl_+(sfact_*(0.10*lnl_)),0,0
!
create_lines,,1
!
csdele,csn+5,csn+6,1
!
csys,acs1__
!
lplot
!
!
*set,acs1__,
*set,kpint_,
*set,kp1_,
*set,kp2_,
*set,origln_,
*set,rotang_,
*set,sfact_,
*set,lnl_,

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