!   TITLE:  subassy_revolve.mac (SM_TOOL)
!
!
!   Generalized macro for choice of angle of rotation and number of volume
!   segments.  Also added code to create a cartesian or cylindrical C.S.
!   if revolve C.S. is not either type, and restore the active C.S. after
!   macro execution.
!
!   OBJECTIVE:
!
!   This sub-macro revolves a selected set of areas in a sub-assembly.
!
!
!   COMMAND SYNTAX:
!
!                            (1)  (2)      (3)     (4)
!           SUBASSY_REVOLVE, cs, revang, numseg, shr_opt
!
!
!   ARGUMENTS:
!
!       (1) cs = coordinate system whose Z axis is the axis of revolution.
!                This C.S. may be a cartesian or cylindrical C.S.
!
!       (2) revang = total angle of revolution of selected areas
!
!       (3) numseg = number of volume segments in the revolve angle (revang)
!
!       (4) shr_opt = solid model entity share options:
!
!               0 (or blank) = share/merge areas and volumes (default)
!
!               1 = separate areas and volumes
!
!
!   DESCRIPTION:
!
!   This sub-macro revolves a set (2 or more) of cross-sectional areas in
!   a sub-assembly.  These areas must be of the same sub-assembly
!   'part', such that when 'init_entity_num' is executed prior to the
!   execution of this macro, only the desired areas to be revolved should
!   be selected. If the areas (and therefore the volumes) are to share their
!   constituent solid model entities, lines (and areas), then the areas are
!   glued, revolved and merged, which is the default.  If they are to remain
!   totallly separate entities (not sharing their solid model entities), then
!   the user may specify this condition.
!
!   The revolves are executed about the Z axis of a specified coordinate
!   system. The total revolve angle and number of volume segments may be
!   specified.  If they are not specified, then the total angle of revolve
!   and the number of volume segments for each area in the revolve defaults
!   to 360 degrees and 4 volume segments, respectively (4 volume segments
!   revolved at 90 degrees each). The rotation direction is consistent with
!   the vector definition of the right-hand rule, with positive rotations
!   along the positive Z axis.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
revcs_=arg1
revang_=arg2
numseg_=arg3
shropt_=arg4
!
init_entity_num
!
*if,revang_,eq,0,then
    *if,numseg_,eq,0,then
        revang_=360
        numseg_=4
    *else
        revang_=360
    *endif
*else
    *if,numseg_,eq,0,then
        *if,revang_,le,180,then
            numseg_=1
        *elseif,revang_,le,360,then
            numseg_=2
        *endif
    *endif
*endif
!
*get,actcs2_,active,,csys
!
*get,rvcstyp_,cdsy,revcs_,attr,kcs
!
*if,rvcstyp_,ne,0,then
    *if,rvcstyp_,ne,1,then
        create_cs,0,,1,0,0,0,0,0,0
        revcs_=csn+1
    *endif
*endif
!
*if,shropt_,eq,0,then
    glu_ar_attr
    cmsel,s,CAglu_
*endif
!
csys,revcs_
!
revolve_aset,revcs_,revang_,numseg_
!
*if,shropt_,eq,0,then
    nummrg,kp
*endif
!
kdele,axp11_,axp12_,1
!
init_entity_num
!
csys,actcs2_
!
lplot
!
*set,actcs2_,
*set,revcs_,
*set,revang_,
*set,numseg_,
*set,axp11_,
*set,axp12_,
*set,rvcstyp_,
*set,shropt_,
cmdele,CAglu_
!
*if,prkey_,eq,1,then
    /go
*endif