!   TITLE:  ang_cut_pln.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a volume cutting plane at a user specified angle
!   and distance from the active coordinate system origin.
!
!
!   COMMAND SYNTAX:
!
!                          (1)      (2)      (3)     (4)
!           ANG_CUT_PLN, ang_pln, dist_pln, x_dist, y_dist
!
!
!   ARGUMENTS:
!
!       (1) ang_pln = the angle of the cutting plane as measured from the
!                     C.S. +x axis.
!
!       (2) dist_pln = the normal distance of the plane surface from the
!                      the C.S. origin. X_DIST and Y_DIST are ignored.
!
!       (3) x_dist = the distance along the x (+ or -) axis the plane
!                    intersects. If this is specified, DO NOT specify Y_DIST
!                    and DIST_PLN.
!
!       (4) y_dist = the distance along the y (+ or -) axis the plane
!                    intersects. If this is specified, DO NOT specify X_DIST
!                    and DIST_PLN.
!
!
!   DESCRIPTION:
!
!   The cutting plane is created at a user specified angle, ANG_PLN, with
!   respect to the +x axis, and is an angle (in degrees) within the range:
!
!                           0 < ang_pln < 180
!
!   The distance of the plane (DIST_LN) is the magnitude of a vector from the
!   origin oriented normal to the plane surface. Therefore, it is the perpen-
!   dicular distance of the plane from the origin. Also, the plane is aligned
!   parallel to the z axis of the active C.S.
!
!   The plane position may also be specified by the intercept with the X or
!   Y axis.  The active coordinate system may be any type.
!
!   See the argument descriptions to verify proper useage.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
ang_=arg1
dist_=arg2
xdist_=arg3
ydist_=arg4
!
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    clocal,csn+50,0,0,0,0,0,0,0         ! create cartesian CS at same location.
*endif
!
cm,vset,volu
!
max_enty_dim,'l'
!
lpln_=10*max_leng
!
flag_=0
!
*if,dist_,eq,0,then
    *if,xdist_,ne,0,then
        flag_=1
        clocal,csn+51,1,xdist_,0,0,0,0,0
    *else
        *if,ydist_,ne,0,then
            flag_=1
            clocal,csn+51,1,0,ydist_,0,0,0,0
        *endif
    *endif
*endif
!
*if,dist_,lt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_-90)*rconv)
        y_=abs(dist_)*sin((ang_-90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_-90)*rconv)
        y_=-abs(dist_)*sin((ang_-90)*rconv)
    *endif
*elseif,dist_,gt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_+90)*rconv)
        y_=abs(dist_)*sin((ang_+90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_+90)*rconv)
        y_=-abs(dist_)*sin((ang_+90)*rconv)
    *endif
*else
    *if,flag_,ne,1,then
        xdist_=0
        ydist_=0
        x_=0
        y_=0
    *endif
*endif
!
*if,flag_,ne,1,then
    clocal,csn+51,1,x_,y_,0,0,0,0
*endif
!
k,,lpln_,ang_,-lpln_
k,,lpln_,ang_,lpln_
k,,-lpln_,ang_,lpln_
k,,-lpln_,ang_,-lpln_
!
create_area
!
vsel,s,volu,,vset
!
vol_part_area,am
!
init_entity_num
!
csdele,csn+50,csn+51,1
csys,acs_
!
lplot
!
*set,x_,
*set,y_,
*set,ang_,
*set,dist_,
*set,xdist_,
*set,ydist_,
*set,lpln_,
*set,acs_,
*set,acstyp_,
*set,flag_,
cmdele,vset
!
*if,prkey_,eq,1,then
    /go
*endif