!   TITLE:  hex_nut.mac (MISC_PART)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a hex-head nut as a miscellaneous part.
!
!
!   COMMAND SYNTAX:
!
!                   (1)    (2)     (3)    (4)       (5)
!        HEX_NUT, nut_cs, w_flat, thick, d_hole, strt_ang
!
!
!   ARGUMENTS:
!
!       (1) nut_cs = the coordinate system to create nut relative to.
!
!       (2) w_flat = width of the hex from flat to flat sides.
!
!       (3) thick = thickness (length) of the nut.
!
!       (4) d_hole = center hole (shaft) diameter. If left blank (0),
!                    the hex nut is created with no center hole.
!
!       (5) strt_ang = start angle of the 1st corner, as measured from
!                      +X-axis. (-60 < strt_ang < 60)
!
!
!   DESCRIPTION:
!
!   The nut axis is along the Z-axis, with one hexagonal surface coplanar to
!   the XY-plane of the specified coordinate system. The start angle is the
!   angle of the 1st corner of the hex surface relative to the +X-axis of the
!   specified coordinate system, with the length of the nut extruded along the
!   +Z-axis. The center hole is created along the Z-axis.
!
!   The start angle defaults to 0 if it is not specified. If the hole diameter
!   (argument 3) is not specified, the hex nut is created with no center hole.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
*get,actvcs_,active,,csys
!
nutcs_=arg1
wflat_=arg2
thk_=arg3
dhole_=arg4
strtang_=arg5
!
!       METHOD = 'i':
!                           (1)   (2)     (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, r_in, num_side, a_or_l, strt_ang, z_pos
!
!
csys,nutcs_
!
equilat_poly,'i',wflat_/2,6,1,strtang_,0
!
*if,dhole_,gt,0,then
    create_circ_area,dhole_/2,0
    !
    asba,am-1,am,,delete,delete
    init_entity_num
*endif
!
asel,s,area,,am
extrude_aset,thk_
!
csys,actvcs_
!
aplot
!
*set,nutcs_,
*set,wflat_,
*set,thk_,
*set,strtang_,
*set,dhole_,
*set,actvcs_,
!
*if,prkey_,eq,1,then
    /go
*endif