!   TITLE:  cir_bore.mac (SM_TOOL)
!
!
!       the bore volume.  It allows yhe use of any type of coordinate system
!       to be used as the active C.S.
!
!   This sub-macro is used to create a circular cylinder or cone-shaped bore
!   into a volume, or set of volumes.  The bore may be a right circular
!   cylinder (phibev = 0), or have a side angle (0 < phibev < 90). For the
!   angled conic bore, the diameter of the circular end surfaces may be
!   specified at the top (opt = 0), or at the bottom (inside base) of the bore.
!
!   The cylindrical or conic shaped bore volume has its axis centered about
!   the Z axis of the active C.S.  It has one end surface coplanar with the XY
!   plane of the active C.S., with the other end located a specified depth,
!   DCUT, in the -Z direction of the active C.S.
!
!   if the depth parameter, DCUT, is left blank ( or 0 ), then a circular area
!   of a specified diameter is created.  This allows the user to duplicate
!   and/or extruded the area into a hole pattern if desired.
!
!   Input arguments are:
!
!       A selected set of volume(s)
!
!       (1) opt = input options:
!
!               0 (or blank) = diameter of cut at the surface of the part
!
!               1 = diameter of cut at the base of the part
!
!       (2) dia_cut = diameter of cut/volume:
!
!               a.) at the surface of the part if OPT=0
!
!               b.) at the base of the part if OPT=1
!
!       (3) dcut = the depth or thickness of the cut. If this argument is 0
!                  or blank, then a circular shaped area is created in the
!                  XY plane of the active C.S. with no depth.
!
!       (4) phibev = angle of bevel as measured from the axis of the
!                    cylindrical cut volume.
!
!
!
!               (1)    (2)    (3)    (4)
!     CIR_BORE, opt, dia_cut, dcut, phibev
!
!
*get,prkey_,active,0,prkey
/nopr
!
cm,v2bcut,volu                          ! selected volume to be (2b) cut
!
*get,ccs_,active,,csys
*get,ccstyp_,cdsy,ccs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,,1,0,0,0,0,0,0
*endif
!
opt_=arg1
diacut_=arg2
dcut_=arg3
phibev_=arg4
!
x_=dcut_*tan(phibev_*rconv)
!
*if,opt_,eq,1,then
    diacut_=diacut_+2*x_
*endif
!
*do,ii_,0,3*rtangle,rtangle
    k,,diacut_/2,ii_,0
*enddo
!
*if,dcut_,ne,0,then
    *if,(diacut_/2-x_),ge,0,then
        !
        *do,ii_,0,3*rtangle,rtangle
            k,,(diacut_/2-x_),ii_,-dcut_
        *enddo
        !
        init_entity_num
        !
        v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
        !
        init_entity_num
        !
        vsbv,v2bcut,vm,,delete,delete
        !
        init_entity_num
        !
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        !
        init_entity_num
    *endif
*else
    create_area,1
*endif
!
lplot
!
csys,ccs_
!
*set,opt_,
*set,phibev_,
*set,dcut_,
*set,diacut_,
*set,x_,
*set,ii_,
*set,ccs_,
cmdele,v2bcut,

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