!   TITLE:  extrude_aset.mac (SM_TOOL)
!
!
!       Added new-volume counting capability to be used by command macro:
!       CREATE_VOLS-AREAS. Added capability to select a particular area
!       for extrude. Added capability to merge coincident areas from
!       extrude (argument 3).
!
!   OBJECTIVE:
!
!   This sub-macro extrudes a selected set of areas by a given distance.
!
!
!   COMMAND SYNTAX:
!
!                      (1)    (2)     (3)
!       EXTRUDE_ASET, d_ext, area_#, sepo
!
!
!   ARGUMENTS:
!
!       (1) d_ext = distance to extrude the set of areas.
!
!       (2) area_# = area number of the area to extrude (if not the selected
!                    set of areas).
!
!       (3) sepo = boolean to decide sharing or separate coincident areas:
!
!               0 (or blank) = coincident areas are merged.
!
!               1 = coincident areas are separate.
!
!
!   DESCRIPTION:
!
!   The algorithm extrudes the selected set of areas and then restores the
!   selected set to the full model set.
!
!   The extrusion will be in the positive outward normal direction for each
!   area in the selected set of areas if D_EXT is positive, and in the negative
!   normal direction if D_EXT is negative. Therefore, care must be taken to
!   ensure the desired extrude direction is executed for each area.
!
!   If a single area is desired to extrude, argument 2 may be used to specify
!   the desired area. This over-rides the current selected set of areas and
!   extrudes only that area. If argument 2 is left blank, then the selected
!   set of areas will be extruded.
!
!   If a set of 2 or more selected areas share a common line (side), they are
!   extruded into separate volumes with coincident, but separate, areas at the
!   shared line by default. If it desired to have these volumes share a common
!   side, then argument 3 should be left blank (or 0). If it is desired to have
!   separate and coincident areas, then argument 3 should be specified as a 1.
!
!   *** IMPORTANT: The newly created volumes are stored in a component group
!                  for use in subsequent boolean operations. The volumes are
!                  stored in a component group named:
!
!                                   new_vols
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
dext__=arg1
anum__=arg2
sep__=arg3
!
*if,anum__,gt,0,then
    asel,s,area,,anum__
*endif
!
*get,alow__,area,,num,min
*get,ahigh__,area,,num,max
!
xvcnt_=0
!
*do,iii__,alow__,ahigh__,1
    *if,asel(iii__),eq,1,then
        voffst,iii__,dext__
    *endif
*enddo
!
init_entity_num
vsel,s,volu,,vm-(xvcnt_-1),vm
!
*if,sep__,eq,0,then
    aslv,s
    lsla,s
    ksll,s
    nummrg,kp
    init_entity_num
*endif
!
vsel,s,volu,,vm-(xvcnt_-1),vm
cm,new_vols,volu
init_entity_num
!
aplot
!
*set,dext__,
*set,iii__,
*set,alow__,
*set,ahigh__,
*set,xvcnt_,
!
*if,prkey_,eq,1,then
    /go
*endif