!   TITLE:  lug_cylind.mac (MISC_PART)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a cylindrical bolt lug as a miscellaneous part.
!
!
!   COMMAND SYNTAX:
!
!                     (1)     (2)    (3)    (4)      (5)
!        LUG_CYLIND, lug_cs, r_out, leng, d_hole, dpth_hole
!
!
!   ARGUMENTS:
!
!       (1) lug_cs = the coordinate system to create lug relative to.
!
!       (2) r_out = outer radius of the lug surface.
!
!       (3) leng = length of the lug, as measured from the hole/radius
!                  center.
!
!       (4) d_hole = center hole (shaft) diameter. If left blank (0),
!                    the lug is created with no center hole.
!
!       (5) dpth_hole = center hole depth. If left blank (0), the hole
!                       is created through the entire lug length (as
!                       specified in argument 3).
!
!
!   DESCRIPTION:
!
!   The lug profile is created with the lug cylindrical surface and/or hole
!   axis along the Z-axis, with the top surface coplanar to the XY-plane of
!   the specified coordinate system. The length of the lug is measured from
!   the top surface (XY-plane) center, along the -Z-axis. If it is desired
!   to extrude in the +Z-axis direction, simply place a minus sign in front
!   of the value of argument 3 (leng).
!
!   If the hole diameter (argument 3) is not specified, the lug is created
!   with no center hole. If the hole depth (argument 5) is left blank (0),
!   the hole is created through the entire lug length (as specified in
!   argument 3).
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
*get,actvcs_,active,,csys
!
lugcs_=arg1
rout_=arg2
leng_=arg3
dhole_=arg4
hdepth_=arg5
!
*if,leng_,lt,0,then
    sign_=-1
*elseif,leng_,ge,0,then
    sign_=1
*endif
!
csys,lugcs_
!
create_circ_area,rout_,0,,2
!
asel,s,area,,am
extrude_aset,-leng_
!
*if,hdepth_,eq,0,then
    hdepth_=abs(leng_)
*endif
!
*if,dhole_,gt,0,then
    create_circ_area,dhole_/2,0,,2
    !
    asel,s,area,,am
    extrude_aset,-sign_*hdepth_
    vsbv,vm-1,vm,,delete,delete
    init_entity_num
*endif
!
csys,actvcs_
!
aplot
!
*set,lugcs_,
*set,rout_,
*set,leng_,
*set,dhole_,
*set,hdepth_,
*set,actvcs_,
*set,sign_,
!
*if,prkey_,eq,1,then
    /go
*endif