!   TITLE:  create_circle.mac (SM_TOOL)
!
!
!       Optimized code.
!
!   OBJECTIVE:
!
!   This sub-macro creates a set of circular profile lines.
!
!
!   COMMAND SYNTAX:
!
!                        (1)    (2)     (3)     (4)    (5)
!       CREATE_CIRCLE, radius, z_loc, ang_inc, n_arc, st_ang
!
!
!   ARGUMENTS:
!
!       (1) radius = the radius of the circle
!
!       (2) z_loc = the location of the circle center along the z-axis
!                   of the active coordinate system
!
!       (3) ang_inc = angle subtended by arc(s). When specifying this
!                     parameter, the algorithm will create the circle
!                     with a series of arcs subtending an angle of
!                     'ANG_INC'. Therefore, the value of this parameter
!                     must be an integral divisor of 360; i.e., 3,4,5,6,
!                     8,9,10,12,....180. When this parameter is desired,
!                     'N_ARC' must be left blank.
!
!       (4) n_arc = The number of equal arc increments that the circle
!                   is constructed from.  If this argument is specified,
!                   then 'ANG_INC' is over-ridden and the circle is
!                   created by this number of equal arcs.
!
!       (5) st_ang = The start angle of the first arc used in the
!                    construction of the circle.
!
!
!   DESCRIPTION:
!
!   Creates a full circle consisting of arcs as specified by either various
!   arc angle increments or a number of arcs from a specified start angle.
!
!   When arguments 2, 3, 4 and 5 are left blank, the algorithm defaults to a
!   circle of 4-90 degree arcs, starting at the X-axis (0 degrees), in the XY
!   plane of the active CS (z = 0).
!
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
rad_=arg1
zloc_=arg2
anginc_=arg3
narc_=arg4
stang_=arg5
!
clocal,csn+50,1,0,0,0,0,0,0
!
finang_=stang_+360
!
*if,narc_,eq,0,then
    *if,anginc_,eq,0,then
        anginc_=90
        narc_=4
    *else
        narc_=abs(finang_-stang_)/anginc_
    *endif
*else
    anginc_=abs(finang_-stang_)/narc_
*endif
!
*do,ii_,0,narc_-1,1
    ang_=stang_+(ii_*anginc_)
    k,,rad_,ang_,zloc_
*enddo
!
create_lines,1
!
*if,anginc_,eq,180,or,narc_,eq,2,then
    lsel,r,line,,lm
    clocal,csn+51,0,0,0,0,stang_,0,0
    lsymm,y,lm
    get_max_entity
    lglue,lm-1,lm
    csdele,csn+51
*endif
!
csdele,csn+50
!
configuration,1
init_entity_num
!
lplot
!
*set,ii_
*set,rad_
*set,stang_
*set,finang_
*set,anginc_
*set,narc_
*set,ang_
*set,zloc_
!
*if,prkey_,eq,1,then
    /go
*endif