!   TITLE:  hollow_cylinder.mac (SM_TOOL)
!
!
!   This sub-macro creates a hollw cylinder, or hollow cylindrical section,
!   of a user specified length, L_CYL.  The full cylinder (360 degrees) may
!   be made in 4 separate volume sections or as 1 solid volume. This is con-
!   trolled by the parameter S_OR_PRT (see below).  If only cylindrical sec-
!   tions are desired, then the user may specify quarter (90 degrees), half
!   (180 degrees) or 3-quarter (270 degees) sections ONLY.
!
!   Other options allow the cylinder to be created by full knowledge of the
!   inner and outer diameters of the wall; or by a knowledge of either the
!   inner or outer diameter and the wall thickness, WALL_THK. If zero or no
!   length is specified, then the algorithm will create the section areas
!   only (no volumes).
!
!           cs_num = active coordinate system number to bulid cylinder from
!                    (must be a cylindrical coordinate system)
!
!           s_or_prt = solid or partitioned cylinder parameter. This parameter
!                      is used to create a solid (1 volume) cylinder, or a
!                      cylinder consisting of 4-90 degree partitions.  The
!                      solid option is only available for a full (360 degree)
!                      cylinder.
!
!                       0 (or blank) = solid
!                       1 = partitioned
!
!           diam_i = cylinder inner diameter
!
!           diam_o = cylinder outer diameter
!
!           wall_thk = cylinder wall thickness
!
!           l_cyl = cylinder length
!
!           arc_ang = arc angle of cylinder.  The valid options for this
!                     argument are 90, 180, 270 and 360.
!
!           z_pos = position of initial profile area(s) along z axis. If
!                   left blank, 'z_pos' is assumed to be 0.
!
!
!
!                   (1)      (2)      (3)     (4)      (5)      (6)     (7)
! HOLLOW_CYLINDER, cs_num, s_or_prt, diam_i, diam_o, wall_thk, l_cyl, arc_ang
!
!                  z_pos
!                   (8)
!
!
!
*get,prkey_,active,0,prkey
/nopr

cs_num=arg1
diam_i=arg3
diam_o=arg4
l_cyl=arg6
arc_ang=arg7
z_pos=arg8
!
*if,arc_ang,eq,0,then
    arc_ang=360
*endif
!
*if,arc_ang,eq,360,then
    s_or_prt=arg2
*else
    s_or_prt=1
*endif
!
*if,diam_i,eq,0,then
    wall_thk=arg5
    rad_o=diam_o/2
    rad_i=rad_o-wall_thk
*elseif,diam_o,eq,0,then
    wall_thk=arg5
    rad_i=diam_i/2
    rad_o=rad_i+wall_thk
*else
    rad_o=diam_o/2
    rad_i=diam_i/2
*endif
!
!
*if,s_or_prt,eq,0,then
    !
    csys,cs_num
    !
    *do,kkk,0,arc_ang-90,90
        k,,rad_o,kkk,z_pos
    *enddo
    !
    create_area,1
    !
    *do,kkk,0,arc_ang-90,90
        k,,rad_i,kkk,z_pos
    *enddo
    !
    create_area,1
    !
    asba,am-1,am,,delete,delete
    !
    init_entity_num
    !
    *if,l_cyl,gt,0,then
        voffst,am,l_cyl
        init_entity_num
    *endif
    !
    lplot
*else
    csys,cs_num
    !
    k,,rad_o,0,z_pos
    k,,rad_o,90,z_pos
    k,,rad_i,90,z_pos
    k,,rad_i,0,z_pos
    !
    create_area,1
    !
    *if,arc_ang,gt,90,then
        create_cs,0,,0,0,0,0,0,0,0
    *endif
    !
    *if,arc_ang,eq,180,then
        arsym,x,am,,,,0,0
    *elseif,arc_ang,eq,270,then
        arsym,x,am,,,,0,0
        init_entity_num
        arsym,y,am,,,,0,0
    *elseif,arc_ang,eq,360,then
        arsym,x,am,,,,0,0
        init_entity_num
        arsym,y,am-1,am,1,,0,0
    *endif
    !
    init_entity_num
    !
    *if,l_cyl,gt,0,then
        *if,arc_ang,eq,90,then
            voffst,am,l_cyl
        *elseif,arc_ang,eq,180,then
            asel,s,area,,am-1,am,1
            extrude_aset,l_cyl
        *elseif,arc_ang,eq,270,then
            asel,s,area,,am-2,am,1
            extrude_aset,l_cyl
        *elseif,arc_ang,eq,360,then
            asel,s,area,,am-3,am,1
            extrude_aset,l_cyl
        *endif
    *endif
    !
    init_entity_num
    !
    csys,cs_num
    !
    lplot
*endif
!
*set,cs_num,
*set,s_or_prt,
*set,diam_i,
*set,diam_o,
*set,wall_thk,
*set,l_cyl,
*set,arc_ang,
*set,rad_i,
*set,rad_o,
*set,z_pos,

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