Standards

 Standardization is important and fun.


Variable Format for ANSYS Macros

Naming Convention for ANSYS Variables

Revision: A

RevDate: May 11, 2001

Maintainer: James Judd

Table of Contents (TOC):

Purpose To Be Done

Conventions: General Letter Case Part Name Type / Subtype Number

Purpose:

Define a format for naming variables in ANSYS macros to provide the following:

  • Minimize overlap of variable names between parts
  • Easy recognition of variables meaning in terms of: part referenced , type of variable, sub type of variable, number group, etceteras.

General Convention: TOC

Six to eight alphanumeric letters in the format ## $$ %% where

  • ## = abbreviation of part name.
  • $$ = abbreviation of parameter type and possibly subtype.
  • %% = parameter number ranging from 00 to 99.

8 alphanumeric characters are allowed for each variable, therefore any one of the groups (e.g. ##, $$, or %%) could have one additional alphanumeric character per variable.

Letter Case Conventions: TOC

Upper and lower case letters are used to visually differentiate between the alpha character groups (e.g. ## and $$) and to differentiate between the type and subtype within the $$ group.

  • ## Use lowercase letters for all characters.
  • $$ First character is uppercase and the second character may be upper or lower case.
  • %% Usually use numeric character but if use alpha character then choose lower case.

Specific Conventions: TOC

## Part Name

  • Try to use only two letters. [Example: hs = housing sleeve]
  • Try not to repeat among other parts.

%% Number TOC

  • Suggest 00 for global signifigance; 01 up for specific; and 99 down for temporary definitions.
  • Suggest using ‘tens’ place for category as appropriate. [For example: hsCV10 represents entire left half of model while hsCV20 represents right half. Within left half could have bottom portion = hsCV11 and top portion = hsCV12. ]
  • See Type / SubType list below for specific conventions for specific parameter types

$$ Type / SubType TOC

CS | coordinate system number (e.g. __ in ‘Local’ command). Use first % for coordinate system type, 0=cartesian, 1=cylindrical, 2=spherical. Use second, etc % for iterative number where 0 is reserved for the part’s main CS. Ex. stCS10 = main cylindrical CS for stator. Ex. stCS01 = a global CS for stator which is referenced (clocal) to the main stator CS, stCS00.
CSn | Active CS number used to define part's local CS (e.g. in CLOCAL command). Note: without a partname refers to a CS counter, with partname refers to CS number.
CSx | X dimension to part's coordinate system from CSn in terms of CSn. If no CSn assume in reference to global CS.
CSy, CSz, CSxy, CSyz, CSzx | similar to CSx but for Y, Z, rotXY, rotYZ, and rotZX.
CV | component group - volume
CA, CL, CK, CN, CE | similar to CV but for areas, lines, keypoints, nodes, and elements respectively.
Da | Dimension ANGULAR
Dc | Dimension CHAMFER.
Do | Similar to Dx but for other dimensions that are not in direction of part’s CS axes.
Dr | Dimension in RADIAL direction
Dx | Dimension in part’s X axis direction from unspecified origin (e.g. length from/to shown by dimension arrows on drawing). See Px etc. for alternative.
Dy, Dz | Similar to Dx but for dimension in part’s Y and Z axis direction respectively.
ETn | arbitrary local Element Type number (i.e. ITYPE in ET command) Note: without a partname refers to a counter, with partname refers to part.
MPn | material property number (e.g. ‘mat’ in ‘MP’ command) Note: without a partname refers to a counter, with partname refers to part.
NUXY | ‘Minor Poisson’s Ratio’ for material identified by part name. [Ex: ssNUXY = poisson’s ratio for stainless steel]
EX, DENS, etc. | Similar to NUXY but for other material property types.
PF | Parameter File. Designates the array file for storing part parameters. Note: a prefix number is not required.
Px | Dimension in part’s X axis direction from origin of part’s CS to specified point. (e.g. dimension is always assumed to be from origin of CS to point specified and no dimension line is required on drawings). See Dx etc. for alternative.
Py, Pz | Similar to Px but for dimension in parts Y and Z axis direction respectively.

TOC

To Be Done (TBD):

  • Under ‘Letter Case Convention’ explain how NT and Unix treat case differently in ANSYS for variables, character arrays, and macro name.

(Items planned for functional expansion or correction. Official list is in comments database.) TOC


w:\ansys\mac\tools\bearing_compliance.mac.html

!   TITLE:  bearing_compliance.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -   03/24/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a bearing section to analyze the compliance
!   of a bearing in the radial direction.  It uses Hertzian contact
!   equations to initiate the model.
!
!       ctbcs:      Cartesian Bearing Coordinate System
!       cylbcs:     Cylindrical Bearing Coordinate System
!       sphbcs:     Spherical Bearing Coordinate System
!
!******************************* TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   2.  Material and Element Type
!   4.  Solid Model
!       4.1  Bearing Race Cross Sections
!           4.1.1  Inner/Outer Race Profiles
!           4.1.2  Circular Cross Section Cut
!           4.1.3  Relocate Race Profiles
!
!************************** Model Assembly Preparation **********************
!
mod_assemb_prep     ! prepare database for assembly
!
/dev,font,1,charter,bold,r,26,,,,,
!
/title,Bearing Compliance Analysis
!
/view,1,1,1,1
/auto,1
/replot
!
/units,bin      ! British/inch units
/prep7
!
!**************************** End Model Preparation *************************
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>

        name='bearing'  ! part name selection variable
                ! (must be 8 characters or less)

        !--------------- model c.s. names --------------

        ct_name='ctbcs'     ! cartesian
        cyl_name='cylbcs'   ! cylindrical
        sph_name='sphbcs'   ! spherical

            ! (all names must be 8 characters or less)
        !-----------------------------------------------

        pi=acos(-1) !---------- CONSTANTS ----------
        rconv=pi/180       ! radian conversion constant
        dconv=180/pi       ! degree conversion constant
        rtangle=(pi/2)*dconv

        rin=2.00
        rout=2.50
        h=0.5
        chmf=.05
        wgap=0.1

        dball=0.28
        rrace=0.15
        dbc=rin+((rout-rin)/2)
        dcl=(2*rrace)-dball
        w=wgap+dcl

!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
!acs=0      ! active coordinate system (c.s.) locating model c.s.
!
!------------- Specify model c.s. center location --------------
!
xc=1.00     ! x (r) coordinate center
yc=2.00     ! y (theta) coordinate center
zc=3.00     ! z (z or phi) coordinate center
!
!------------- Specify model c.s. orientation ------------------
!
rotxy=0     ! 1st rotation angle (+x to +y)
rotyz=0     ! 2nd rotation angle (+y to +z)
rotzx=0     ! 3rd rotation angle (+z to +x)
!
!---------------------------------------------------------------
!
*if,csn,eq,0,then
    csn=10      ! initialize local c.s. numbers
*endif
!
csn=csn+1
%ct_name%=csn       ! cartesian model c.s. number
!
csn=csn+1
%cyl_name%=csn      ! cylindrical model c.s. number
!
csn=csn+1
%sph_name%=csn      ! spherical model c.s. number
!
csys,acs
clocal,%ct_name%,0,xc,yc,zc,rotxy,rotyz,rotzx
!
csys,acs
clocal,%cyl_name%,1,xc,yc,zc,rotxy,rotyz,rotzx
!
csys,acs
clocal,%sph_name%,2,xc,yc,zc,rotxy,rotyz,rotzx
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<< 3.  Material and Element Type >>>>>>>>>>>>>>>>>>>
!
*if,assemble,eq,0,then
!
!---------------------- Material Properties --------------------
!
UIMP,1,EX, , ,10.3E6,       ! Material:  Aluminum
UIMP,1,DENS, , ,.097/386.4,
UIMP,1,NUXY, , ,0.33,
!
!---------------------------------------------------------------
!
!
!------------------------- Element Type ------------------------
!
ET,1,shell93
ET,2,solid95
!
!---------------------------------------------------------------
!
*endif
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!------------------ 4.1  Bearing Race Cross Sections -----------------
!
!
!------------------ 4.1.1  Inner/Outer Race Profiles -----------------
!
csys,ctbcs
!
k,,0,0,0
k,,0,1,0
!
init_entity_num
!
axp1=km-1
axp2=km
!
k,,rin-dcl/2+chmf,0,0
k,,dbc-(w/2),0,0
k,,dbc-(w/2),h,0
k,,rin-dcl/2+chmf,h,0
k,,rin-dcl/2,h-chmf,0
!
k,,rin-dcl/2,chmf,0
!
init_entity_num
!
a,km-5,km-4,km-3,km-2,km-1,km
!
k,,dbc+(w/2),0,0
k,,rout+dcl/2-chmf,0,0
k,,rout+dcl/2,chmf,0
k,,rout+dcl/2,h-chmf,0
k,,rout+dcl/2-chmf,h,0
!
k,,dbc+(w/2),h,0
!
init_entity_num
!
a,km-5,km-4,km-3,km-2,km-1,km
!
lplot
!
!------------------ 4.1.2  Circular Cross Section Cut ---------------
!
csys,ctbcs
!
csn=csn+1
bcs=csn
clocal,bcs,1,dbc,h/2,0,0,0,0
!
*do,i,0,3*rtangle,rtangle
    k,,rrace,i,0
*enddo
!
init_entity_num
!
a,km-3,km-2,km-1,km
!
init_entity_num
!
asba,am-2,am,,delete,keep
asba,am-1,am,,delete,delete
!
init_entity_num
!
lplot
!
!------------------- 4.1.3  Relocate Race Profiles ------------------
!
csys,ctbcs
csn=csn+1
outrcs1=csn
clocal,outrcs1,0,dbc+w/2,0,0,0,0,0
!
csys,ctbcs
csn=csn+1
inrcs1=csn
clocal,inrcs1,0,dbc-w/2,0,0,0,0,0
!
csn=csn+1
inrcs2=csn
clocal,inrcs2,0,dcl/2,0,0,0,0,0
!
csys,outrcs1
csn=csn+1
outrcs2=csn
clocal,outrcs2,0,-dcl/2,0,0,0,0,0
!
csys,ctbcs
asel,selv,loc,x,rin-dcl/2,dbc
!
csys,inrcs1
atran,inrcs2,all,,,,1,1
!
init_entity_num
!
csys,ctbcs
asel,selv,loc,x,dbc,rout+dcl/2
!
csys,outrcs1
atran,outrcs2,all,,,,0,1
!
init_entity_num
!
lplot
!

*go,:skip1

csys,bcs
*do,i,0,3*rtangle,rtangle
    k,,dball/2,i,0
*enddo
!
init_entity_num
!
a,km-3,km-2,km-1,km
!

:skip1

!*go,:skip2

vrotat,all,,,,,,axp1,axp2,360,4

!:skip2

*go,:skip3

csys,bcs
!
k,,0,0,0
*do,i,0,rtangle,rtangle
    k,,dball/2,i,0
*enddo
!
init_entity_num
!
a,km-2,km-1,km
!
sphrp1=km-2
sphrp2=km
!
asel,selv,loc,r,0,dball/2
asel,r,loc,y,0,rtangle
!
vrotat,all,,,,,,sphrp1,sphrp2,360,4
!
init_entity_num
!
csn=csn+1
clocal,csn,0,0,0,0,0,0,0
!
vsel,selv,loc,y,0,dball/2
vsel,r,loc,x,-dball/2,dball/2
!
vsymm,y,all,,,,1,0
!
init_entity_num
!
aplot

:skip3

finalize_model_data


w:\ansys\mac\tools\coil.mac.html

!   TITLE:  coil.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -   03/22/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a circular cross-section coil spring.  Parameter
!   values can be adjusted to vary the:
!
!               a.) pitch
!               b.) coil radius
!               c.) wire radius
!               d.) number of coils
!
!       ctclcs:     Cartesian Coil Coordinate System
!       cylclcs:    Cylindrical Coil Coordinate System
!       sphclcs:    Spherical Coil Coordinate System
!
!
!******************************* TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Solid Model
!
!
!************************** Model Assembly Preparation **********************
!
!
mod_assemb_prep                 ! prepare database for assembly
!
!
/title,Coil Spring
!
!
/units,bin
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
*ask,rcoil,coil radius,5
*ask,pitch,coil pitch,3
*ask,rwire,wire radius,0.75
*ask,cycle,number of turns,5
!
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
!
mod_coord_system,0,1,2,3,0,0,0
!
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 3.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
k=pitch/(4*rtangle)
thetamax=cycle*(4*rtangle)
inclang=(atan(pitch/(2*pi*rcoil)))*dconv
s=2*rwire*sin(inclang*rconv)
phi=((s/rcoil)/2)*dconv
lcount=0
!
csys,cs1_
!
*do,theta,0,thetamax,rtangle
    k,,rcoil,theta,k*theta
*enddo
!
init_entity_num
!
*do,i,(km-(thetamax/rtangle)),km-1,1
    l,i,i+1
    lcount=lcount+1
*enddo
!
init_entity_num
!
ckp=km-(thetamax/rtangle)
!
create_cs,0,'cs_cs',1,kx(ckp),ky(ckp),kz(ckp),0,rtangle+inclang,0
!
*do,i,0,3*rtangle,rtangle
    k,,rwire,i,0
*enddo
!
init_entity_num
!
csys,0      ! remove for circular cross-section
a,km-3,km-2,ckp
a,km-2,km-1,ckp
a,km-1,km,ckp
a,km,km-3,ckp
!
csys,cs1_
!
*do,i,0,((4*cycle)-1),1
    beta=mod((rtangle*i),4*rtangle)
    asel,selv,loc,y,beta-phi,beta+phi
    asel,r,loc,x,(rcoil-rwire),(rcoil+rwire)
    asel,r,loc,z,(k*rtangle*i-rwire),(k*rtangle*i+rwire)
    vdrag,all,,,,,,lm-(lcount-1-i),
*enddo
!
init_entity_num
!
lplot


w:\ansys\mac\tools\draw_lam-coil.mac.html

!   TITLE:  draw_lam-coil.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      07/13/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
FINISH
/CLEAR,START
/prep7
/title,Lamination-Coil Assembly
/PNUM,KP,1
!
r1=1.160/2
r2=2.375/2
r3=1.210/2
r4=2.155/2
l1=0.504
l2=0.300
!
!------------------------ 4.1  Lamination Stack -----------------------
!
csys,0
!
k,,0,r1,0       ! points 1 thru 4
k,,l1,r1,0
k,,l1,r2,0
k,,0,r2,0
!
create_area
!
lplot
!
!--------------------------- 4.2  Stator Wire -------------------------
!
csys,0
!
k,,0,r3,0       ! points 5 thru 8
k,,0,r4,0
k,,-l2,r4,0
k,,-l2,r3,0
!
create_lines
!
lfillt,lm-2,lm-1,0.2*((r2-r3)-(r2-r4))
lfillt,lm-1,lm,0.2*((r2-r3)-(r2-r4))
!
isolate_lines
al,all
init_entity_num
!
k,,l1,r4,0      ! points 9 thru 12
k,,l1,r3,0
k,,l1+l2,r3,0
k,,l1+l2,r4,0
!
create_lines
!
lfillt,lm-2,lm-1,0.2*((r2-r3)-(r2-r4))
lfillt,lm-1,lm,0.2*((r2-r3)-(r2-r4))
!
isolate_lines
al,all
init_entity_num
!
aglue,am-2,am-1,am
!
init_entity_num
!
lplot
!
!---------------------------- Create Axis of Rotation ----------------------
!
/ANUM ,0,    12, 0.40000    ,-0.48000
/LSPEC,    10,     0, 2.000
/LSYM,-0.720,-0.480, 180,   4, 1.000
/LINE,-0.720,-0.480, 1.520,-0.480
/LSYM, 1.520,-0.480,   0,   4, 1.000
/ANUM ,0,     1, 0.38000    ,-0.58000
/TSPEC, 15, 1.200,   1,   0,   0
/TLAB, 0.044,-0.580,Axis of Rotation
/ANUM ,0,     1,  1.4300    ,-0.56000
/TLAB, 1.388,-0.560,Z
!
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC,  1,  0.269026393778    ,  0.783939607802    ,   0.00000000000
/REPLO
!
/ANUM ,0,    12,-0.80000E-01,-0.40000
/LSPEC,    10,     0, 1.000
/LSYM,-0.080,-0.320,  90,   4, 1.000
/LINE,-0.080,-0.320,-0.080,-0.480
!
/ANUM ,0,     1,-0.15000    ,-0.36000
/TLAB,-0.192,-0.360,Y
!
!--------------------------------------------------------------------------
!
/FOC,  1,  0.362499374154    ,  0.574066312242    ,   0.00000000000
/REPLO
/FOC,  1,  0.535336205792    ,  0.450611432501    ,   0.00000000000
/REPLO
/FOC,  1,  0.512408870983    ,  0.450611432501    ,   0.00000000000
/REPLO
/FOC,  1,  0.501827024148    ,  0.450611432501    ,   0.00000000000
/REPLO
/ANUM ,0,     3,  1.1650    , 0.45000E-01
/LSPEC,    15,     0, 1.000
/LINE , 0.350, 0.620, 1.250, 0.620
/LINE , 0.370,-0.480, 1.250,-0.480
/LINE , 1.200, 0.120, 1.200, 0.610
/LINE , 1.200, 0.020, 1.200,-0.470
/LSYM , 1.200, 0.610,  90,4, 1.000
/LSYM , 1.200,-0.470, 270,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 1.165, 0.045,r2
/ANUM ,0,     3, 0.94500    , 0.50000E-02
/LINE , 0.590, 0.540, 1.030, 0.540
/LINE , 0.570,-0.480, 1.030,-0.480
/LINE , 0.980, 0.080, 0.980, 0.530
/LINE , 0.980,-0.020, 0.980,-0.470
/LSYM , 0.980, 0.530,  90,4, 1.000
/LSYM , 0.980,-0.470, 270,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.945, 0.005,r4
/ANUM ,0,     3, 0.74500    ,-0.19500
/LINE , 0.590, 0.140, 0.830, 0.140
/LINE , 0.550,-0.480, 0.830,-0.480
/LINE , 0.780,-0.120, 0.780, 0.130
/LINE , 0.780,-0.220, 0.780,-0.470
/LSYM , 0.780, 0.130,  90,4, 1.000
/LSYM , 0.780,-0.470, 270,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.745,-0.195,r3
/ANUM ,0,     3, 0.22500    ,-0.21500
/LINE , 0.270, 0.100, 0.310, 0.100
/LINE , 0.250,-0.480, 0.310,-0.480
/LINE , 0.260,-0.140, 0.260, 0.090
/LINE , 0.260,-0.240, 0.260,-0.470
/LSYM , 0.260, 0.090,  90,4, 1.000
/LSYM , 0.260,-0.470, 270,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.225,-0.215,r1
/ANUM ,0,     3,-0.26500    ,-0.12500
/LINE ,-0.100, 0.090,-0.100,-0.150
/LINE ,-0.360, 0.130,-0.360,-0.150
/LINE ,-0.160,-0.100,-0.110,-0.100
/LINE ,-0.300,-0.100,-0.350,-0.100
/LSYM ,-0.110,-0.100,   0,4, 1.000
/LSYM ,-0.350,-0.100, 180,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB ,-0.265,-0.125,l2
/ANUM ,0,     3, 0.42500    ,-0.12500
/LINE , 0.340, 0.110, 0.340,-0.150
/LINE , 0.580, 0.110, 0.580,-0.150
/LINE , 0.390,-0.100, 0.350,-0.100
/LINE , 0.530,-0.100, 0.570,-0.100
/LSYM , 0.350,-0.100, 180,4, 1.000
/LSYM , 0.570,-0.100,   0,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.425,-0.125,l2
/ANUM ,0,     3, 0.85000E-01, 0.41500
/LINE ,-0.080, 0.410,-0.080, 0.490
/LINE , 0.320, 0.390, 0.320, 0.490
/LINE , 0.050, 0.440,-0.070, 0.440
/LINE , 0.190, 0.440, 0.310, 0.440
/LSYM ,-0.070, 0.440, 180,4, 1.000
/LSYM , 0.310, 0.440,   0,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.085, 0.415,l1
/replot
!
/ANUM ,0,     1,-0.66000    , 0.84000
/TSPEC, 15, 0.900,   1,   0,   0
/TLAB,-0.849, 0.840,r1 = 1.160/2
/ANUM ,0,     1,-0.70000    , 0.78000
/TLAB,-0.889, 0.780,r2 = 1.210/2
/ANUM ,0,     1,-0.73000    , 0.72000
/TLAB,-0.919, 0.720,r3 = 2.155/2
/ANUM ,0,     1,-0.76000    , 0.66000
/TLAB,-0.949, 0.660,r4 = 2.375/2
/ANUM ,0,     1,-0.71000    , 0.56000
/TLAB,-0.867, 0.560,l1 = 0.504
/ANUM ,0,     1,-0.76000    , 0.46000
/TLAB,-0.917, 0.460,l2 = 0.300
/ANUM,     0,     1,-0.65991    , 0.71985
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.849, 0.720,r1 = 1.160/2
/ANUM,     0,     1,-0.69995    , 0.65979
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.889, 0.660,r2 = 1.210/2
/ANUM,     0,     1,-0.72998    , 0.59985
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.919, 0.600,r3 = 2.155/2
/ANUM,     0,     1,-0.75989    , 0.53979
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.949, 0.540,r4 = 2.375/2
/ANUM,     0,     1,-0.70996    , 0.43982
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.867, 0.440,l1 = 0.504
/ANUM,     0,     1,-0.75989    , 0.33984
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.917, 0.340,l2 = 0.300
/ANUM,    13,DELE
/ANUM,    14,DELE
/ANUM,    15,DELE
/ANUM,    16,DELE
/ANUM,    17,DELE
/ANUM,    18,DELE
/REPLOT
!
/ANUM,     0,     1,-0.17969    , 0.87976
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.369, 0.880,r1 = 1.160/2
/ANUM,     0,     1,-0.21973    , 0.81958
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.409, 0.820,r2 = 1.210/2
/ANUM,    19,DELE
/ANUM,    20,DELE
/ANUM,     0,     1,-0.41968    , 0.79956
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.609, 0.800,r1 = 1.160/2
/ANUM,     0,     1,-0.45972    , 0.73938
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.649, 0.740,r2 = 1.210/2
/ANUM,    13,DELE
/ANUM,    14,DELE
/ANUM,    15,DELE
/ANUM,    21,DELE
/ANUM ,0,     1,-0.55000    , 0.88000
/TLAB,-0.739, 0.880,r1 = 1.160/2
/ANUM ,0,     1, 0.12000    , 0.86000
/TLAB,-0.069, 0.860,r3 = 2.155/2
/ANUM,     0,     1,-0.55969    , 0.81934
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.749, 0.820,r2 = 1.210/2
/ANUM,    16,DELE
/ANUM,     0,     1,-0.55994    , 0.75989
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.749, 0.760,r3 = 2.155/2
/ANUM,    14,DELE
/ANUM,     0,     1,-0.55981    , 0.69958
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.749, 0.700,r4 = 2.375/2
/ANUM,    22,DELE
/ANUM,     0,     1,-0.71985    , 0.37964
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.877, 0.380,l2 = 0.300
/ANUM,    24,DELE
/ANUM,     0,     1,-0.59973    , 0.55957
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.757, 0.560,l2 = 0.300
/ANUM,     0,     1,-0.58972    , 0.61975
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.747, 0.620,l1 = 0.504
/ANUM,    17,DELE
/ANUM,    23,DELE
/ANUM,     0,     1,-0.70984    , 0.63977
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.899, 0.640,r1 = 1.160/2
/ANUM,     0,     1,-0.71960    , 0.45935
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.909, 0.460,r4 = 2.155/2
/ANUM,     0,     1,-0.71948    , 0.57922
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.909, 0.580,r2 = 2.375/2
/ANUM,     0,     1,-0.71985    , 0.51978
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.909, 0.520,r3 = 1.210/2
/ANUM,     0,     1,-0.75952    , 0.31934
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.917, 0.320,l2 = 0.300
/ANUM,     0,     1,-0.74951    , 0.37952
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.907, 0.380,l1 = 0.504
/ANUM,    13,DELE
/ANUM,    14,DELE
/ANUM,    15,DELE
/ANUM,    16,DELE
/ANUM,    18,DELE
/ANUM,    19,DELE
!
/ANUM ,0,     1, 0.58000    , 0.82000
/TLAB, 0.517, 0.820,Coil
/ANUM ,0,     1,  0.0000    , 0.84000
/TLAB,-0.158, 0.840,Lamination
/ANUM ,0,     1, 0.91000    , 0.82000
/TLAB, 0.847, 0.820,Coil
/ANUM,     0,     1, 0.13989    , 0.23987
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.018, 0.240,Lamination
/ANUM,    14,DELE
/ANUM,     0,     1,-0.21997    , 0.31995
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.283, 0.320,Coil
/ANUM,    13,DELE
/ANUM,     0,     1, 0.46985    , 0.31995
/TSPE, 15, 0.900,   1,   0,   0
/TLAB, 0.407, 0.320,Coil
/ANUM,    15,DELE
/replot
!
/ANUM ,0,     1,-0.31170    , 0.82027
/TLAB,-0.837, 0.820,These parameters are found in
/ANUM,     0,     1,-0.16479    , 0.73511
/TLAB,-0.830, 0.735,parameter file:   LAM-COIL.PARM
/ANUM,    16,DELE
/ANUM,     0,     1,-0.93994E-02, 0.88391
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.535, 0.884,These parameters are found in
/ANUM,     0,     1, 0.13745    , 0.79883
/TSPE, 15, 0.900,   1,   0,   0
/TLAB,-0.528, 0.799,parameter file:   LAM-COIL.PARM
/ANUM,    15,DELE
/ANUM,    18,DELE
/replot
!
toolbar


w:\ansys\mac\tools\draw_weld_profile.mac.html

!   TITLE:  draw_weld_profile.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/01/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates the cross-sectional profile of the weld
!   cross-section.
!
!---------------------------------------------------------------------------
!
!
clear_start_new
mod_assemb_prep
/title, Weld Profile
!
csys,0
!
weld_profile,1,6,4,3+6,0,0,0,0
!
view,'f'
!
aplot
!
!--------------------------------------------------------------------
!
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC, 1 ,,-0.300000,,1
/REP,FAST
/FOC, 1 ,,0.100000,,1
/REP,FAST
!
/ANUM ,0,     3, 0.19536    , 0.82494
/LINE , 0.257, 0.705, 0.257, 0.800
/LINE , 0.414, 0.690, 0.414, 0.800
/LINE , 0.157, 0.750, 0.247, 0.750
/LINE , 0.514, 0.750, 0.424, 0.750
/LSYM , 0.247, 0.750,   0,4, 1.000
/LSYM , 0.424, 0.750, 180,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.195, 0.825,wld_wdth
!
/ANUM ,0,     3, 0.64007    , 0.16143
/LINE , 0.435,-0.289, 0.830,-0.289
/LINE , 0.439, 0.662, 0.830, 0.662
/LINE , 0.780, 0.136, 0.780,-0.279
/LINE , 0.780, 0.236, 0.780, 0.652
/LSYM , 0.780,-0.279, 270,4, 1.000
/LSYM , 0.780, 0.652,  90,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.640, 0.161,wld_dpth
!
/ANUM ,0,    12, 0.35000    , 0.61638
/LSYM, 0.366, 0.677,  74,   4, 1.000
/LINE, 0.366, 0.677, 0.334, 0.556
/ANUM ,0,    12, 0.23837    , 0.55601
/LINE, 0.334, 0.556, 0.143, 0.556
/ANUM ,0,     1,-0.36807    , 0.49746
/TLAB,-0.823, 0.497,beadrad=bdraf*wld_wdth
!
/ANUM ,0,     3, 0.60621E-01,-0.88877
/LINE ,-0.219,-0.782,-0.219,-0.914
/LINE , 0.410,-0.314, 0.410,-0.914
/LINE , 0.026,-0.864,-0.209,-0.864
/LINE , 0.166,-0.864, 0.400,-0.864
/LSYM ,-0.209,-0.864, 180,4, 1.000
/LSYM , 0.400,-0.864,   0,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 0.061,-0.889,xc
!
/ANUM,     0,     1,-0.15564    , 0.52661
/TLAB,-0.611, 0.526,beadrad=bdraf*wld_wdth
/ANUM,     5,DELE
!
/ANUM ,0,    12,-0.53758    , 0.29986
/LSPEC,    10,     0, 1.000
/LSYM,-0.538, 0.373,  90,   4, 1.000
/LINE,-0.538, 0.373,-0.538, 0.227
/ANUM ,0,    12,-0.48634    , 0.15349
/LSYM,-0.567, 0.153, 180,   4, 1.000
/LINE,-0.567, 0.153,-0.406, 0.153
/ANUM ,0,    12,-0.31431    , 0.24131
/LSYM,-0.237, 0.241,   0,   4, 1.000
/LINE,-0.237, 0.241,-0.391, 0.241
/ANUM,     0,    12, 0.41406    , 0.73889
/LSYM, 0.414, 0.812,  90,   4, 1.000
/LINE, 0.414, 0.812, 0.414, 0.666
/ANUM,     5,DELE
/ANUM,     0,    12, 0.48730    , 0.66565
/LSYM, 0.565, 0.665,   0,   4, 1.000
/LINE, 0.565, 0.665, 0.411, 0.665
/ANUM,    10,DELE
/ANUM,     9,DELE
!
/ANUM ,0,     1,-0.73969    , 0.76092
/TSPEC, 10, 1.000,   1,   0,   0
/TLAB,-0.757, 0.761,X
/ANUM ,0,     1,-0.65185    , 0.19740
/TLAB,-0.669, 0.197,Y
/ANUM ,0,     1,-0.42366    , 0.28522
/TLAB,-0.494, 0.285,wpcs
/ANUM,     0,     1, 0.54504    , 0.58154
/TLAB, 0.528, 0.582,X
/ANUM,     9,DELE
/ANUM,     0,     1, 0.37671    , 0.75720
/TLAB, 0.359, 0.757,Y
/ANUM,    10,DELE
/ANUM,     0,     1, 0.59387    , 0.68762
/TLAB, 0.524, 0.687,wpcs
/ANUM,    12,DELE
!
/ANUM ,0,     1,-0.57109    , 0.88534
/TLAB,-0.904, 0.885,(weld profile C.S.)
/ANUM,     0,     1, 0.99915    , 0.69128
/TLAB, 0.666, 0.691,(weld profile C.S.)
/ANUM,    12,DELE
!
/ANUM,    11,DELE
/ANUM,     8,DELE
/ANUM ,0,    12,-0.65837    , 0.23582
/LSYM,-0.658, 0.304,  90,   4, 1.000
/LINE,-0.658, 0.304,-0.658, 0.168
/ANUM ,0,     1,-0.48714    , 0.12422
/TLAB,-0.505, 0.124,X
/ANUM,     0,    12, 0.40674    , 0.72961
/LSYM, 0.407, 0.798,  90,   4, 1.000
/LINE, 0.407, 0.798, 0.407, 0.662
/ANUM,     8,DELE
/ANUM,     0,     1, 0.51208    , 0.58875
/TLAB, 0.494, 0.589,X
/ANUM,    11,DELE
!
/ANUM ,0,     3,  1.0452    ,-0.72765E-01
/LSPEC,    15,     0, 1.000
/LINE ,-0.074,-0.758, 1.130,-0.758
/LINE , 0.834, 0.662, 1.130, 0.662
/LINE , 1.080,-0.098, 1.080,-0.748
/LINE , 1.080, 0.002, 1.080, 0.652
/LSYM , 1.080,-0.748, 270,4, 1.000
/LSYM , 1.080, 0.652,  90,4, 1.000
/TSPEC, 15, 1.000,   1,   0,   0
/TLAB , 1.045,-0.073,yc
!
/replot


w:\ansys\mac\tools\weld_profile.mac.html

!   TITLE:  weld_profile.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/01/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a model of a weld fillet profile for analyzing
!   stresses through the weld cross-section.
!
!   COMMAND SYNTAX:
!
!
!                       (1)        (2)    (3)  (4)  (5)  (6)    (7)
!       WELD_PROFILE, wld_wdth, wld_dpth, xc,  yc,  zc, rotxy, rotyz,
!
!                     rotzx, bdraf
!                      (8)    (9)
!
!   ARGUMENTS:
!
!       wld_wdth = width of weld
!
!       wld_dpth = weld penetration depth
!
!       xc = x coordinate of the weld C.S. center relative to the active C.S.
!
!       yc = y coordinate of the weld C.S. center relative to the active C.S.
!
!       zc = z coordinate of the weld C.S. center relative to the active C.S.
!
!       rotxy = xy angular rotation of the weld C.S. relative to the active C.S.
!
!       rotyz = yz angular rotation of the weld C.S. relative to the active C.S.
!
!       rotzx = zx angular rotation of the weld C.S. relative to the active C.S.
!
!       bdraf = weld bead radius factor. The weld bead radii are this multiple
!               of the weld width. ( bdraf > or = 0.5 )
!
!
!   DESCRIPTION:
!
!   The weld profile is an area representing a cross-sectional cut of the
!   weld zone joining 2 separate parts or sections. The weld width and depth
!   of penetration must be specified, along with the coordinate position of
!   the weld C.S., as measured from the active C.S. The radius of the weld
!   beads are specified as some multiple of the weld width. The default value
!   of this factor, i.e., BDRAF, is 1, but may be over-ridden with a desired
!   user-specified value.
!
!   A layout of this profile, and the pertinent input arguments, is created
!   by DRAW_WELD_PROFILE.MAC.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*get,actcs_,active,,csys
!
*get,acttyp_,cdsy,actcs_,attr,kcs
!
*if,acttyp_,ne,0,then
    create_cs,0,'wpcs_',0,0,0,0,0,0,0
*endif
!
wldwdth_=arg1
wlddpth_=arg2
xwcnt_=arg3
ywcnt_=arg4
zwcnt_=arg5
xywcnt_=arg6
yzwcnt_=arg7
zxwcnt_=arg8
bdraf_=arg9
!
!
*if,bdraf_,eq,0,then
    bdraf_=1
*else
    *if,bdraf_,lt,0.5,then
        bdraf_=0.5
    *endif
*endif
!
beadrad_=bdraf_*wldwdth_
!
bdcdpth_=sqrt((beadrad_**2)-((0.5*wldwdth_)**2))
!
create_cs,0,'weldcs',0,xwcnt_,ywcnt_,zwcnt_,xywcnt_,yzwcnt_,zxwcnt_
!
k,,0,0,0
k,,0,-wlddpth_,0
k,,-wldwdth_,-wlddpth_,0
k,,-wldwdth_,0,0
!
init_entity_num
!
lstr,km-3,km-2
lstr,km-1,km
!
init_entity_num
!
create_cs,0,,1,-0.5*wldwdth_,-bdcdpth_,0,0,0,0
!
l,km,km-3
!
init_entity_num
!
csys,weldcs
create_cs,0,,1,-0.5*wldwdth_,-(wlddpth_+bdcdpth_),0,0,0,0
!
l,km-2,km-1
!
init_entity_num
!
lsel,s,line,,lm-3,lm,1
al,all
!
init_entity_num
!
csys,actcs_
!
lplot
!
*set,wldwdth_,
*set,wlddpth_,
*set,xwcnt_,
*set,ywcnt_,
*set,zwcnt_,
*set,xywcnt_,
*set,yzwcnt_,
*set,zxwcnt_,
*set,beadrad_,
*set,bdcdpth_,
*set,actcs_,

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


w:\ansys\mac\tools\nut.mac.html

!   TITLE:  nut.mac (PART_LIB)
!
mod_assemb_prep
!
k,,0,0
k,,1.5,0
k,,1.5,.75
k,,1,1
k,,0,1
!
create_area
!
revolve_aset,km,km-4,90,1
!
create_cs,0,,1,0,1.2,0,0,-90,0
!
k,,1.5,0,0
k,,1.5,-60,0
k,,1.5,-120,0
k,,1.5,-120,-2
!
create_lines,,1
!
adrag,lm-2,lm-1,,,,,lm
!
ldele,lm,,,1
!
init_entity_num
!
isolate_areas
cm,aset1,area
init_entity_num
!
vol_part_area,'aset1'
!
vdele,vm-2,vm-1,1,1
!
init_entity_num
!
csys,0
vsymm,x,vm
vsymm,z,vm,vm+1,1
!
vadd,all


w:\ansys\mac\tools\magnet.mac.html

!   TITLE:  magnet.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -       02/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a motor magnet cross-section.  The active C.S. must
!   be a cartesian C.S. The position and orientation of the C.S. orients the
!   position of the magnet within the assembly.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MAGNET, width, height, chamfer
!
!---------------------------------------------------------------------------
!
!
wdth_=arg1
hgth_=arg2
chmf_=arg3
!
!
*get,mag_cs,active,,csys
!
csys,mag_cs
!
k,,wdth_/2,0,0
k,,wdth_/2,hgth_,0
k,,-wdth_/2,hgth_,0
k,,-wdth_/2,0,0
!
create_lines
!
chamfer_area,1,lm-3,lm-2,chmf_
chamfer_area,1,lm,lm-6,chmf_
chamfer_area,1,lm-2,lm-10,chmf_
chamfer_area,1,lm-3,lm-13,chmf_
!
csys,mag_cs
!
lplot
!
*set,wdth_,
*set,hgth_,
*set,chmf_,


w:\ansys\mac\tools\screw_thread_2d.mac.html

!   TITLE:  screw_thread_2d.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     06/22/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a 2d planar axisymmetric screw thread profile.
!   This is used for a preliminary analysis of screw thread stresses in
!   an axisymmetric profile cut through the screw and mating member.
!
!   The threads are layed out in relation to a cartesian c.s. The first
!   keypoint is created at the origin of this c.s. and is the outermost
!   point at the base of the first thread.  The rest of the threads are
!   then created in the first quadrant (+x and +y) of this c.s.
!
!   The thread parameters are chosen for the worst case (conservative)
!   loading conditions; i.e., the smallest root radii, the largest tooth
!   height, etc. Therefore, the user should enter in values for D_MJR and
!   D_MIN that will yield the worst loading dimensions based on the allow-
!   able tolerances as defined by ASME B1.1 - 1989 ( revision of ANSI
!   B1.1 - 1982). This would be the maximum major diameter and the min-
!   imum minor diameter.  If the desired analysis is for the maximum mat-
!   erial condition (MMC), then D_MJR and D_MIN should not be specified,
!   and the program will calculate the thread parameters based on formulae
!   derived at MMC.
!
!   Input for this macro:
!
!           prof = thread profile.  Options are:
!
!               'i' = internal thread profile
!               'x' = external thread profile
!
!           n_thrd = number of threads to create.  If length of
!                thread engagement is known, then specify
!                THRD_LN and leave this parameter blank.
!
!           thrd_ln = thread length.  If N_THRD is not specified,
!                 then the program will calculate the number
!                 of threads in a user specified length of
!                 thread engagement.
!
!           n_inch = number of threads per inch
!
!           stndrd = thread standard.
!
!               'j' = UNJ thread standard, which specifies
!                     a root radius, R_THRD.
!
!               'un' (or blank) = UN thread profile, flat
!                         surface at thread root.
!
!           d_mjr = thread MAXIMUM major diameter
!
!           d_min = thread MINIMUM minor diameter
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! SCREW_THREAD_2D, prof, n_thrd, thrd_ln, n_inch, stndrd, d_mjr, d_min
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

prof=arg1
n_thrd=arg2
thrd_ln=arg3
n_inch=arg4
stndrd=arg5
d_mjr=arg6
d_min=arg7
!
!
lstart=lm_prev
!
!
*get,zzzz,parm,stndrd,type
!
*if,zzzz,eq,0,then
    stndrd='un'
*endif
!
!
*if,n_thrd,eq,0,then
    n_thrd=nint(thrd_ln*n_inch)+1
*endif
!
!
p_thrd=1/n_inch         ! calculation of thread pitch
!
*if,d_mjr,eq,0,then
    h_thrd=(sqrt(3)/2)*p_thrd   ! calculate thread height (MMC)
*else
    h_thrd=(d_mjr-d_min)/2      ! calculate thread height (worst case)
*endif
!
thrd_ang=(2*atan((p_thrd/2)/h_thrd))*dconv  ! thread angle
!
r_thrd=0.15011*p_thrd           ! fillet radius at thread root
!
!
!

*go,:skip

*if,prof,eq,'x',then
!
!---------------------- External Thread Profile -----------------------
!
*get,thrd_cs,active,,csys
!
csn=csn+1
ndselcs=csn
clocal,ndselcs,0,0,0,0,(90-thrd_ang/2),0,0
!
csys,thrd_cs
!
*if,stndrd,eq,'j',then
    *do,iii,0,2*n_thrd,1
        *if,mod(iii,2),eq,0,then
            k,,iii*(p_thrd/2),0,0
        *elseif,mod(iii,2),eq,1,then
            k,,iii*(p_thrd/2),h_thrd,0
            !
            init_entity_num
            !
            k_tip=km
        *endif
        !
        init_entity_num
        !
        *if,iii,gt,0,then
            *if,mod(iii,2),eq,0,then
            lstr,km,k_tip
            *elseif,mod(iii,2),eq,1,then
            lstr,km-1,k_tip
            *endif
        *endif
        !
        init_entity_num
        !
        *if,iii,ge,3,then
           *if,mod(iii,2),eq,1,then
            lfillt,lm-1,lm,r_thrd
           *endif
        *endif
        !
        init_entity_num
    *enddo
    !
    r_width=p_thrd/8
    root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
    r2edge=0.649519*p_thrd
    h_thrd2=root_h+r2edge
    !
    k,,0,h_thrd2,0
    k,,kx(km),h_thrd2,0
    !
    create_lines
    !
    lsel,selv,loc,x,(0.5*p_thrd),(n_thrd-0.5)*p_thrd
    lsel,r,loc,y,(r_thrd/cos(thrd_ang*rconv))*(sin(thrd_ang*rconv))**2,h_thrd
    lsel,r,loc,z,0
    lsel,a,line,,lm-1
    lsel,a,line,,lm-(2*n_thrd+n_thrd-1)
    !
    ln_part_ln,lm
    !
    init_entity_num
    !
    *do,iij,1,2*n_thrd-1,2
        lstr,km-(2*n_thrd-iij),km-(2*n_thrd-iij-1)
    *enddo
    !
    init_entity_num
    !
    *if,d_mjr,eq,0,then
        lsel,selv,loc,y,1.015*((7/8)*h_thrd),h_thrd
    *else
        lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
    *endif
    !
    lsel,r,loc,x,0,n_thrd*p_thrd
    lsel,r,loc,z,0
    !
    ldele,all,,,1
    !
    init_entity_num
    !
    ksel,selv,loc,x,0
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k1_thrd=km
    !
    init_entity_num
    !
    ksel,selv,loc,x,n_thrd*p_thrd
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k2_thrd=km
    !
    init_entity_num
    !
*elseif,stndrd,eq,'un',then
    !
    *do,ijk,0,2*n_thrd,1
        *if,mod(ijk,2),eq,0,then
            k,,ijk*(p_thrd/2),0,0
        *elseif,mod(ijk,2),eq,1,then
            k,,ijk*(p_thrd/2),h_thrd,0
        *endif
        !
        init_entity_num
        !
        *if,ijk,gt,0,then
            lstr,km-1,km
        *endif
        !
        init_entity_num
    *enddo
    !
    k,,0,h_thrd/4,0
    k,,kx(km),h_thrd/4,0
    !
    create_lines
    !
    *if,d_mjr,eq,0,then
        k,,0,(7/8)*h_thrd,0
        k,,kx(km),(7/8)*h_thrd,0
    *else
        r_width=p_thrd/4
        root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
        r2edge=(d_mjr-d_min)/2
        h_thrd2=root_h+r2edge
        !
        k,,0,h_thrd2,0
        k,,kx(km),h_thrd2,0
    *endif
    !
    create_lines
    !
    lsel,s,line,,lm-1
    cm,lcut,line
    !
    init_entity_num
    !
    lsel,s,line,,lm-(2*n_thrd+1),lm
    !
    ln_part_ln,lcut
    !
    init_entity_num
    !
    ldele,lcut,,,1
    !
    init_entity_num
    !
    *do,iij,1,4*n_thrd-2,2
        *if,iij,eq,1,then
            counter=0
            incrm=3
        *endif
        !
        counter=counter+1
        !
        lstr,km-(4*n_thrd-1)+iij,km-(4*n_thrd-1)+(iij+1)
        !
        *get,lm,line,,num,max
        !
        *if,mod(counter,2),eq,0,then
            lfillt,lm,lstart+(2*n_thrd+5)+incrm,.0010
            lfillt,lm,lstart+(2*n_thrd+5)+incrm+3,.0010
            incrm=incrm+6
        *endif
    *enddo
    !
    init_entity_num
    !
    lsel,selv,loc,y,0,0.985*(h_thrd/4)
    !
    *if,d_mjr,eq,0,then
        lsel,a,loc,y,1.015*((7/8)*h_thrd),h_thrd
    *else
        lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
    *endif
    !
    lsel,r,loc,x,0,n_thrd*p_thrd
    lsel,r,loc,z,0
    !
    ldele,all,,,1
    !
    init_entity_num
    !
    ksel,selv,loc,x,(h_thrd/4)/tan(thrd_ang*rconv)
    ksel,r,loc,y,h_thrd/4
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k1_thrd=km
    !
    init_entity_num
    !
    ksel,selv,loc,x,(n_thrd*p_thrd)-((h_thrd/4)/tan(thrd_ang*rconv))
    ksel,r,loc,y,h_thrd/4
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k2_thrd=km
    !
    init_entity_num
*endif
!
k,,kx(k1_thrd),-1.3*p_thrd,0
k,,kx(k2_thrd),-1.3*p_thrd,0
!
create_lines
!
lstr,km-1,k1_thrd
lstr,km,k2_thrd
!
init_entity_num
!
isolate_lines
!
al,all
!
init_entity_num
!
lplot
!
!----------------------------------------------------------------------
!
*endif      ! END external thread profile
!
!
!
!
*if,prof,eq,'i',then
!
!---------------------- Internal Thread Profile -----------------------
!
*if,stndrd,eq,'j',then
    *do,iii,0,2*n_thrd,1
        *if,mod(iii,2),eq,0,then
            k,,iii*(p_thrd/2),0,0
        *elseif,mod(iii,2),eq,1,then
            k,,iii*(p_thrd/2),h_thrd,0
            !
            init_entity_num
            !
            k_tip=km
        *endif
        !
        init_entity_num
        !
        *if,iii,gt,0,then
            *if,mod(iii,2),eq,0,then
            lstr,km,k_tip
            *elseif,mod(iii,2),eq,1,then
            lstr,km-1,k_tip
            *endif
        *endif
        !
        init_entity_num
        !
        *if,iii,ge,3,then
           *if,mod(iii,2),eq,1,then
            lfillt,lm-1,lm,r_thrd
           *endif
        *endif
        !
        init_entity_num
    *enddo
    !
    r_width=p_thrd/8
    root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
    r2edge=0.649519*p_thrd
    h_thrd2=root_h+r2edge
    !
    k,,0,h_thrd2,0
    k,,kx(km),h_thrd2,0
    !
    create_lines
    !
    lsel,selv,loc,x,(0.5*p_thrd),(n_thrd-0.5)*p_thrd
    lsel,r,loc,y,(r_thrd/cos(thrd_ang*rconv))*(sin(thrd_ang*rconv))**2,h_thrd
    lsel,r,loc,z,0
    lsel,a,line,,lm-1
    lsel,a,line,,lm-(2*n_thrd+n_thrd-1)
    !
    ln_part_ln,lm
    !
    init_entity_num
    !
    *do,iij,1,2*n_thrd-1,2
        lstr,km-(2*n_thrd-iij),km-(2*n_thrd-iij-1)
    *enddo
    !
    init_entity_num
    !
    *if,d_mjr,eq,0,then
        lsel,selv,loc,y,1.015*((7/8)*h_thrd),h_thrd
    *else
        lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
    *endif
    !
    lsel,r,loc,x,0,n_thrd*p_thrd
    lsel,r,loc,z,0
    !
    ldele,all,,,1
    !
    init_entity_num
    !
    ksel,selv,loc,x,0
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k1_thrd=km
    !
    init_entity_num
    !
    ksel,selv,loc,x,n_thrd*p_thrd
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k2_thrd=km
    !
    init_entity_num
    !
*elseif,stndrd,eq,'un',then
    !
    *do,ijk,0,2*n_thrd,1
        *if,mod(ijk,2),eq,0,then
            k,,ijk*(p_thrd/2),0,0
        *elseif,mod(ijk,2),eq,1,then
            k,,ijk*(p_thrd/2),h_thrd,0
        *endif
        !
        init_entity_num
        !
        *if,ijk,gt,0,then
            lstr,km-1,km
        *endif
        !
        init_entity_num
    *enddo
    !
    k,,0,(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
    k,,kx(km),(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
    !
    create_lines
    !
    *if,d_mjr,eq,0,then
         k,,0,h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
         k,,kx(km),h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv)),0
    *else
        r_width=p_thrd/4
        root_h=(r_width/2)/tan((thrd_ang/2)*rconv)
        r2edge=(d_mjr-d_min)/2
        h_thrd2=root_h+r2edge
        !
        k,,0,h_thrd2,0
        k,,kx(km),h_thrd2,0
    *endif
    !
    create_lines
    !
    lsel,s,line,,lm-1,lm
    cm,lcut,line
    !
    init_entity_num
    !
    lsel,s,line,,lm-(2*n_thrd+1),lm
    !
    ln_part_ln,lcut
    !
    init_entity_num
    !
    ldele,lcut,,,1
    !
    init_entity_num
    !
    *do,iij,1,4*n_thrd-2,2
        *if,iij,eq,1,then
            counter=0
            incrm=3
        *endif
        !
        counter=counter+1
        !
        lstr,km-(4*n_thrd-1)+iij,km-(4*n_thrd-1)+(iij+1)
        !
        *get,lm,line,,num,max
        !
        *if,mod(counter,2),eq,0,then
            lfillt,lm,lstart+(2*n_thrd+5)+incrm,.0050
            lfillt,lm,lstart+(2*n_thrd+5)+incrm+3,.0050
            incrm=incrm+6
        *endif
    *enddo
    !
    init_entity_num
    !
    lsel,selv,loc,y,0,0.985*(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv))
    !
    *if,d_mjr,eq,0,then
        lsel,a,loc,y,1.015*(h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv))),h_thrd
    *else
        lsel,selv,loc,y,1.015*(h_thrd2),h_thrd
    *endif
    !
    lsel,r,loc,x,0,n_thrd*p_thrd
    lsel,r,loc,z,0
    !
    ldele,all,,,1
    !
    init_entity_num
    !
    ksel,selv,loc,x,(h_thrd/4)/tan(thrd_ang*rconv)
    ksel,r,loc,y,h_thrd/4
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k1_thrd=km
    !
    init_entity_num
    !
    ksel,selv,loc,x,(n_thrd*p_thrd)-((h_thrd/4)/tan(thrd_ang*rconv))
    ksel,r,loc,y,h_thrd/4
    ksel,r,loc,z,0
    !
    get_max_entity
    !
    k2_thrd=km
    !
    init_entity_num
*endif
!
k,,kx(k1_thrd),-1.3*p_thrd,0
k,,kx(k2_thrd),-1.3*p_thrd,0
!
create_lines
!
lstr,km-1,k1_thrd
lstr,km,k2_thrd
!
init_entity_num
!
isolate_lines
!
al,all
!
init_entity_num
!
lplot
!
!----------------------------------------------------------------------
!
*endif      ! END external thread profile
!
!
!
!------------------------- Transfer Area C.S. -------------------------
!
*get,thrd_cs,active,,csys
!
csn=csn+1
!
*if,prof,eq,'x',then
    !
    min_d_cs=csn
    clocal,min_d_cs,0,-kx(k1_thrd),-ky(k1_thrd),0,0,0,0
    csys,thrd_cs
    atran,min_d_cs,am,,,,0,1
    !
    nscp=n_thrd     ! # of surface contact points
    y_nd_d=h_thrd       ! nodal distances in y direction
    !
*elseif,prof,eq,'i',then
    !
    mjr_d_cs=csn
    clocal,mjr_d_cs,0,-kx(k1_thrd),-ky(k1_thrd),0,0,0,0
    csys,thrd_cs
    atran,mjr_d_cs,am,,,,0,1
*endif
!
!----------------------------------------------------------------------
!
init_entity_num
!
lplot
!
*if,thrd_ass,eq,0,then
    *set,iii,
    *set,iij,
    *set,ijk,
    *set,k_tip,
    *set,n_thrd,
    *set,n_inch,
    *set,r_thrd,
    *set,p_thrd,
    *set,h_thrd,
    *set,h_thrd2,
    *set,k1_thrd,
    *set,k2_thrd,
    *set,thrd_ang,
    *set,root_h,
    *set,r_width,
    *set,r2edge,
    *set,prof,
    *set,stndrd,
    *set,d_mjr,
    *set,d_min,
    *set,zzzz,
    *set,counter,
    *set,incrm,
    *set,lstart,
    *set,thrd_ln,
    *set,y_nd_d,
*endif

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

:skip


w:\ansys\mac\tools\spring.mac.html

!
!   This macro creates a cylindrical slotted mechanical
!   spring based on the parameters calculated by strength
!   of material formula iterations. By capitalizing on
!   symmetry, a quarter coil segment is created and mirrored
!   several times to create the entire spring.
!
!   TITLE:  spring.mac (PART_LIB)
!
*get,prkey_,active,0,prkey
/nopr

mod_assemb_prep
!
/units,bin
!
!*************************** Paramter Values **************************
!
pi=3.1415927    ! constants
rconv=pi/180
!
!---------- Specify model c.s. center location -----------
!
xc=1.00     ! cartesian x coordinate
yc=2.00     ! cartesian y coordinate
zc=3.00     ! cartesian z coordinate
!
!---------- Specify model c.s. orientation ---------------
!
rotxy=0     ! 1st rotation angle (+x to +y) default 0
rotyz=0     ! 2nd rotation angle (+y to +z) default 0
rotzx=0     ! 3rd rotation angle (+z to +x) default 0
!
!---------- Specify model parameters ---------------------
!
rout=2.10/2 ! outer radius of coil
rin=.60     ! inner radius of coil
t=0.12      ! coil thickness
tgap=0.064  ! thickness of gap between coils
rfil=0.5*tgap   ! fillet radius
d0=0.27/2   ! 1/2 width of coil connectors
!
!**********************************************************************
!
!
!<<<<<<<<<<<<<<<<<<<<<< Model Coordinate System >>>>>>>>>>>>>>>>>>>>>>>>
!
csn=11          ! initialize local c.s. numbers
ctmcs=csn       ! cartesian model c.s. number
csn=csn+1
cylmcs=csn      ! cylindrical model c.s. number
!
csys,0
clocal,ctmcs,0,xc,yc,zc,rotxy,rotyz,rotzx
!
csys,0
clocal,cylmcs,1,xc,yc,zc,rotxy,rotyz,rotzx
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
csys,cylmcs !------------- create initial volume ---------------
!
k,,rin,0
k,,rout,0
k,,rout,90
k,,rin,90
!
*get,km,kp,,num,max
!
lstr,km-3,km-2
l,km-2,km-1
lstr,km-1,km
l,km,km-3
!
a,km-3,km-2,km-1,km
!
*get,am,area,,num,max
!
voffst,am,(tgap+t)
!
!----------------------- create 1st planar cut into volume -----------
!
csys,ctmcs
!
k,,1.1*rout,d0+rfil,-(0.5*tgap)
k,,1.1*rout,1.1*rout,-(0.5*tgap)
k,,1.1*rout,1.1*rout,(0.5*tgap)
k,,1.1*rout,d0+rfil,(0.5*tgap)
k,,1.1*rout,d0,0
!
*get,km,kp,,num,max
!
lstr,km-4,km-3
lstr,km-3,km-2
lstr,km-2,km-1
!
csn=csn+1
clocal,csn,1,1.1*rout,d0+rfil,0,0,0,90
!
l,km-1,km
l,km,km-4
!
a,km,km-1,km-2,km-3,km-4
!
*get,am,area,,num,max
!
voffst,am,1.5*rout
!
*get,vm,volu,,num,max
!
vsbv,vm-1,vm,,delete,delete
!
numcmp,all
!
!----------------------- create 2nd planar cut into volume -----------
!
csys,ctmcs
!
k,,d0+rfil,1.1*rout,(t+1.5*tgap)
k,,1.1*rout,1.1*rout,(t+1.5*tgap)
k,,1.1*rout,1.1*rout,(t+0.5*tgap)
k,,d0+rfil,1.1*rout,(t+0.5*tgap)
k,,d0,1.1*rout,(t+tgap)
!
*get,km,kp,,num,max
!
lstr,km-4,km-3
lstr,km-3,km-2
lstr,km-2,km-1
!
csn=csn+1
clocal,csn,1,(d0+rfil),1.1*rout,(t+tgap),-90,0,-90
!
l,km-1,km
l,km,km-4
!
a,km,km-1,km-2,km-3,km-4
!
*get,am,area,,num,max
!
voffst,am,1.5*rout
!
*get,vm,volu,,num,max
!
vsbv,vm-1,vm,,delete,delete
!
numcmp,all
!
/VIEW, 1 ,1,1,1
/auto,1
!
lplot
!
!---------------------- cut volumes for mapped meshing ---------------
!
!
!<<<<<<<<<<<<<<<<<<<<<<< 1st cut >>>>>>>>>>>>>>>>>>>>>>>>
!
csys,ctmcs
!
k,,d0+rfil,0.8*rin,-(0.5*tgap)
k,,d0+rfil,1.1*rout,-(0.5*tgap)
!
*get,km,kp,,num,max
*get,vm,volu,,num,max
!
phi1=asin((d0+rfil)/rout)
phi2=asin((d0+rfil)/rin)
!
a,km-1,km,kp(d0+rfil,rout*cos(phi1),(t+tgap)),kp(d0+rfil,rin*cos(phi2),(t+tgap))
!
*get,am,area,,num,max
!
vsba,vm,am,,delete,delete
!
numcmp,all
!
!<<<<<<<<<<<<<<<<<<<<<<< 2nd cut >>>>>>>>>>>>>>>>>>>>>>>>
!
csys,ctmcs
!
k,,0.8*rin,d0+rfil,(t+tgap)
k,,1.1*rout,d0+rfil,(t+tgap)
!
*get,km,kp,,num,max
!
csys,cylmcs
vsel,s,loc,y,0,(90-(phi1/rconv))
*get,vm,volu,,num,max
!
csys,ctmcs
a,km-1,km,kp(rout*cos(phi1),d0+rfil,rfil),kp(rin*cos(phi2),d0+rfil,rfil)
!
*get,am,area,,num,max
!
vsba,vm,am,,delete,delete
!
allsel,all
numcmp,all
!
!*go,:flip
csys,ctmcs
vsymm,x,all
vsymm,y,all
vsymm,z,all
!
csn=csn+1
clocal,csn,0,0,0,(t+tgap),0,0,0
vsymm,z,all
!
csn=csn+1
clocal,csn,0,0,0,(t+tgap),0,0,0
vsymm,z,all
!
!:flip
vplot
!
numcmp,all
assemble=1
!name='spring'
!arry_nam='sprng'
finalize_model_data


w:\ansys\mac\tools\sqr_sect_press_vessel.mac.html

!   TITLE:  sqr_sect_press_vessel.mac (PART_LIB)
!
mod_assemb_prep
!
x=1.125/2
y=1.125/2
t=.025
pload=500
!
k,,x,0,0
k,,x,y,0
k,,0,y,0
k,,0,y-t,0
k,,x-t,y-t,0
k,,x-t,0
!
create_area
!
et,1,plane82
!
UIMP,1,EX, , ,29.0E6,             ! Material:  304L / 316L CRES
UIMP,1,DENS, , ,0.286/g_bin,
UIMP,1,NUXY, , ,0.27,
!
msh_area,,,1,.005,.005
!
lsel,s,line,,1,2,1
!
sfl,all,pres,pload
!
nsel,s,loc,x,0
d,all,ux
!
nsel,s,loc,y,0
d,all,uy
!
init_entity_num
!
lplot
!
/solu
eqslv,iter,5,3
solve
!
/POST1
/EFACE,1
AVPRIN,0,0,
!
PLNSOL,S,EQV,0,1


w:\ansys\mac\tools\test_case.mac.html

!   TITLE:  test_case.mac (PART_LIB)
!
mod_assemb_prep
!
x=1.125/2
y=1.125/2
t=.025
pload=500
!
k,,x,0,0
k,,x,y,0
k,,0,y,0
k,,0,y-t,0
k,,x-t,y-t,0
k,,x-t,0
!
create_area
!
et,1,plane82
!
UIMP,1,EX, , ,29.0E6,             ! Material:  304L / 316L CRES
UIMP,1,DENS, , ,0.286/g_bin,
UIMP,1,NUXY, , ,0.27,
!
msh_area,,,1,.005,.005
!
arsym,x,all
!
nummrg,all
!
init_entity_num
!
lsel,s,line,,1,2,1
lsel,a,line,,7,8,1
!
sfl,all,pres,pload
!
nsel,s,loc,y,0
d,all,uy
!
nsel,s,loc,x,x
nsel,r,loc,y,0
d,all,all
!
init_entity_num
!
lplot
!
/solu
eqslv,iter,5,3
solve
!
/POST1
/EFACE,1
AVPRIN,0,0,
!
PLNSOL,S,EQV,0,1


w:\ansys\mac\tools\thread_assemble.mac.html

!   TITLE:  thread_assemble.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/28/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro assembles a set of internal and external thread
!   profiles together in a 2D axisymmetric model. It assembles them
!   surface to surface to determine stress and deflection under axial
!   loading conditions, showing the stress and D.O.F profiles through
!   an axisymmetric planar cut.
!
!       axis_cs = thread axis coordinate systems.  For axisymmetric
!             analysis, this will be the golbal cartesian c.s.,
!             0 (or blank).
!
!       y_ext = the y coordinate position of the external thread
!
!       d_min_i = the minor diameter of the internal thread
!
!       d_min_x = the minor diameter of the external thread
!
!       n_thrd_x = # of threads in the externally threaded member.
!              If the thread length is known or desired, leave
!              blank and specify the thread length, THRD_LNX.
!
!       thrd_lnx = threaded length of external thread.
!              If N_THRD_X is specified, this argument will be
!              ignored.
!
!       n_thrd_i = # of threads in the internally threaded member
!              If the thread length is known, or desired, leave
!              blank and specify the thread length, THRD_LNI.
!
!       thrd_lni = threaded length of internal thread.
!              If N_THRD_I is specified, this argument will be
!              ignored.
!
!       n_inch = # of threads per inch of the internal and threads.
!
!       stndrd = thread standard.
!
!           'j' = UNJ thread standard, which specifies a root
!                 radius, R_THRD.
!
!           'un' (or blank) = UN thread profile, flat surface
!                             at thread root.
!
!       thrd_clr = thread clearance between internal and external
!              thread minor diameters. This specification will
!              allow analysis of the thread stresses for dif-
!              ferent clearances.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                    (1)     (2)     (3)      (4)      (5)       (6)
! THREAD_ASSEMBLE, axis_cs, y_ext, d_min_i, d_min_x, n_thrd_x, thrd_lnx,
!
!                  n_thrd_i, thrd_lni, n_inch, stndrd, thrd_clr
!                    (7)       (8)      (9)     (10)     (11)
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

thrd_ass=1
!
!
axis_cs=arg1
y_ext=arg2
d_min_i=arg3
d_min_x=arg4
n_thrd_x=arg5
thrd_lnx=arg6
n_thrd_i=arg7
thrd_lni=arg8
n_inch=arg9
stndrd=ar10
thrd_clr=ar11
!
!
csys,axis_cs
!
csn=csn+1
!
*if,d_min_i,gt,0,then
    clocal,csn,0,d_min_i/2,y_ext,0,-90,0,0
*elseif,d_min_i,lt,0,then
    clocal,csn,0,d_min_i/2,y_ext,0,-90,-180,0
*endif
!
!
screw_thread_2d,'x',n_thrd_x,thrd_lnx,n_inch,stndrd,,
!
!
!----------------------- Calculate Gap Parameters ------------------------
!
xxx=h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv))
!
yyy=(0.250*p_thrd)/(2*tan((thrd_ang/2)*rconv))
!
thrd_h_x=(7/8)*h_thrd-h_thrd/4      ! external thread height
!
thrd_h_i=xxx-yyy            ! internal thread height
!
gap=thrd_h_x+thrd_h_i+5*h_thrd      ! Gap distance between external thread
!                   ! minor diameter and internal thread
!                   ! major diameter.
!-------------------------------------------------------------------------
!
csys,axis_cs
!
csn=csn+1
!
*if,d_min_i,gt,0,then
    clocal,csn,0,gap+d_min_i/2,y_ext,0,-90,-180,0
*elseif,d_min_i,lt,0,then
    clocal,csn,0,gap+d_min_i/2,y_ext,0,-90,0,0
*endif
!
!
screw_thread_2d,'i',n_thrd_i,thrd_lni,n_inch,stndrd,,
!
!
xxx=thrd_h_x*tan((thrd_ang/2)*rconv)
!
zzz=xxx*(thrd_clr/thrd_h_x)
!
csys,mjr_d_cs
!
csn=csn+1
thrdacs=csn
clocal,thrdacs,0,-((xxx-zzz)+2*(.041667*p_thrd)),(gap-thrd_clr-thrd_h_i),0,0,0,0
!
csys,mjr_d_cs
atran,thrdacs,am,,,,0,1
!
init_entity_num
!
!
*set,thrd_ass,
*set,iii,
*set,iij,
*set,ijk,
*set,k_tip,
*set,n_thrd,
*set,n_inch,
*set,r_thrd,
*set,k1_thrd,
*set,k2_thrd,
*set,root_h,
*set,r_width,
*set,r2edge,
*set,prof,
*set,stndrd,
*set,d_mjr,
*set,d_min,
*set,zzzz,
*set,counter,
*set,incrm,
*set,lstart,
*set,xxx,
*set,yyy,
*set,zzz,
*set,gap,
*set,n_thrd_i,
*set,n_thrd_x,


w:\ansys\mac\tools\thread_mesh.mac.html

!   TITLE:  thread_mesh.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  06/27/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro unites a set of internal and external thread profile
!   entities in a 2D axisymmetric model. It then meshes the assembled
!   thread profile areas
!
!
!           thrdax = external thread area
!
!           mtrlx = material of the external thread
!
!           thrdai = internal thread area
!
!           mtrli = material of the internal thread
!
!           elml = minimum element edge length in thread areas
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! THREAD_MESH, thrdax, mtrlx, thrdai, mtrli, elml
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

thrdax=arg1
mtrlx=arg2
thrdai=arg3
mtrli=arg4
elml=arg5
!
!
asel,s,area,,thrdax
lsla,s
cm,lnsx,line        ! create line component group "lines of 'x' thread'
!
!
asel,s,area,,thrdai
lsla,s
cm,lnsi,line        ! create line component group "lines of 'i' thread'
!
!
init_entity_num
!
adele,thrdax
adele,thrdai
!
init_entity_num
!
*do,ijj,0,nscp-1,1
    init_entity_num
    !
    csys,ndselcs
       lsel,selv,loc,y,-((ijj*y_nd_d)+0.0005),-((ijj*y_nd_d)-0.0005)
    csys,min_d_cs
       lsel,r,loc,y,thrd_clr,y_nd_d
       !
    get_max_entity
    !
    *if,lm,ne,0,then
        lovlap,all
    *endif
*enddo
!
init_entity_num
!
csys,min_d_cs           ! recreate external thread area
!
lsel,selv,loc,y,-1.5*p_thrd,(7/8)*h_thrd
lsel,r,loc,x,0,1.03*thrd_ln
lsel,u,line,,lnsi
!
al,all
!
init_entity_num
!
thrdax=am
!
!
csys,mjr_d_cs+1         ! recreate internal thread area
!
lsel,selv,loc,y,-1.5*p_thrd,h_thrd-(0.041667*p_thrd)/(2*tan((thrd_ang/2)*rconv))
lsel,u,line,,lnsx
!
al,all
!
init_entity_num
!
thrdai=am
!
!
asel,s,area,,thrdax
msh_algorithm,1,1,0,,,,,,elml,elml+1.2*elml,mtrlx,,,,
!
asel,s,area,,thrdai
msh_algorithm,1,1,0,,,,,,elml,elml+1.2*elml,mtrli,,,,
!
init_entity_num
!
*set,nscp,
*set,elml,
*set,thrd_clr,


w:\ansys\mac\tools\entity_number_buttons.mac.html

!   TITLE:  entity_number_buttons.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A               01/13/2001      J. Rinaldi
!
!               Changed the abbreviation button name from CANCEL to DONE.
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates the entity number toolbar buttons.
!
!---------------------------------------------------------------------------
*get,prkey_,active,0,prkey
/nopr

*abbr,___1___,entity_number_buttons
!
*abbr,KEYPOINT,numbers_toggle,1
*abbr,LINE,numbers_toggle,2
*abbr,AREA,numbers_toggle,3
*abbr,VOLUME,numbers_toggle,4
!
*abbr,___2___,entity_number_buttons
!
*abbr,NODE,numbers_toggle,5
*abbr,ELEMENT,numbers_toggle,6
*abbr,MAT_NUM,numbers_toggle,7
*abbr,MAT_COLR,numbers_toggle,8
!
!
*abbr,___3___,entity_number_buttons
!
*abbr,CS_NUMS,numbers_toggle,9
!
*abbr,___4___,entity_number_buttons
!
*abbr,NUMS_OFF,numbers_toggle,10
!
*abbr,___5___,entity_number_buttons
!
*abbr,DONE,toolbar                      ! Revision A


w:\ansys\mac\tools\entity_numbers.mac.html

!   TITLE:  entity_numbers.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro calls the entity number abbreviation toolbar.
!
!
abbres,new,entity_number_buttons,mac


w:\ansys\mac\tools\measure_buttons.mac.html

!   TITLE:  measure_buttons.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates the measurement toolbar buttons.
!
*get,prkey_,active,0,prkey
/nopr

*abbr,MX_E_DIM,tv_max_ent_dim
*abbr,KP_DIST,ct_dist_calcs
*abbr,ND_DIST,nd_dist_calcs
*abbr,L_K_DIST,ln_dist_pt_calc
*abbr,L_L_DIST,tv_ln_dist_ln
*abbr,A_K_DIST,ar_dist_pt_calc
!
*abbr,PR_COORD,tv_profile_coords
*abbr,KP_COORD,cs_dist_pt_calc
*abbr,K_L_PATH,tv_kp_path_ln
*abbr,CG_VOL,tv_mark_cg
!
*abbr,DONE,toolbar


w:\ansys\mac\tools\measure_mod.mac.html

!   TITLE:  measure_mod.mac  (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro calls the measurement functions on the toolbar.
!
!
/prep7
!
abbres,new,measure_buttons,mac


w:\ansys\mac\tools\numbers_toggle.mac.html

!   TITLE:  numbers_toggle.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A               01/13/2001      J. Rinaldi
!
!               Added the capability to do multiple number toggles before
!               exiting to main toolbar button layout.
!---------------------------------------------------------------------------
!       Rev B               04/04/2001      J. Rinaldi
!
!               Added the capability to toggle material numbers and/or
!               colors.
!---------------------------------------------------------------------------
!
!   This sub-macro toggles entity numbers on/off. Called by
!   ENTITY_NUMBER_BUTTONS.
!
!
*get,prkey_,active,0,prkey
/nopr

*get,_usestat,parm,_usecntr,type
!
*if,_usestat,eq,-1,then
    _usecntr=1
    kp_tog_=0
    ln_tog_=0
    ar_tog_=0
    vl_tog_=0
    nd_tog_=0
    elm_tog_=0
    cs_tog_=0
    matntog_=0
    matctog_=0
    *set,_usestat,
*endif
!
*if,arg1,eq,1,then
    *if,kp_tog_,eq,0,then
        kp_tog_=1
    *else
        kp_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,KP,kp_tog_
    !
    *if,kp_tog_,eq,1,then
        lplot
    *else
        /replot
    *endif
*elseif,arg1,eq,2,then
    *if,ln_tog_,eq,0,then
        ln_tog_=1
    *else
        ln_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,LINE,ln_tog_
    !
    *if,ln_tog_,eq,1,then
        lplot
    *else
        /replot
    *endif
*elseif,arg1,eq,3,then
    *if,ar_tog_,eq,0,then
        ar_tog_=1
    *else
        ar_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,AREA,ar_tog_
    !
    *if,ar_tog_,eq,1,then
        aplot
    *else
        /replot
    *endif
*elseif,arg1,eq,4,then
    *if,vl_tog_,eq,0,then
        vl_tog_=1
    *else
        vl_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,VOLU,vl_tog_
    !
    *if,vl_tog_,eq,1,then
        vplot
    *else
        /replot
    *endif
*elseif,arg1,eq,5,then
    *if,nd_tog_,eq,0,then
        nd_tog_=1
    *else
        nd_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,NODE,nd_tog_
    !
    *if,nd_tog_,eq,1,then
        nplot
    *else
        /replot
    *endif
*elseif,arg1,eq,6,then
    *if,elm_tog_,eq,0,then
        elm_tog_=1
    *else
        elm_tog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,ELEM,elm_tog_
    !
    *if,elm_tog_,eq,1,then
        eplot
    *else
        /replot
    *endif
*elseif,arg1,eq,7,then              ! added in Revision B
    *if,matntog_,eq,0,then
        matntog_=1
    *else
        matntog_=0
    *endif
    !
    /NUMBER,0
    /PNUM,MAT,matntog_
    !
    *if,matntog_,eq,1,then
        eplot
    *else
        /replot
    *endif
*elseif,arg1,eq,8,then              ! added in Revision B
    *if,matctog_,eq,0,then
        matctog_=1
    *else
        matctog_=0
    *endif
    !
    /NUMBER,1
    /PNUM,MAT,matctog_
    !
    *if,matctog_,eq,1,then
        eplot
    *else
        /replot
    *endif
*elseif,arg1,eq,9,then
    *if,cs_tog_,eq,0,then
        cs_tog_=1
    *else
        cs_tog_=0
    *endif
    !
    /PSYMB,CS,cs_tog_
    !
    *if,cs_tog_,eq,1,then
        lplot
    *else
        /replot
    *endif
*elseif,arg1,eq,10,then
    /PNUM,KP,0
    /PNUM,LINE,0
    /PNUM,AREA,0
    /PNUM,VOLU,0
    /PNUM,NODE,0
    /PNUM,ELEM,0
    /PSYMB,CS,0
    /PNUM,MAT,0
    *set,_usecntr,
    /replot
    abbres,new,tools,mac
*endif
!
*set,_usestat,
!
*if,arg1,ne,10,then             ! added in Revision A
    entity_number_buttons


w:\ansys\mac\tools\solid_model_buttons.mac.html

!   TITLE:  solid_model_buttons.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates the solid model toolbar buttons.
!
!
*get,prkey_,active,0,prkey
/nopr

*abbr,___1___,solid_model_buttons
!
*abbr,CREAT_LN,tv_creat_lines
*abbr,PAR_LNS,tv_parallel_lines
*abbr,PRFL_LNS,tv_profile_lines
*abbr,CREAT_AR,tv_create_area
*abbr,CREAT_VL,tv_create_volume
!
*abbr,___2___,solid_model_buttons
!
*abbr,EXTR_AR,tv_extrude_aset
*abbr,REV_ASET,tv_revolve_aset
!
*abbr,___3___,solid_model_buttons
!
*abbr,CIRC_BOR,tv_cir_bore
*abbr,RECT_BOR,tv_rec_bore
*abbr,POCKET,tv_pocket_cut
*abbr,CT_NORMC,tv_norm_cut_pln_ct
!
*abbr,___4___,solid_model_buttons
!
*abbr,SM_MERGE,solid_mod_merge
!
*abbr,___5___,solid_model_buttons
!
*abbr,CANCEL,toolbar


w:\ansys\mac\tools\solid_model_tools.mac.html

!   TITLE:  solid_model_tools.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro calls the solid model abbreviation toolbar.
!
!
*get,prkey_,active,0,prkey
/nopr

abbres,new,solid_model_buttons,mac


w:\ansys\mac\tools\toolbar.mac.html

!   TITLE:  toolbar.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/12/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro displays a standard set of macro tools on the tool-bar.
!   (Calls tools.mac)
!
*get,prkey_,active,0,prkey
/nopr

abbres,new,tools,mac


w:\ansys\mac\tools\tools.mac.html

!   TITLE:  tools.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/12/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a standard set of macro tools to be stored on
!   the tool-bar. These tools aid in the execution of operations to check
!   the validity, effectiveness and correctness of line codes used in the
!   creation of macros; to expedite the creation of models executed in data-
!   base files, the execution of standard solutions, and to effectively
!   post-process analysis results.
!
!
*get,prkey_,active,0,prkey
/nopr

*abbr,___1___,toolbar
!
*abbr,SAVE_DB,SAVE
*abbr,CHNGE_DB,new_db
*abbr,RESUM_DB,clr_resume_db
*abbr,CLR_NEW,clear_start_new,vidtog_
*abbr,QUIT,clear_exit
!
*abbr,___2___,toolbar
!
*abbr,PREPROCR,/prep7
*abbr,MOD_A_PR,mod_assemb_prep
*abbr,IN_ENT_N,init_entity_num
*abbr,GET_MAX,get_max_entity
!
*abbr,___3___,toolbar
!
*abbr,ISO_AREA,tv_isolate_areas
*abbr,ISO_LINE,tv_isolate_lines
*abbr,PART_SEL,tv_select_part
*abbr,SM_SET,tv_featr_set_select
*abbr,ALLSELCT,allsel,all
!
*abbr,___4___,toolbar
!
*abbr,W_PLANE0,wpcsys,1,0
*abbr,VIDEO,tv_reverse_video
*abbr,IMAGE,tv_create_image
*abbr,KPLOT,kplot
*abbr,LPLOT,lplot
*abbr,APLOT,aplot
*abbr,VPLOT,vplot
!
*abbr,NPLOT,nplot
*abbr,EPLOT,eplot
*abbr,___5___,toolbar
!
*abbr,ENT_NUMS,entity_numbers
*abbr,DISP_MAX,entity_max
*abbr,DIFF_CLC,parm_calcs
!
*abbr,___6___,toolbar
!
*abbr,MEASURE,measure_mod
!
*abbr,___7___,toolbar
!
*abbr,SM_TOOLS,solid_model_tools


l:\ansys\mac\tools\fix_line_div.mac.html

! TITLE:  fix_line_div.mac  (SM_TOOL)
!
!---------------------------------------------------------------------------
!   Rev -     03/13/2002    J. Judd
!---------------------------------------------------------------------------
! OBJECTIVE:
!
!   1) After /GRESU, redisplays line divisions present before /GSAVE.
!   2) After mesh, allow to reset line divisions to match mesh divisions.
!
! COMMAND SYNTAX:
!
!   fixdivs,MshMatch
!
! ARGUMENTS:
!
!   MshMatch = determine whether meshed lines will have line divisions
!              set to match mesh as follows:
!     0 = false (default) lines will display per current NDNX attribute.
!     1 = true will reset line divisions to match mesh divisions.
!
! DESCRIPTION:
!
!   1) After /GRESU, redisplays line divisions.  In 5.6 and higher, /GRESU
!      unexplainable makes line divisions not display.
!   2) After mesh, allow to reset line divisions to match mesh divisions.
!      For example if line division set to 10 and mesh required 5 divisions
!      then line would still show 10 divisions unless you use this command.
!
! WARNING:
!
!  - Works only in Prep7

! EXAMPLES:
!
! TO BE DONE:
!
!-------------------------------------------------------------------------
*GET,AR67,ACTIVE,,PRKEY
/NOPR

!*GET,_z9,ACTIVE,,KEYWORD,,PREP7   !Rather have error than too many IF nests.
!*IF,_z9,EQ,0,THEN
!   *MSG,WARN
!   FIXDIVS only works in PREP7
!*ELSE
   *get,ar10,line,,count
   ar12=0
   *do,ar11,1,ar10
      ar12=lsnext(ar12)
      ar13=0  $ar14=0  $ar15=0  $ar16=0  !reset
      *get,ar13,line,ar12,attr,ndiv
      *get,ar14,line,ar12,attr,spac
      *get,ar15,line,ar12,attr,ndnx
      *get,ar16,line,ar12,attr,spnx
      *if,arg1,EQ,1,THEN
         *if,ar13,GT,0,then
            lesize,ar12,,,ar13,ar14
         *elseif,ar15,GT,0,then
            lesize,ar12,,,ar15,ar16
         *endif
      *else
         *if,ar15,GT,0,then     !if don't check this would default to kesize,
                                !esize or desize.
            lesize,ar12,,,ar15,ar16
         *endif
      *endif
   *enddo
!*ENDIF

*IF,AR67,EQ,1,THEN
  /GOPR
*ENDIF
/EOF


w:\ansys\mac\tools\purge_model.mac.html

!   TITLE:  purge_model.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      05/24/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro purges the model of any extraneous solid model entities
!   that are not apart of the models.
!
!
!   DESCRIPTION:
!
!   The existence of extraneous solid model entities may be the result of
!   boolean operations. This macro "cleans" these extraneous entities by
!   eliminating loose entities that are not apart of the final model.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

init_entity_num
!
*get,vcnt_,volu,,count
*get,acnt_,area,,count
!
*if,vcnt_,gt,0,then
    isolate_areas
    adele,all,,,1
    !
    init_entity_num
    !
    isolate_lines
    ldele,all,,,1
    !
    init_entity_num
    !
    isolate_kp
    kdele,all
*else
    *if,acnt_,gt,0,then
        isolate_lines
        ldele,all,,,1
        !
        init_entity_num
        !
        isolate_kp
        kdele,all
    *else
        isolate_kp
        kdele,all
    *endif
*endif
!
init_entity_num
!
lplot

*set,acnt_
*set,vcnt_


w:\ansys\mac\tools\solid_mod_merge.mac.html

!   TITLE:  solid_mod_merge.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  10/24/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro merges coincident solid model entities, and updates
!   the entity maximums. This macro uses the default tolerances, 0.0001.
!
!
*get,prkey_,active,0,prkey
/nopr

nummrg,kp
init_entity_num
/replot
abbres,new,tools,mac


w:\ansys\mac\tools\mod_assemb_prep.mac.html

!   TITLE:  mod_assemb_prep.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  03/22/2000    J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   03/27/2000      J. Rinaldi
!
!       The letter 'u' was added to the entity variable names
!       to distinguish the unselected set maximum entity number
!       values.  These values will be used in later boolean oper-
!       ations.
!---------------------------------------------------------------------------
!       Rev B   04/12/2000      J. Rinaldi
!
!       Add the line command:  abbres,new,tools,mac
!---------------------------------------------------------------------------
!       Rev C   05/09/2000      J. Rinaldi
!
!       Add the macro command:  constants
!
!       Initialize local c.s. numbers (removed from 'macro_template.mac')
!---------------------------------------------------------------------------
!       Rev D   06/05/2000      J. Rinaldi
!
!       Added the 'XX_prev' commands.  These commands retrieve
!       the previous maximum entity values and stores them for use
!       in the macro command CREATE_LINES.MAC.
!---------------------------------------------------------------------------
!       Rev E   06/14/2000      J. Rinaldi
!
!       Added the coordinate system position stack-up initializations
!---------------------------------------------------------------------------
!       Rev F   06/30/2000      J. Rinaldi
!
!       Added the entity pass-off initializations
!---------------------------------------------------------------------------
!       Rev G   07/22/2000      J. Rinaldi
!
!       Added code to track the number of models created in the database
!       when performing assembly work. Model numbers are tracked using
!       the parameter 'modl_num'. Also, created an array, ASSM_PAR, that
!       stores all MOD_ASSEMB_PREP initiated parameters.
!---------------------------------------------------------------------------
!       Rev H   09/22/2000      J. Judd, D. Edwards, J. Rinaldi
!
!       Added code to base font selection on operating system.  Combined
!       'km' definition with 'kmu' *Get routine.  Added comments.
!---------------------------------------------------------------------------
!       Rev I   01/29/2001      J. Rinaldi
!
!       Added decision to over-ride use of MOD_ASSEMB_PREP.
!---------------------------------------------------------------------------
!       Rev J   05/31/2001      J. Rinaldi
!
!       Added sub-assembly parameter
!---------------------------------------------------------------------------
!       Rev K   07/30/2001      J. Rinaldi
!
!       Added mesh flag parameter.
!---------------------------------------------------------------------------
!
!
!
!   This sub-macro prepares a model for possible assembly with other
!   components.  Its execution is based on the decision variable
!   'assemble', where:
!
!       assemble = 0    clears the database and builds an individual part.
!                       If assemble = 0 (or left blank) for all succesive
!                       parts of an assembly, it will have no effect on the
!                       parameter 'assemble'.
!
!       assemble = 1    records all existing solid and FEA model entities
!                       into groups and maintains them unselected. If used
!                       in a part after a sub-assembly is initialized, then
!                       this part will be the first separate part that is
!                       not part of the previous sub-assembly.
!
!       assemble = 2    Initiates the creation of a sub-assembly. Bypasses
!                       use of MOD_ASSEMB_PREP. This allows a series of part
!                       macros to be run in order, allowing them to act as
!                       one part macro; i.e., a sub-assembly.
!
!   It initializes and maintains entity maximum values, coordinate system
!   numbers, entity count parameters, model count, coordinate system position
!   stack-ups, previous maximum values and numerical constants. Also, it un-
!   selects the previously created model entities and initializes the toolbar
!   abbreviations.
!
!   The following instructions apply to the use of the arguments:
!
!           assemble = argument which determines whether an assembly is
!                      to be performed (create multiple models in the
!                      database):
!
!                           0 (or blank) = do not perform assembly
!
!                           1 = perform assembly
!
!                           2 = do not execute MOD_ASSEMB_PREP
!
!           frst_mdl = argument determines the first model to calculate
!                      coordinate system stack-ups from:
!
!                           0 (or blank) = does not initiate c.s. stack-up
!                                          calculations
!
!                           1 = initiate c.s. stack-up calculations
!
!           f_mesh = mesh flag parameter.  This parameter determines whether
!                    models are to be meshed, whether individually or in an
!                    assembly:
!
!                           0 (or blank) = do not mesh solid models
!
!                           1 = mesh solid models
!
!                    This parameter can only be set in the 1st model of an
!                    assembly.
!
!
!   ***** CONDITIONS FOR USE OF ARGUMENTS:
!
!       a.) Creation of the first model in the database (modl_num = 1):
!
!           1.) If ASSEMBLE = 0 (or blank), then 'frst_mdl' is irrelevant,
!               since there will be no other models created to measure
!               stack-ups to.
!
!           2.) If ASSEMBLE = 1, then frst_mdl = 1 always, which is auto-
!               matically set by the algorithm.  Therefore, frst_mdl is left
!               blank.
!
!           3.) If ASSEMBLE = 2, the algorithm will skip execution of
!               MOD_ASSEMB_PREP.  This will allow the building of that current
!               macro without unselecting the previous model entities.  This
!               is essentially running all part macros (with ASSEMBLE = 2) as
!               one continuous macro; i.e., as if they were all in the same
!               part macro.  The only difference is that FINALIZE_MODEL_DATA
!               is executed, thereby storing/clearing the parameters.  Therefore,
!               the parameter files will still need to use PARAMETER_VALUE
!               where necessary.
!
!   `       When the first model in the database is created, only specify
!           'assemble', and leave 'frst_mdl' blank. In either case, 1 or 2,
!           frst_mdl = 1 for all first models in the database. Therefore,
!           coordinate system stack-up calculations are always initiated from
!           the first model in the database.
!
!       b.) Creation of successive models in the database (modl_num = 2 or more):
!
!           If modl_num = 2 or more, then 'assemble' is already set to 1,
!           and need not be specified in any remaining models. Therefore,
!           'assemble' is left blank in all models after the first.
!
!           1.) If FRST_MDL = 0 (or blank), then the algorithm will not
!               initiate stack-up calculations from this model. The ongoing
!               stack-up calculations initiated frorm the first model in the
!               database (modl_num = 1) will be continued without interuption.
!
!           2.) If FRST_MDL = 1, then the algorithm will initiate stack-up
!               calculations from this model onward, until 'frst_mdl' is
!               initiated again.
!
!   In summary, if you are creating a stand-alone model (not an assembly),
!   then simply call this macro with no arguments:
!
!                   EXAMPLE:    mod_assemb_prep
!
!   If you are performing an assembly, then the first model macro calling
!   this sub-macro must have a 1 in the first argument (assemble) of this
!   macro call, with no argument for 'frst_mdl':
!
!                   EXAMPLE:    mod_assemb_prep,1
!
!   For any successive model in an assembly (modl_num = 2 or more), and no
!   stack-up calculations from any or all of these particular models, simply
!   use this macro with no arguments:
!
!                   EXAMPLE:    mod_assemb_prep
!
!   For any successive model in an assembly (modl_num = 2 or more), and it
!   is desired to perform stack-up calculations from any of these
!   particular models, then simply place a 1 in the second argument only,
!   with no argument for 'assemble':
!
!                   EXAMPLE:    mod_assemb_prep,,1
!
!   Lastly, when ASSEMBLE = 2, then this part is the first part of a sub-assembly.
!   All successive parts with the first argument left blank will be part of that
!   sub-assembly.  The first part that is not part of this sub-assembly must have
!   a 1 in the first argument.
!
!           EXAMPLE:    mod_assemb_prep,2   <--- 1st part of sub-assembly
!
!                       mod_assemb_prep     <--- 2nd part of sub-assembly
!
!                       mod_assemb_prep     <--- 3rd part of sub-assembly
!                              .                            .
!                              .                            .
!                              .                            .
!                       mod_assemb_prep     <--- nth part of sub-assembly
!
!                       mod_assemb_prep,1   <--- 1st part of next assembly
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MOD_ASSEMB_PREP, assemble, frst_mdl
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
*if,subassm_,eq,1,then
    *if,arg1,eq,1,then
        subassm_=0
    *elseif,arg1,eq,2,then
        subassm_=0
    *endif
*endif
!
*if,subassm_,ne,1,then          ! If assemble = 2, then, do not perform
    !                           ! MOD_ASSEMB_PREP on this model.  (Rev I)
    !
    FINISH
    !
    *if,assemble,eq,0,then
        clear_start_new,vidtog_
        selv='s'                ! selection type variable
    *else
        selv='r'
    *endif
    !
    /prep7                      ! activate preprocessor mode
*endif
!
*if,modl_num,eq,0,then      ! track # of models created in DB assembly (Rev G)
    modl_num=1
    f_mesh_=arg3            ! mesh flag parameter (Rev K)
    !
    *if,arg1,eq,1,then
        assemble=1
    *elseif,arg1,eq,2,then
        assemble=1
    *else
        assemble=0
    *endif
    !
    frst_mdl=modl_num
    !
    *dim,model,char,modl_num
    *dim,mdlbuff,char,modl_num+1
    !
    *dim,par_file,char,modl_num
    *dim,parfbuff,char,modl_num+1
    !
    *dim,parfmxi,array,modl_num
    *dim,pfmxibuf,array,modl_num+1
*else
    frst_mdl=arg2
    modl_num=modl_num+1
*endif
!
*if,modl_num,eq,1,then          ! store previous entity maximums (Rev D)
    km_prev=0
    lm_prev=0
    am_prev=0
    vm_prev=0
    em_prev=0
    nm_prev=0
*else
    km_prev=km
    lm_prev=lm
    am_prev=am
    vm_prev=vm
    em_prev=em
    nm_prev=nm
*endif
!
*if,assemble,eq,1,then          ! coordinate system position stack-up (Rev E)
    *if,frst_mdl,eq,1,then
        xstack=0
        ystack=0
        zstack=0
    *endif
*endif
!
!
*if,subassm_,ne,1,then          ! If assemble = 2, then, do not perform
    !                           ! MOD_ASSEMB_PREP on this model.  (Rev I)
    !
    map_run_=1                  ! mod_assemb_prep IS RUN
    !
    allsel,all
    !
    !
    *get,kmu,kp,,num,max    ! initialize entity numbers (Rev A)
    km=kmu                  ! store current maximum entity numbers
    numstr,kp,kmu           ! initialize entity numbers from current max values
    !
    *get,lmu,line,,num,max
    lm=lmu
    numstr,line,lmu
    !
    *get,amu,area,,num,max
    am=amu
    numstr,area,amu
    !
    *get,vmu,volu,,num,max
    vm=vmu
    numstr,volu,vmu
    !
    *get,emu,elem,,num,max
    em=emu
    numstr,elem,emu
    !
    *get,nmu,node,,num,max
    nm=nmu
    numstr,node,nmu
    !
    !
    *get,kp_pssof,kp,,count     ! entity count #'s to pass-off to INIT_ENTITY_NUM
    *get,ln_pssof,line,,count   ! (Rev F)
    *get,ar_pssof,area,,count
    *get,vl_pssof,volu,,count
    *get,el_pssof,elem,,count
    *get,nd_pssof,node,,count
    !
    !
    *if,kp_pssof,gt,0,then
        ksel,s,kp,,1,kmu,1
        cm,_kset_,kp
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,s,line,,1,lmu,1
        cm,_lset_,line
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,s,area,,1,amu,1
        cm,_aset_,area
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,s,volu,,1,vmu,1
        cm,_vset_,volu
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,s,elem,,1,emu,1
        cm,_eset_,elem
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,s,node,,1,nmu,1
        cm,_ndset_,node
        nsel,u,node,,_ndset_
    *endif
*else
    map_run_=0                  ! mod_assemb_prep IS NOT RUN
*endif                          ! END arg1=2
!
!
constants                       ! (Rev C)
!
*if,csn,eq,0,then
    csn=11                      ! initialize local c.s. numbers (Rev C)
*endif
!
*if,arg1,eq,2,then              ! initialize sub-assembly parameter (Rev J)
    subassm_=1
*else
    *if,modl_num,eq,1,then
        subassm_=0
    *endif
*endif
!
*if,modl_num,eq,1,then          ! create parameter storage array (Rev G)
    !
    *get,zzzparmx,parm,,max     ! get count of user defined parameters
    *get,zzzzsclp,parm,,basic   ! get count of scalar parameters
    !
    zzzzsclp=zzzzsclp-1
    !
    *dim,zzzzparm,char,zzzzsclp+1   ! create array for storing parameters
    !
    zzzparof=0                  ! initialize parameter offset variable
    !
    *do,zzzzzzz1,1,zzzparmx-2,1
        !
        *if,zzzparof,eq,0,then
            zzzzzzz2=zzzzzzz1   ! If parameter offset is 0, leave as is.
        *else
            zzzzzzz2=zzzzzzz1-zzzparof  ! If parameter offset ~0, subtract it.
        *endif
        !
        *get,zzzzpar,parm,,loc,zzzzzzz1     ! retrieve parameter location
        *get,zzpartyp,parm,%zzzzpar%,type   ! retrieve parameter type
        !
        *if,zzzzzzz1,eq,zzzparmx-2,then     ! If ...zz1 = # scalar parameters,
            *if,zzpartyp,ne,0,then          ! If parameter type is not scalar,
                *exit                       ! then exit DO loop.
            *else                           ! If parameter type is scalar, then
                zzzzparm(zzzzzzz2,1)=zzzzpar    ! store in array position '..zz2'.
            *endif
        *else                               ! If zz1 ~= # scalar parameters,
            zzzzparm(zzzzzzz2,1)=zzzzpar    ! store in array position '...zz2'.
        *endif
        !
        *if,zzpartyp,ne,0,then          ! If parameter type not a scalar, then
            zzzparof=zzzparof+1         ! add 1 to parameter offset.
        *endif
        !
    *enddo
    !
    zzzzparm(zzzzsclp+1,1)='ASSMPMXI'   ! Store ASSMPMXI in last position
    assmpmxi=zzzzsclp+1                 ! Store the DIM of array in ASSMPMXI
    !
    *dim,assm_par,char,zzzzsclp+1       ! Store the contents of array in an
    !                                   ! array named ASSM_PAR.
    *do,zzzzijkl,1,zzzzsclp+1,1
        assm_par(zzzzijkl,1)=zzzzparm(zzzzijkl,1)
    *enddo
    !
    *set,zzzzijkl,
    *set,zzzzparm(1),
    *set,zzzzsclp,
    *set,zzzzpar,
    *set,zzzparmx,
    *set,zzzparof,
    *set,zzpartyp,
    *set,zzzzzzz1,
    *set,zzzzzzz2,
*endif
!
abbres,new,tools,mac    ! (Rev B)
!
!------- View & Font Controls ---------
!
! Decide font control based upon operating system (Rev H)
!
*GET,os_,Active,,SYNAME
!
*if,os_,eq,'SOLARIS',then
    /dev,font,1,charter,bold,r,20       ! Solaris 6 - Ultra Sparc 10
*elseif,os_,eq,'SOLARIS6',then
    /dev,font,1,charter,bold,r,20       ! Solaris 1 - Sparc 1
*else
    /dev,font,1,Arial,400,0,-16,0,0,,,  ! win95, NT, etc.
*endif
!
view,'iso'
!
!--------------------------------------


w:\ansys\mac\tools\init_entity_num.mac.html

!   TITLE:  init_entity_num.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!   Rev -   RELEASED    03/22/2000      J. Rinaldi
!---------------------------------------------------------------------------
!   Rev A               04/05/2001      J. Judd
!
!   Eliminates echo to output file during execution of /nopr and /gopr
!---------------------------------------------------------------------------
!   Rev B               10/03/2001      J. Rinaldi
!
!   Added the option to select all parts in an assembly after updating
!   the entity maximums.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is used to update solid and FE model entity numbers,
!   and initialize all newly created entity numbers from these maximums.
!
!
!   COMMAND SYNTAX:
!
!                          (1)
!       INIT_ENTITY_NUM, all_sel
!
!
!   ARGUMENTS:
!
!       (1) all_sel = parameter defining the option to select current
!                     solid model entities or entire assembly of models
!                     entities:
!
!               0 (or blank) = select only current solid model entities.
!
!               1 = select all solid model entities in the assembly.
!
!
!   DESCRIPTION:
!
!   This sub-macro accomodates all solid/FE model parametric operations. It
!   eliminates the use of any numbering "holes" in the sequence that may have
!   been created by boolean operations, thereby allowing total parameterization
!   to be manageable.
!
!   It retrieves the maximum numbers of all solid/FE model entities in the
!   database, and initializes any newly created (or deleted) entity numbers,
!   as a result of any subsequent modeling operations, from the retrieved
!   maximum values.
!
!   Ater retrieving the maximums and initializing the new entity numbers,
!   it will either select only the current solid model entities (the current
!   part under construction in an assembly), or select all entities of all
!   models in the database (assembly). The option between these 2 functions
!   is controlled by the argument, 'all_sel'.
!
!   This sub-macro should ONLY be used when the number maximums and initial-
!   izations are desired from the entire database set. For retrieving the
!   maximum entity numbers from within a selected set of entities, the
!   'GET_MAX_ENTITY' macro should be used.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
km_prev=km              ! store previous entity maximums
lm_prev=lm
am_prev=am
vm_prev=vm
em_prev=em
nm_prev=nm
!
allsel,all
!
*get,km,kp,,num,max     ! store current maximum entity numbers
numstr,kp,km            ! initialize entity numbers from current max values
!
*get,lm,line,,num,max
numstr,line,lm
!
*get,am,area,,num,max
numstr,area,am
!
*get,vm,volu,,num,max
numstr,volu,vm
!
*get,em,elem,,num,max
numstr,elem,em
!
*get,nm,node,,num,max
numstr,node,nm
!
*if,arg1,eq,0,then
    *if,kp_pssof,gt,0,then
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
*elseif,arg1,eq,1,then
    allsel,all
*endif
!
/gopr


w:\ansys\mac\tools\parm_val.mac.html

!   TITLE:  parm_val.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/02/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   05/12/2001      J. Rinaldi
!
!               Modified code to check if a model is built.  If it exists
!               it retrieves the parameter value; if not it aborts. Also
!               added default assignment parameter.
!---------------------------------------------------------------------------
!       Rev B   07/06/2001      J. Rinaldi
!
!               Modified code to use the default value if a parameter
!               array is found but the parameter is not defined.
!---------------------------------------------------------------------------
!       Rev C   01/04/2002      J. Judd
!
!               Modified code to not print to output file except if default
!               value used or if error traps sprung.
!               Added error trap for names not being in single quotes.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro initializes/retrieves a parameter value from a previously
!   stored array of parameter values.
!
!
!   COMMAND SYNTAX:
!
!                   (1)      (2)     (3)       (4)
!       PARM_VAL, mod_name, param, new_parm, def_val
!
!
!   ARGUMENTS:
!
!       (1) mod_name = model name using the parameter file which has
!                      the desired user value.  This may be retrieved
!                      from the array 'MODEL'.
!
!       (2) param = desired parameter within the parameter file to be
!                   queried.
!
!       (3) new_parm = new parameter character name to assign the value to
!
!       (4) def_val = parameter assignment default value.  If ALL of the
!                     following conditions are met:
!
!                   a.) the parameter array for a model does not exist
!
!                   b.) the parameter NEW_PARM is not previously defined
!
!                   c.) DEF_VAL is not equal to 0
!
!               then DEF_VAL is assigned to the new specified parameter.
!
!           In the event that a given model, and therefore the parameter
!           array, does not exist for retrieval, these conditions will insure
!           that a previously defined value for a parameter holding the name
!           of NEW_PARM is not overwritten when this macro is executed. Also,
!           if the parameter NEW_PARM is not previously defined, it will not
!           be initialized with a value of 0 when DEF_VAL is left blank.
!           A message note will be included in the output if the default value
!           is used.
!
!
!   DESCRIPTION:
!
!   These parameter values may be used to link separate models together whose
!   surfaces may interface. This will keep the surfaces contingent by using the
!   same dimensional values to interface the parts (e.g., outer diameter of one
!   part mating with the inner diameter of a second part, therefore same diame-
!   ter value must be used for the two mating surfaces from a given axis of rot-
!   ation). This prevents the user from searching for a specific parameter value
!   manually, and keeps the parts linked if a specific paramter value is changed.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
*set,abort1_        ! initialize error traps/flags to default settings
*set,trap1_
*set,trap2_
!
mod_name=arg1
param_=arg2
newparm_=arg3
defval_=arg4
!
*get,ptyp_,parm,mod_name,type   ! check that 'mod_name' is a character string
!
*if,ptyp_,ne,3,then
   abort1_=1
*endif
!
*get,ptyp_,parm,param_,type     ! check that 'param_' is a character string
!
*if,ptyp_,ne,3,then
   abort1_=1
*endif
!
*get,ptyp_,parm,newparm_,type   ! check that 'newparm_' is a character string
!
*if,ptyp_,ne,3,then
   abort1_=1
*endif
!
*if,abort1_,ne,1,then
    param_=upcase(param_)
    *get,parftyp_,parm,par_file,type
    !
    *if,parftyp_,eq,4,then
        *get,modlim_,parm,par_file,dim,x
        !
        *do,iiii_,1,modlim_,1
            *if,mod_name,eq,model(iiii_,1),then
                mod_indx=iiii_
                abrtget_=0
                *exit
            *else
                *if,iiii_,eq,modlim_,then
                    abrtget_=1
                *endif
            *endif
        *enddo
        !
        *if,abrtget_,eq,0,then
            parm_arr=par_file(mod_indx,1)
            !
            max_indx=parfmxi(mod_indx,1)
            !
            *do,iiii_,1,max_indx,1
                *if,param_,eq,%parm_arr%(iiii_,1),then
                    %newparm_%=%parm_arr%v(iiii_,1)
                    *exit
                *else
                    *if,iiii_,eq,max_indx,then
                        *get,ptyp_,parm,%newparm_%,type
                        !
                        *if,ptyp_,eq,-1,then
                            *if,defval_,ne,0,then
                                %newparm_%=defval_
                                trap1_=1
                            *endif
                        *else
                            trap2_=1
                        *endif
                    *endif
                *endif
            *enddo
        *else
            *get,ptyp_,parm,%newparm_%,type
            !
            *if,ptyp_,eq,-1,then
                *if,defval_,ne,0,then
                    %newparm_%=defval_
                    trap1_=1
                *endif
            *else
                trap2_=1
            *endif
        *endif
    *else
        *get,ptyp_,parm,%newparm_%,type
        !
        *if,ptyp_,eq,-1,then
            *if,defval_,ne,0,then
                %newparm_%=defval_
                trap1_=1
            *endif
        *else
            trap2_=1
        *endif
    *endif
*else
   *msg,warn
   PARM_VAL aborted.  Need single quotes around model or variable names. &
   Output file/window lists the input parameters for 'PARM_VAL' execution.
*endif
!
*if,trap1_,eq,1,then
   *msg,warn
   Default value used in 'PARM_VAL' execution. &
   Output file/window lists the input parameters for 'PARM_VAL' execution.
*endif
!
*if,trap2_,eq,1,then
    *msg,warn
    PARM_VAL aborted.  Default value not used (parameter currently defined). &
    Output file/window lists the input parameters for 'PARM_VAL' execution.
*endif
!
*set,mod_name,
*set,param_,
*set,newparm_,
*set,defval_,
*set,iiii_,
*set,max_indx,
*set,mod_indx,
*set,parm_arr,
*set,abrtget_,
*set,ptyp_,
*set,parftyp_,
*set,modlim_,
*set,abort1_,
*set,trap1_,
*set,trap2_,
/gopr


w:\ansys\mac\tools\finalize_model_data.mac.html

!   TITLE:  finalize_model_data.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  03/22/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to finalize storage of solid model entities
!   into groups by name, and store all model names in an array called 'MODEL'.
!   This aids in selecting parts or subassemblies, and tracking their names.
!   It is called at the end of all part macros to store pertinent model data.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
*if,subassm_,eq,1,then      ! subassm_ is defined in mod_assem_prep.mac
    init_entity_num
*else
    purge_model
*endif
!
nummrg,kp
!
init_entity_num
!
*get,vcount,volu,,count         ! Selected volume count
!
*get,_parchk1,parm,name,type    ! Model name type: 0=scalar, 1=array,
                                ! 2=table, 3=character scalar,
                                ! 4=character array, -1=undefined Parameter.
!
*if,_parchk1,eq,-1,then
    name='part1_'               ! Default if part name undefined
*endif
!
*if,vcount,gt,0,then
    !
    cm,name,volu
    !entity_file,'v','%name%'
    !
    !---------------- Store Volume Model Name in MODEL Array ---------------
    !
    *if,modl_num,eq,1,then
        model(modl_num,1)=name
    *else
        *do,mnz_,1,modl_num-1,1
            mdlbuff(mnz_,1)=model(mnz_,1)
        *enddo
        !
        mdlbuff(modl_num,1)=name
        !
        *set,model(1),
        *dim,model,char,modl_num
        !
        *do,mnz_,1,modl_num,1
            model(mnz_,1)=mdlbuff(mnz_,1)
        *enddo
        !
        *set,mdlbuff(1),
        *dim,mdlbuff,char,modl_num+1
    *endif
    !
    !-----------------------------------------------------------------------
    !
*else
    !
    cm,name,area
    !entity_file,'a','%name%'
    !
    !----------------- Store Area Model Name in MODEL Array ----------------
    !
    *if,modl_num,eq,1,then
        model(modl_num,1)=name
    *else
        *do,mnz_,1,modl_num-1,1
            mdlbuff(mnz_,1)=model(mnz_,1)
        *enddo
        !
        mdlbuff(modl_num,1)=name
        !
        *set,model(1),
        *dim,model,char,modl_num
        !
        *do,mnz_,1,modl_num,1
            model(mnz_,1)=mdlbuff(mnz_,1)
        *enddo
        !
        *set,mdlbuff(1),
        *dim,mdlbuff,char,modl_num+1
    *endif
    !
    !-----------------------------------------------------------------------
    !
*endif
!
allsel,all
!
lplot
!
*set,mnz_,
*set,vcount,
!
*get,_parchk2,parm,cs_arry,type
*get,_parchk3,parm,arry_nam,type
!
*if,_parchk2,eq,4,then
    *do,mnz_,1,csn-11,1     ! uninitializes c.s. parameter names
        *set,%cs_arry(mnz_,1)%,
    *enddo
*endif
!
*if,_parchk3,ne,-1,then
    _indxoff=4              ! parameter array index offset (lines 5&6, PAR_ARRAY)
    par_array,arry_nam      ! stores model parameters in an array
*endif
!
*if,_parchk2,eq,4,then
    *do,mnz_,1,csn-11,1     ! reinitializes c.s. parameter names
        *set,%cs_arry(mnz_,1)%,cs_arryv(mnz_,1)
    *enddo
*endif
!
*get,nummat_,parm,mat_name,dim,y
!
*if,nummat_,gt,0,then       ! reinitializes material number parameters
    *do,abc_,1,nummat_,1
        mat_prop(1,abc_)=abc_
        namhold_=mat_name(1,abc_)
        %namhold_%=abc_
    *enddo
*endif
!
!
*set,namhold_,
*set,nummat_,
*set,abc_,
*set,arry_nam,
*set,mnz_,
*set,_parchk1,
*set,_parchk2,
*set,_parchk3,


w:\ansys\mac\tools\create_cs.mac.html

!   TITLE:  create_cs.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -  RELEASED     08/18/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a coordinate system (c.s.) by CLOCAL, CSKP, LOCAL
!   or CS.  It also updates the coordinate system tracking parameter, CSN,
!   and names the coordinate system by a user specified name.  The arguments
!   used as input for this macro are:
!
!       (1) mthd = the method used to create the coordinate system.
!                  Options for this argument are:
!
!                   0 (or blank) = use the command CLOCAL; create c.s. at a
!                                  relative position and orientation to the
!                                  active c.s.
!
!                   1 = use the command CSKP; create c.s. by 3 keypoints.
!
!                   2 = use the command LOCAL; create c.s. relative to
!                       global cartesian c.s.
!
!                   3 = use the command CS; create c.s. by 3 nodes.
!
!       (2) cs_nam = character parameter name of c.s., which is assigned
!                    the value of CSN, the coordinate system number.
!
!       (3) cs_typ = coordinate system type:
!
!                   0 = cartesian
!                   1 = cylindrical
!                   2 = spherical
!                   3 = toroidal
!
!       (7, 10) ratyx = scaling ratio of y-axis radius to x-axis radius
!
!       (8, 11) ratzx = scaling ratio of z-axis radius to x-axis radius
!
!
!   Arguments particular to the various options:
!
!   METHOD = 0 & 2:
!
!           (4) xc = x coordinate of c.s. center
!
!           (5) yc = x coordinate of c.s. center
!
!           (6) zc = x coordinate of c.s. center
!
!           (7) rotxy = 1st rotation angle (+x to +y)
!
!           (8) rotyz = 2nd rotation angle (+y to +z)
!
!           (9) rotzx = 3rd rotation angle (+z to +x)
!
!   METHOD = 1:
!
!           (4) kp_1 = c.s. origin keypoint
!
!           (5) kp_2 = keypoint defining +x axis direction
!
!           (6) kp_3 = keypoint defining +y axis direction (+xy plane)
!
!   METHOD = 3:
!
!           (4) nd_1 = c.s. origin node
!
!           (5) nd_2 = node defining +x axis direction
!
!           (6) nd_3 = node defining +y axis direction (+xy plane)
!
!
!
!---------------------- COMMAND SYNTAX / method = 0 ------------------------
!
!             (1)    (2)    (3)    (4) (5) (6)  (7)    (8)    (9)
! CREATE_CS, mthd, cs_nam, cs_typ, xc, yc, zc, rotxy, rotyz, rotzx
!
!            ratyx, ratzx
!            (10)    (11)
!
!------------------------------- method = 1 --------------------------------
!
!             (1)    (2)    (3)    (4)   (5)   (6)    (7)    (8)
! CREATE_CS, mthd, cs_nam, cs_typ, kp_1, kp_2, kp_3, ratyx, ratzx
!
!------------------------------- method = 2 --------------------------------
!
!             (1)    (2)    (3)    (4) (5) (6)  (7)    (8)    (9)
! CREATE_CS, mthd, cs_nam, cs_typ, xc, yc, zc, rotxy, rotyz, rotzx
!
!            ratyx, ratzx
!            (10)    (11)
!
!------------------------------- method = 3 --------------------------------
!
!             (1)    (2)    (3)    (4)   (5)   (6)    (7)    (8)
! CREATE_CS, mthd, cs_nam, cs_typ, nd_1, nd_2, nd_3, ratyx, ratzx
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

mthd=arg1
cs_nam=arg2
cs_typ=arg3
!
!
csn=csn+1
!
*get,par_typ,parm,cs_nam,type
!
*if,par_typ,eq,0,then
    cs_nam=csn
    abrtfile=1              ! abort filing process parameter (1=abort filing)
*elseif,par_typ,eq,3,then
    %cs_nam%=csn
    abrtfile=0              ! abort filing process parameter (0=file)
*endif
!
*if,mthd,eq,0,then
    xc=arg4
    yc=arg5
    zc=arg6
    rotxy=arg7
    rotyz=arg8
    rotzx=arg9
    ratyx=ar10
    ratzx=ar11
    !
    clocal,%cs_nam%,cs_typ,xc,yc,zc,rotxy,rotyz,rotzx,ratyx,ratzx
    !
    *set,xc,
    *set,yc,
    *set,zc,
    *set,rotxy,
    *set,rotyz,
    *set,rotzx,
*endif
!
!
*if,mthd,eq,1,then
    kp_1=arg4
    kp_2=arg5
    kp_3=arg6
    ratyx=arg7
    ratzx=arg8
    !
    cskp,%cs_nam%,cs_typ,kp_1,kp_2,kp_3,ratyx,ratzx
    !
    *set,kp_1,
    *set,kp_2,
    *set,kp_3,
*endif
!
!
*if,mthd,eq,2,then
    xc=arg4
    yc=arg5
    zc=arg6
    rotxy=arg7
    rotyz=arg8
    rotzx=arg9
    ratyx=ar10
    ratzx=ar11
    !
    local,%cs_nam%,cs_typ,xc,yc,zc,rotxy,rotyz,rotzx,ratyx,ratzx
    !
    *set,xc,
    *set,yc,
    *set,zc,
    *set,rotxy,
    *set,rotyz,
    *set,rotzx,
*endif
!
!
*if,mthd,eq,3,then
    nd_1=arg4
    nd_2=arg5
    nd_3=arg6
    ratyx=arg7
    ratzx=arg8
    !
    cs,%cs_nam%,cs_typ,nd_1,nd_2,nd_3,ratyx,ratzx
    !
    *set,nd_1,
    *set,nd_2,
    *set,nd_3,
*endif
!
*get,_parchk,parm,cs_arry,type
!
*if,abrtfile,eq,0,then
    *if,_parchk,eq,4,then
        cs_file
    *endif
*else
    csn=csn-1
*endif
!
*set,abrtfile,
*set,cs_nam,
*set,cs_typ,
*set,par_typ,
*set,ratyx,
*set,ratzx,
*set,mthd,
*set,_parchk,


w:\ansys\mac\tools\mod_coord_system.mac.html

!   TITLE:  mod_coord_system.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  07/28/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates the model coordinate systems for a particular
!   part.  It is called by the part macro, and is found in section 2 of
!   MACRO_TEMPLATE.MAC.  The coordinate system names are defined in
!   PARAMETER_FILE_TEMPLATE.PARM, and the coordinate system positional
!   stack-ups are tracked by C_S_POSITION.MAC. The relative position of
!   these model coordinate systems are measured from an active coordinate
!   system (ACS), as specified by argument 1 (ARG1).
!
!   If the model coordinate system names are not specified, then the names
!   'cs0_', 'cs1_' and 'cs2_' will be assigned to 'ct_name', 'cyl_name' and
!   'sph_name', respectively, by default.
!
!   After creation of the model coordinate systems, the cartesian model c.s.,
!   %ct_name%, is made active by default. If another c.s. is desired for the
!   next set of operations, then the user must manually activate it.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MOD_COORD_SYSTEM, acs, xc, yc, zc, rotxy, rotyz, rotzx
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
acs_mcs=arg1        ! active coordinate system (c.s.) locating model c.s.
!
!------------- Specify model c.s. center location --------------
!
xc_mcs=arg2             ! x (r) coordinate center
yc_mcs=arg3             ! y (theta) coordinate center
zc_mcs=arg4             ! z (z or phi) coordinate center
!
!------------- Specify model c.s. orientation ------------------
!
rotxymcs=arg5           ! 1st rotation angle (+x to +y)
rotyzmcs=arg6           ! 2nd rotation angle (+y to +z)
rotzxmcs=arg7           ! 3rd rotation angle (+z to +x)
!
!---------------------------------------------------------------
!
*get,_parchk1,parm,ct_name,type
*get,_parchk2,parm,cyl_name,type
*get,_parchk3,parm,sph_name,type
!
*if,_parchk1,eq,-1,then
    ct_name='cs0_'
*endif
!
*if,_parchk2,eq,-1,then
    cyl_name='cs1_'
*endif
!
*if,_parchk3,eq,-1,then
    sph_name='cs2_'
*endif
!
csn=csn+1
%ct_name%=csn       ! cartesian model c.s. number
!
csn=csn+1
%cyl_name%=csn      ! cylindrical model c.s. number
!
csn=csn+1
%sph_name%=csn      ! spherical model c.s. number
!
csys,acs_mcs
clocal,%ct_name%,0,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
csys,acs_mcs
clocal,%cyl_name%,1,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
csys,acs_mcs
clocal,%sph_name%,2,xc_mcs,yc_mcs,zc_mcs,rotxymcs,rotyzmcs,rotzxmcs
!
c_s_position        ! calculates c.s. position stack_ups
!
cs_file,1           ! files newly formed c.s. in array
!
*set,_parchk1,
*set,_parchk2,
*set,_parchk3,
*set,acs,
*set,xc,
*set,yc,
*set,zc,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
!
csys,%ct_name%


w:\ansys\mac\tools\cs_file.mac.html

!   TITLE:  cs_file.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  08/21/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to file coordinate system character parameter
!   names and their cooresponding c.s. number values.  It is called by
!   MOD_COORD_SYSTEM.MAC and CREATE_CS.MAC macro commands.  It then
!   reinitializes these parameters for use in the next model sets.
!
!           mcs_enbl = model coordinate system enable.  This parameter
!                      enables the use of the line code below that
!                      accomodates the input of CT_NAME, CYL_NAME and
!                      SPH_NAME into the coordinate system array, CS_ARRY.MAC.
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

mcs_enbl=arg1
!
!
*if,csn,le,14,then
    !
    *dim,cs_arry,char,csn-11
    *dim,cs_buff,char,(csn-11)+1
    !
    *dim,cs_arryv,array,csn-11
    *dim,cs_buffv,array,(csn-11)+1
    !
    cs_arry((csn-11)-2,1)=ct_name
    cs_arry((csn-11)-1,1)=cyl_name
    cs_arry((csn-11)-0,1)=sph_name
    !
    cs_arryv((csn-11)-2,1)=%ct_name%
    cs_arryv((csn-11)-1,1)=%cyl_name%
    cs_arryv((csn-11)-0,1)=%sph_name%
    !
*else
    !
    *if,mcs_enbl,eq,0,then
        *do,mnz,1,(csn-11)-1,1
            cs_buff(mnz,1)=cs_arry(mnz,1)
            cs_buffv(mnz,1)=cs_arryv(mnz,1)
        *enddo
        !
        cs_buff(csn-11,1)=cs_nam
        cs_buffv(csn-11,1)=%cs_nam%
        !
        *set,cs_arry(1),
        *set,cs_arryv(1),
        !
        *dim,cs_arry,char,csn-11
        *dim,cs_arryv,array,csn-11
        !
        *do,mnz,1,csn-11,1
            cs_arry(mnz,1)=cs_buff(mnz,1)
            cs_arryv(mnz,1)=cs_buffv(mnz,1)
        *enddo
        !
        *set,cs_buff(1),
        *set,cs_buffv(1),
        !
        *dim,cs_buff,char,(csn-11)+1
        *dim,cs_buffv,array,(csn-11)+1
    *else
        *set,cs_buff(1),
        *set,cs_buffv(1),
        !
        *dim,cs_buff,char,csn-11
        *dim,cs_buffv,array,csn-11
        !
        *do,mnz,1,(csn-11)-3,1
            cs_buff(mnz,1)=cs_arry(mnz,1)
            cs_buffv(mnz,1)=cs_arryv(mnz,1)
        *enddo
        !
        cs_buff((csn-11)-2,1)=ct_name
        cs_buff((csn-11)-1,1)=cyl_name
        cs_buff((csn-11)-0,1)=sph_name
        !
        cs_buffv((csn-11)-2,1)=%ct_name%
        cs_buffv((csn-11)-1,1)=%cyl_name%
        cs_buffv((csn-11)-0,1)=%sph_name%
        !
        *set,cs_arry(1),
        *set,cs_arryv(1),
        !
        *dim,cs_arry,char,csn-11
        *dim,cs_arryv,array,csn-11
        !
        *do,mnz,1,csn-11,1
            cs_arry(mnz,1)=cs_buff(mnz,1)
            cs_arryv(mnz,1)=cs_buffv(mnz,1)
        *enddo
        !
        *set,cs_buff(1),
        *set,cs_buffv(1),
        !
        *dim,cs_buff,char,(csn-11)+1
        *dim,cs_buffv,array,(csn-11)+1
    *endif
*endif
!
*set,mcs_enbl,
*set,mnz,


w:\ansys\mac\tools\clear_exit.mac.html

!   TITLE:  clear_exit.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  04/12/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro clears the database, and exits ANSYS.
!
FINISH
/CLEAR,START
/EXIT,NOSAV


w:\ansys\mac\tools\clear_start_new.mac.html

!   TITLE:  clear_start_new.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  04/12/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro clears the database, ready to start a new session;
!   and initializes the toolbar functions.
!
FINISH
/CLEAR,START
reverse_video,arg1
vidtog_=arg1
vuscntr_=1
abbres,new,tools,mac


w:\ansys\mac\tools\clr_resume_db.mac.html

!   TITLE:  clr_resume_db.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  09/19/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro clears the database, ready to start a new session; resumes
!   the current database, and initializes the toolbar functions.
!
*get,prkey_,active,0,prkey
/nopr

clear_start_new,vidtog_
!
resume
!
allsel,all
!
*get,kp_cnt,kp,,count
*get,ln_cnt,line,,count
*get,ar_cnt,area,,count
*get,vl_cnt,volu,,count
*get,el_cnt,elem,,count
!
*if,el_cnt,gt,0,then
    eplot
*elseif,vl_cnt,gt,0,then
    vplot
*elseif,ar_cnt,gt,0,then
    aplot
*elseif,ln_cnt,gt,0,then
    lplot
*elseif,kp_cnt,gt,0,then
    kplot
*endif
!
toolbar
!
/prep7


w:\ansys\mac\tools\new_db.mac.html

!   TITLE:  new_db.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  09/19/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro clears the database, ready to start a new session; resumes
!   the current database, and initializes the toolbar functions.
!
*get,prkey_,active,0,prkey
/nopr

clear_start_new
!
*ask,new_dbf,DATABASE FILE TO CHANGE TO,'file'
!
/filname,new_dbf,1
!
resume
!
allsel,all
!
*get,kp_cnt,kp,,count
*get,ln_cnt,line,,count
*get,ar_cnt,area,,count
*get,vl_cnt,volu,,count
*get,el_cnt,elem,,count
!
*if,el_cnt,gt,0,then
    eplot
*elseif,vl_cnt,gt,0,then
    vplot
*elseif,ar_cnt,gt,0,then
    aplot
*elseif,ln_cnt,gt,0,then
    lplot
*elseif,kp_cnt,gt,0,then
    kplot
*endif
!
toolbar


w:\ansys\mac\tools\striplis.pl.html

#!/usr/local/bin/perl
#
#   TITLE:  striplis.pl (MANAGEMENT)
#
#---------------------------------------------------------------------------
#       Rev -     01/20/2001    D. Edwards <dee.engineering@usa.net>
#       Rev A     04/26/2001    D. Edwards
#                 Handle stray lines that get written when running
#                 in batch mode.
#---------------------------------------------------------------------------
#
# Remove extraneous lines from one or more Ansys output listing ".lis" files.
# The contents of the input files are replaced by the stripped versions.
#
# Lines that do not start with one or more spaces followed by a digit are
# removed.
#
#------------------------------ COMMAND SYNTAX -----------------------------
#
# striplis.pl file_name...
#
#   file_name = The name of the file(s) to remove extraneous lines froms
#
#---------------------------------------------------------------------------

foreach $fname (@ARGV) {

    #print "$fname\n";

    open(IN,"$fname") || die "Unable to open $fname: $!";
    open(OUT,">$fname.tmp") || "Unable to open scratch file $fname: $!";

    while (<IN>) {
        if (/^\s+[0-9]/ && ! /VERSION/) {
            print OUT;
        }
    }
    close(IN);
    close(OUT);
    unlink("$fname");
    rename("$fname.tmp","$fname");
}

#print "All done with Perl\n";


w:\ansys\mac\tools\line1.pl.html

#!/usr/local/bin/perl
#
#   TITLE:  line1.pl (MANAGEMENT)
#
#---------------------------------------------------------------------------
#       Rev -     RELEASED  01/20/2001  D. Edwards <dee.engineering@usa.net>
#---------------------------------------------------------------------------
#
# This macro takes a multiline file and converts it to one line.
# The contents of each line are separated by one space.
#
#   (1) file_name = The name of the file to be reformatted to one line.
#
#------------------------------ COMMAND SYNTAX -----------------------------
#
#            (1)
# line1.pl file_name
#
#---------------------------------------------------------------------------

#
# Open input file and create temp. output file
#
open(IN,"$ARGV[0]") || die "Unable to open $ARGV[0]: $!";

$fout="line1.$$";
open(OUT,">$fout") || die "Unable to create $fout: $!";

while (<IN>) {
    chomp;
    s/\s*$//;
    print OUT "$_ ";
}

print OUT "\n";

close(IN);
close(OUT);

unlink("$ARGV[0]") || warn "Unable to delete $ARGV[0]: $!";
rename("$fout","$ARGV[0]") || die "Unable to rename $fout to $ARGV[0]: $!";


w:\ansys\mac\tools\macro_template.mac.html

!   TITLE:  macro_template.mac (TEMPLATE)
!
!-----------------------------------------------------------------------
!       Rev -   XX/XX/XXXX      X. XXXXX
!-----------------------------------------------------------------------
!
!   XXXXXXXXXXXXXXXXXXX
!
!   CSXXX0:     Cartesian XXXXX Coordinate System
!   CSXXX1:     Cylindrical XXXXX Coordinate System
!   CSXXX2:     Spherical XXXXX Coordinate System
!
!
!************************** TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Solid Model
!
!********************* Model Assembly Preparation **********************
!
mod_assemb_prep,arg1,arg2,arg3      ! prepare database for assembly
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
XXX.parm                            ! name of parameter file
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate System >>>>>>>>>>>>>>>>>>>>>
!
mod_coord_system,acs,xc,yc,zc,rotxyc,rotyzc,rotzxc
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 3.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!

Customize macro in the following fields and delete these instructions as
they are completed. Be sure that parameter names are properly chosen for
non-interference with other models.

    1.  Macro title

    2.  Revision letter, date and name of initiator.  When macro is
        completed for use, place the term 'RELEASED' after the 'Rev -'.
        This releases the macro for use, and any changes made to the
        macro after the release date must be documented as a revision
        starting with the letter 'A' (e.g., Rev A). The lettering
        sequence continues with each change as a new revision. With
        each change, notes should be included documenting what changes
        were made. An example of this is:

!---------------------------------------------------------------------------
!       Rev -   RELEASED  XX/XX/XXXX    X. XXXXX
!---------------------------------------------------------------------------
!       Rev A   YY/YY/YYYY  Y. YYYYY
!
!       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!---------------------------------------------------------------------------
!       Rev B   ZZ/ZZ/ZZZZ  Z. ZZZZZ
!
!       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!---------------------------------------------------------------------------
!

    3.  Text region describing macro function and purpose

    4.  Coordinate system names for cartesian (CS..0), cylindrical (CS..1)
        and spherical (optional) (CS..2) model coordinate systems
        (Information purposes only)

    5.  MOD_ASSEMB_PREP arguments are set externally by the part macro call as
        arguments.

        Argument 1 is the parameter 'assemble', and argument 2 is the parameter
        'frst_mdl'. ( See MOD_ASSEMB_PREP help for an explanation of the use
        of these parameters ) Therefore, if the part macro name is 'PART_NAME.mac',
        then the macro call, setting these parameters, will have the following
        formats:

                PART_NAME,1  ;  PART_NAME,2  ;  PART_NAME,,1  ; etc.

    6.  Parameter file name.  XXX is the macro title with a '.parm' extension.
                (See 'parameter_file_template.parm' for c.s.and part names.
                 This template must be completed in order to feed the
                 character parameter names to the the part macro.)

    7. ************************** IMPORTANT ***************************

        Be sure to end all macros with the following sub-macro call:
        (This is especially important for models to be used in assemblies)

                finalize_model_data


w:\ansys\mac\tools\parameter_file_template.parm.html

!   TITLE:  parameter_file_template.parm (TEMPLATE)
!
!---------------------------------------------------------------------------
!       Rev -   XX/XX/XXXX      X. XXXXX
!---------------------------------------------------------------------------
!
!   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!
!---------------------- a.) Title and Units Declaration --------------------
!
/title,XXXXXXXXXXX
!
/units,XXXX                     ! XXXXX
!
!--------------------- b.) Part Name Selection Variable --------------------
!
name='XXXXX'
arry_nam='XXXXX'
!
!--------------------------- c.) Model C.S. Names --------------------------
!
ct_name='CSXXX0'            ! cartesian
cyl_name='CSXXX1'           ! cylindrical
sph_name='CSXXX2'           ! spherical
!
!----------------------- d.) Material and Element Type ---------------------
!
!
mat_select,VVV,WWW,XXX,YYY,ZZZ              ! Material Properties
!
!
ET,XX,XXXXX                                 ! Element Types
ET,XX,XXXXX
!
!--------------------------- e.) Model Parameters --------------------------
!

                    <<<<< Defined Model Parameters >>>>>

!
!------------------------ f.) Model C.S. Coordinates -----------------------
!
acs=0                           ! active coordinate system
!
xc=0                            ! x coordinate center
yc=0                            ! y coordinate center
zc=0                            ! z coordinate center
!
rotxyc=0                        ! xy rotation
rotyzc=0                        ! yz rotation
rotzxc=0                        ! zx rotation
!
!---------------------------------------------------------------------------

Customize in the following fields and delete these instructions as
they are completed. Be sure that parameter names are properly chosen for
non-interference with other models.

    1.)  Parameter file name with macro title prefix, and a '.parm'
         extension.

    2.)  Revision letter, date and name of initiator.  Follow the same
         convention as 'macro_template.mac'.

    3.)  Text region describing parameter file function and purpose.

    SECTIONS:

    a.)  Graphics window title field (/title,...)

         Unit system used (/units,...) plus comment field

    b.) Set model character name variable (must be 8 characters or less).
        Set parameter file array name (must be 5 characters or less).

    c.) Model c.s. variable names for:

                - cartesian -----\
                                  \
                - cylindrical      |    coordinate systems.
                                  /
                - spherical -----/

    d.)     - Set material properties names to be used

            - Set element types and number

    e.)  Model Parameters

            <<<<< Defined Model Parameters >>>>>

                Open Region for defining parameters.

    f.)  Model coordinate system coordinates. This section sets the Active
         Coordinate System (acs)to build new model from. Set cartesian (if
         'acs' is cartesian), cylindrical (if 'acs' is cylindrical) or spherical
         (if 'acs' is spherical) coordinate values of model coordinate systems
         centers and angular orientations (rotxy, rotyz, rotzx).

         The remaining arguments are the location of the origin (xc, yc and zc)
         and the axis orientations (rotxyc, rotyzc and rotzxc) of the model C.S.
         These values are transferred to MOD_COORD_SYSTEM in the part macro.

         This region must be defined last.  This allows the use of the
         defined model parameters to also be used in defining the model
         C.S. coordinates and axis rotation parameters.


w:\ansys\mac\tools\getiges.mac.html

!
!       TITLE:  getiges.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!               Rev -     02/28/2001      D. Edwards
!
!               Rev A     01/04/2002      D. Edwards
!                   Ansys 5.7 changed "IOPTN,IGES,ALTERNATE"
!                   to "IOPTN,IGES,NODEFEAT"
!---------------------------------------------------------------------------
!
! Read an IGES file and parameterize its points and lines.
!
!  NOTE:  This macro requires perl to be installed on the computer.
!         See ansys/tools/README.perl for more information.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! USAGE:  getiges,'fname_iges'
!         getiges                  (All prompted input)
!
!   where fname_iges = base file name (w/o extension) of the IGES file
!   to be read in.  Single quotes must surround the name.

!------------------------------ Examples -----------------------------------
!
! Read in "flange.igs" and prompt for needed information to fill into
! flange.mac (a copy of macro_template.mac renamed to flange.mac).  All the
! prompted information is stored in a file named flange.inf.
!
!   getiges 'flange'
!
! Running the command again will use the contents of flange.inf rather than
! prompt for all the same information again.  Any changes to the information
! is accomplished by editing flange.inf before rerunning the getiges macro.
!
!
!---------------------- List of Dependencies ------------------------------
!
!   getiges.mac
!       tools/macro_template.mac
!       tools/parameter_file_template.mac
!
!---------------------------------------------------------------------------
*get,prkey_,active,0,prkey
/nopr

fini
/clear,start

!
! Prompt for IGES base file name if not given on command line
!
figes_=arg1
*get,ptype_,parm,figes_,type
*if,ptype_,eq,3,then
    figes_=arg1
*else
    *ask,figes_,Enter the base name of the .igs file:,'figes'
*endif

!
! Enter the IGES file translator
!
/aux15
IOPTN,IGES,NODEFEAT         ! In 5.6 use: IOPTN,IGES,ALTERNATE
IOPTN,MERGE,YES
IOPTN,SOLID,NO
IOPTN,SMALL,NO
IOPTN,GTOLER, DEFA

igesin,%figes_%,igs

fini

/prep7

! Renumbering is needed since merged KP's may leave gaps in numbering
numcmp,all

/PNUM,KP,1
/PNUM,LINE,1
lplot

!
! Generate output listings for mkmac.sh
!
/out,kp_def,lis
klist,all,,,coord
/out

/out,l_def,lis
llist,,,,radius
/out

ksll,u
/out,kp_cent,lis
klist,all,,,coord
/out

alls

!
! Generate an Ansys macro from the KP and line information
!
/syp,getinfo.pl,figes_
/syp,mkmac.pl,figes_

!
! Debugging lines (normally commented out)
!

! See which perl is in use
!/sys,perl -v

! Work
!/sys,perl -d e:\sl\ansys\dee\getinfo.pl test1
!/sys,perl -d e:\sl\ansys\dee\mkmac.pl nhbb_u

! Home (ActiveState)
!/sys,perl -d j:\eng\ansys\dee\getinfo.pl 'test1'
!/sys,perl -d j:\eng\ansys\dee\mkmac.pl 'astub'

! Home (Cygwin)
!/sys,d:\cygwin\bin\perl -d j:\eng\ansys\dee\mkmac.pl 'astub'

!/syp,mkmac.sh,figes_  ! Old version of getiges


w:\ansys\mac\tools\mkmac.pl.html

#!/usr/local/bin/perl
#
#   TITLE:  mkmac.pl (MANAGEMENT)
#
#---------------------------------------------------------------------------
#       Rev -   02/23/2001  D. Edwards <dee.engineering@usa.net>
#
#       Rev A   04/13/2001  D. Edwards
#               Revised script to support both DOS and UNIX ASCII formatted
#               files.
#
#       Rev B   05/09/2001  D. Edwards
#               Added capability to map x, y and z coordinates to any
#               other combination of coordinates.
#
#       Rev C   05/16/2001  D. Edwards
#               Modify algorithim for reading in KP's from file so
#               spaces between numbers are not required.
#
#       Rev D   01/04/2002  D. Edwards
#               Update to work with revised macro/parm templates.
#
#---------------------------------------------------------------------------
#
# This perl program creates a part macro and associated parameter file based
# on Ansys database information and user prompted information.
#
# Before calling this program, the following files must be available:
#
#   1.  macro_template.mac:  The new part macro is generated by filling in
#       this template file. mkmac.pl is based on the 2-16-01 release of
#       of this file. The file must resides in the Ansys working directory
#       or in one of the directories specified in path environment variable
#       ANSYS_MACROLIB (see section 4.2.2 of the Ansys APDL User's Guide
#       for more information).
#
#   2.  parameter_file_template.parm:  This file should reside in the
#       same directory as file 1. above and must be the 2-16-01 release.
#
#       NOTE: If any skeleton fields are added or removed from the
#             above files, this program will need to be modified to
#             work with the changes.
#
#   3. "file_name".inf:  A tab delimited, two column, list of keys and
#       associated values.  The list of keys are defined at the end of this
#       file under the heading *INF DEFINITION*.  The key values are
#       substituted into files 1. and 2. above.  "file_name" must be supplied
#       on the command line.
#
#   4.  "file_name".des.inf:  An optional file which descibes the part
#       macro being created.
#
#   5.  kp_def.lis:  Ansys listing defining all key points to create in
#       the output macro.
#
#   6.  kp_cent.lis:  Ansys listing defining all arc centers
#
#   7.  l_def.lis:  Ansys listing defining all lines and arcs.
#
#------------------------------ COMMAND SYNTAX -----------------------------
#
#   mkmac.pl file_name
#
#     file_name = The base name of the above files denoted with
#             "file_name" (8 characters max).
#
#---------------------------------------------------------------------------
#
#---------------------- List of Dependencies ------------------------------
#
#   mkmac.pl
#       ansys/tools/macro_template.mac
#       ansys/tools/parameter_file_template.parm
#       file_name.inf
#       file_name.des.inf (optional)
#       kp_def.lis
#       kp_cent.lis
#       l_def.lis
#
#   NOTE: See README.perl for information running Perl on the UNIX and
#         windows platforms.
#
#---------------------------------------------------------------------------
#
#---------------------- Table of Contents  ---------------------------------
#
#   1. File name definitions
#   2. Read in the previously created .inf file
#   3. Read macro template and fill in blanks. Output to "file_name".mac
#   4. Read parm template and fill in blanks. Output to "file_name".parm
#   5. Fill in contents of Macro with Ansys listing data
#       5.1 Read in the list of circle centers into memory
#       5.2 Store coordinates of arc endpoints in a hash of lists
#           in "%end_point_kp"
#   6. Define KP & radius parameters in parm file.  Define KP & arc's
#      in macro.
#   7. Define lines and arcs in macro
#   8. Define Model CS at end of parm file
#   9. Subroutine: find_ansys_file(file_name) - Locate an Ansys file in
#      Ansys working directory or ANSYS_MACROLIB path environment variable.
#  10. Subroutine: sq(x) - Cumpute the square of a number
#  11. Subroutine: printg(*HANDLE, "str1", "str2") - Gap output (used to
#      set comments at a specified column position).
#
#--------------------------------------------------------------------------

#-------------------------------------------------------------------------
# 1. File Name Definitions
#-------------------------------------------------------------------------
$MTEMPLATE='macro_template.mac';
$PTEMPLATE='parameter_file_template.parm';

$KLIST='kp_def.lis';
$KCENT='kp_cent.lis';
$LLIST='l_def.lis';

$EPS=1e-5;          # Comparison tolerance to use

$NCOL=29;           # Place comments at column # $NCOL

#-------------------------------------------------------------------------
# 2. Read in the previously created .inf file
#-------------------------------------------------------------------------
# In case Ansys passes the surrounding quotes to as part of the argument,
# strip them off.
$ARGV[0] =~ s/\'//g;

open(INF,"$ARGV[0].inf") || die "Unable to open $ARGV[0].inf: $!";

while (<INF>) {
    s/\015?\012/\n/g;
    chomp;
    %it = (split(/\t+/),%it);       # it = Input Table
}

close(INF);

# Establish coordinate mapping from IGES to desired Ansys coordinates
$it{MAP_X} =~ tr/A-Z/a-z/;              $it{MAP_Y} =~ tr/A-Z/a-z/;
$it{MAP_X} =~ s/\s+//;                  $it{MAP_Y} =~ s/\s+//;
$it{MAP_X} = substr($it{MAP_X},0,1);    $it{MAP_Y} = substr($it{MAP_Y},0,1);

@xyzi=(0,1,2);

if ($it{MAP_X} =~ /[xyz]/ && $it{MAP_Y} =~ /[xyz]/ &&
    $it{MAP_X} ne $it{MAP_Y}) {

    if ($it{MAP_X} eq 'x') {
        @xyz=(1,2);
        @sxyz=('y','z');

    } elsif ($it{MAP_X} eq 'y') {
        @xyz=(0,2);
        @sxyz=('x','z');
        $xyzi[0]=1;

    } else {
        @xyz=(0,1);
        @sxyz=('x','y');
        $xyzi[0]=2;
    }

    if ($it{MAP_Y} eq $sxyz[0]) {
        @xyzi[1,2]=@xyz;
    } else {
        @xyzi[1,2]=@xyz[1,0];
    }
}

# Assign the Parameter Prefix
if ($it{PARM_PRE} ne "BLANK") {
    $P="$it{PARM_PRE}P";
    $R="$it{PARM_PRE}D";
}

#-------------------------------------------------------------------------
# 3. Read in the macro template and fill in the blanks. Output to fname.mac
#-------------------------------------------------------------------------
$f_mac_template=find_ansys_file($MTEMPLATE);

open(IN,"$f_mac_template") || die "Unable to open $f_mac_temp: $!";

if ( $it{"FNAME"} ) {
    $it{"FNAME"} =~ tr/A-Z/a-z/;        # Must be lc for UNIX ANSYS
    open(OUT,">$it{\"FNAME\"}.mac") ||
        die "Unable to open macro file $it{FNAME}.mac: $!";
} else {
    die "The macro file name was not specified!";
}

$search_str = "TITLE:";

while (<IN>) {

    s/\015?\012/\n/g;                           # Fix CRLF's

    if ($search_str eq "TITLE:") {
        if (/$search_str/) {
            s/macro_template/$it{"FNAME"}/;
            $it{"CATEGORY"} =~ tr/a-z/A-Z/;     # Use JR uc standard
            s/TEMPLATE/$it{"CATEGORY"}/;
            $search_str = "Rev -";
        }
    }

    if ($search_str eq "Rev -") {
        if (/$search_str/) {
            s#XX/XX/XXXX#$it{"DATE"}#;
            s/X\. XXXXX/$it{"AUTHOR"}/;
            $search_str = "description";
        }
    }

    if ($search_str eq "description") {
        if (/XXXXXXXXXXX+/) {
            $search_str = "CSXXX";
            if ( -f "$ARGV[0].des.inf" ) {
                open(DES,"$ARGV[0].des.inf") ||
                    die "Unable to open $ARGV[0].des.inf: $!";

                while (<DES>) {
                    s/\015?\012//g;         # Remove CRLF's
                    print OUT "!\t$_\n";
                }
                close(DES);
                print OUT "!\n";
                next;
            }
        }
    }

    if ($search_str eq "CSXXX") {
        if (/$search_str/) {
            s/XXX/$it{"CSNAME"}/;
            s/XXXXX/$it{"CSDESCRIPTION"}/;

            if (/CS.*2/) {
                $search_str = "X.parm";
            }
        }
    }

    if ($search_str eq "X.parm") {
        if (/$search_str/) {
            $_ = "$it{FNAME}.parm\n";
            $search_str = "Solid Model >>>";
        }
    }

    if ($search_str eq "Solid Model >>>") {
        if (/$search_str/) {
            print OUT ;
            print OUT "!\n\n";
            last;
        }
    }

    print OUT;
}

close(IN);      # Close macto_template.mac
close(OUT);     # Close fname.mac

#-------------------------------------------------------------------------
# 4. Read in the parm template and fill in the blanks. Output to fname.parm
#-------------------------------------------------------------------------
$f_parm_temp=find_ansys_file($PTEMPLATE);

open(IN,"$f_parm_temp") || die "Unable to open $f_parm_temp: $!";

open(OUT,">$it{FNAME}.parm") ||
        die "Unable to open macro file $ARGV[0].parm: $!";

$search_str = "TITLE:";

while (<IN>) {

    s/\015?\012/\n/g;                           # Fix CRLF's

    if ($search_str eq "TITLE:") {
        if (/$search_str/) {
            s/parameter_file_template/$it{"FNAME"}/;
            s/TEMPLATE/$it{"CATEGORY"}/;
            $search_str = "Rev -";
        }
    }

    if ($search_str eq "Rev -") {
        if (/$search_str/) {
            s#XX/XX/XXXX#$it{"DATE"}#;
            s/X\. XXXXX/$it{"AUTHOR"}/;
            $search_str = "description";
        }
    }

    if ($search_str eq "description") {
        if (/XXXXXXXXXXXXX+/) {
            $search_str = "/title";
            if ( -f "$ARGV[0].des.inf" ) {
                open(DES,"$ARGV[0].des.inf") ||
                    die "Unable to open $ARGV[0].des.inf: $!";

                while (<DES>) {
                    s/\015?\012//g;         # Remove CRLF's
                    print OUT "!\t$_\n";
                }
                close(DES);
                print OUT "!\n";
                next;
            }
        }
    }

    if ($search_str eq "/title") {
        if (/$search_str/) {
            s/X+/$it{"TITLE"}/;
            $search_str = "/units";
        }
    }

    if ($search_str eq "/units") {
        if (/$search_str/) {
            $_ = "/units,$it{UNITS}\n";
            $search_str = "name=";
        }
    }

    if ($search_str eq "name=") {
        if (/$search_str/) {
            s/XX+/$it{"DBNAME"}/;
            $search_str = "arry_nam";
        }
    }

    if ($search_str eq "arry_nam") {
        if (/$search_str/) {
            s/XX+/$it{"ARRY_NAME"}/;
            $search_str = "CSXXX";
        }
    }

    if ($search_str eq "CSXXX") {
        if (/$search_str/) {
            s/XX+/$it{"CSNAME"}/;

            if (/CS.*2/) {
                $search_str = "mat_select";
            }
        }
    }

    if ($search_str eq "mat_select") {
        if (/$search_str/) {

            print OUT "! Material Properties\n";
            $_ = "mat_select";

            @mat_str = qw(VVV WWW XXX YYY ZZZ);

            for ($i=1; $i <=5; $i++) {
                if ($it{"MAT$i"} eq "BLANK") {
                    #s/,$mat_str[$i-1]//;
                } else {
                    #s/$mat_str[$i-1]/'$it{"MAT$i"}'/;
                    $_ = "$_,\'$it{\"MAT$i\"}\'";
                }
            }
            $_ = "$_\n";
            $search_str = "ET,";
        }
    }

    if ($search_str eq "ET,") {
        if (/$search_str/) {
            if ($it{"ET_NUM1"} ne 'BLANK' &&
                $it{"ET_NAME1"} ne 'BLANK') {

                    s/X.*X/$it{"ET_NUM1"},$it{"ET_NAME1"}/;
                    print OUT ;

            } else {
                print OUT "!$_";
            }

            if ($it{"ET_NUM2"} ne 'BLANK' &&
                $it{"ET_NAME2"} ne 'BLANK') {

                print OUT "ET,$it{'ET_NUM2'},$it{'ET_NAME2'}\n";

            } else {
                print OUT "!ET,XX,XXXXX\n";
            }

            print OUT "!\n!--------------------------- e.) Model Parameters --------------------------\n";

            last;
        }
    }

    print OUT;
}

close(IN);      # Close parameter_file_template.mac
close(OUT);     # Close fname.parm

#-------------------------------------------------------------------------
# 5. Fill in contents of Macro with data from the output files.
#-------------------------------------------------------------------------

#-------------------------------------------------------------------------
# 5.1 Read in the list of circle centers into memory
#-------------------------------------------------------------------------
open(IN, "$KCENT") || die "Unable to open circle center KP list: $!";

while (<IN>) {

    s/\015?\012//g;             # Remove CRLF's

    if (/^\s*\d/) {
        # Reformat the line to make sure it's space delimited
        # and delete THXY,THYZ,THZX ANGLES

        s/(.{8})(.{14})(.{14})(.{14}).*/$1 $2 $3 $4/;
        s/^\s+//;                   # Remove leading whitespace
        @cols[0,1+$xyzi[0],1+$xyzi[1],1+$xyzi[2]] = split(/\s+/);
        push(@cent_kp, $cols[0]);
        push(@cent_x,  $cols[1]);
        push(@cent_y,  $cols[2]);
        push(@cent_z,  $cols[3]);
    }
}

close(IN);

#-------------------------------------------------------------------------
# 5.2 Store coordinates of arc endpoints in a hash of lists
# in "end_point_kp"
#-------------------------------------------------------------------------
open(IN, "$LLIST") || die "Unable to open Line list: $!";

# First get a sorted list of endpoint KP numbers
while (<IN>) {

    s/\015?\012//g;             # Remove CRLF's

    if (/^\s*\d/) {
        s/^\s+//;
        @cols = split(/\s+/);

        if ($cols[3] != 0.0) {
            push(@tmp_kp,$cols[1],$cols[2]);
        }
    }
}

close(IN);

# Do a numeric sort and eliminate duplicate KP's
@tmp_kp = sort {$a <=> $b} @tmp_kp;

@end_point_kp=$tmp_kp[0];

for ($i=1; $i <= $#tmp_kp ; $i++) {
    if ($end_point_kp[-1] != $tmp_kp[$i]) {
        push(@end_point_kp, $tmp_kp[$i]);
    }
}

# Next get the coordinates of each keypoint and store it all in a hash
open(IN, "$KLIST") || die "Unable to open KP list: $!";

$i = 0;         # Index into @end_point_kp

while (<IN>) {

    s/\015?\012//g;             # Remove CRLF's

    if (/^\s*\d/) {

        # Reformat the line to make sure it's space delimited
        # and delete THXY,THYZ,THZX ANGLES
        s/(.{8})(.{14})(.{14})(.{14}).*/$1 $2 $3 $4/;
        s/^\s+//;                   # Remove leading whitespace
        @cols[0,1+$xyzi[0],1+$xyzi[1],1+$xyzi[2]] = split(/\s+/);

        if ( $cols[0] == $end_point_kp[$i] ) {
            $end_point{$cols[0]} = [ @cols[1,2,3] ];
            $i++;
        }
    }
}

close(IN);

#-------------------------------------------------------------------------
# 6. Define KP's in parm file and macro
#    Also define radius parameters in parm file
#-------------------------------------------------------------------------
open(IN, "$KLIST") || die "Unable to open KP list: $!";

open(MAC,">>$it{\"FNAME\"}.mac") ||
    die "Unable to open macro file $ARGV[0].mac: $!";

open(PARM,">$it{\"FNAME\"}.parm.tmp") ||
    die "Unable to open macro file $ARGV[0].parm.tmp: $!";

print MAC "!\n! Keypoint Definitions from $it{\"FNAME\"}.parm\n!\n\n";
print PARM "\n!\n! Keypoint Parameter Definitions\n!\n\n";

$i = 1;             # Increment variable for parameter names

while (<IN>) {

    s/\015?\012//g;             # Remove CRLF's

    if (/^\s*\d/) {

        # Manipulate lines of the form:  I8,3G14.X,stuff

        # Reformat the line to make sure it's space delimited
        # and delete THXY,THYZ,THZX ANGLES
        s/(.{8})(.{14})(.{14})(.{14}).*/$1 $2 $3 $4/;
        s/^\s+//;                   # Remove leading whitespace
        ($col_kp,@cols[$xyzi[0],$xyzi[1],$xyzi[2]]) = split(/\s+/);

        # Define KP parameters in PARM file
        # Perform parameter substitution on reoccuring numbers
        # for each coordinate direction.

        if ($coord_x{"$cols[0]"}) {
            $x = $coord_x{"$cols[0]"};
        } else {
            $x = $cols[0];
            $coord_x{"$cols[0]"} = "${P}x$i"
        }

        if ($coord_y{"$cols[1]"}) {
            $y = $coord_y{"$cols[1]"};
        } else {
            $y = $cols[1];
            $coord_y{"$cols[1]"} = "${P}y$i"
        }

        if ($coord_z{"$cols[2]"}) {
            $z = $coord_z{"$cols[2]"};
        } else {
            $z = $cols[2];
            $coord_z{"$cols[2]"} = "${P}z$i"
        }

        print PARM "${P}x$i=$x\n${P}y$i=$y\n${P}z$i=$z\n\n";

        printg(*MAC, "k,km+$col_kp,${P}x$i,${P}y$i,${P}z$i", "! km + $col_kp");

        # Flag arc center KP's
        if ($col_kp >= $cent_kp[0] && $col_kp <= $cent_kp[-1]) {
            foreach $kp (@cent_kp) {
                if ( $kp == $col_kp ) {
                    print MAC " (center)";
                    last;
                }
            }
        }

        print MAC "\n";
        $i++;
    }
}

close(IN);      # Close kp_def.lis
close(PARM);    # Close .parm.tmp file

#-------------------------------------------------------------------------
# 7. Define lines and arcs in macro
#-------------------------------------------------------------------------
open(IN, "$LLIST") || die "Unable to open Line list: $!";

open(PARM,">>$it{\"FNAME\"}.parm") ||
    die "Unable to open macro file $ARGV[0].parm: $!";

print MAC "\n!\n! Line Definitions\n!\n\n";

print PARM << "END";
!
! Radius Dimension Parameters
!
! Refer to tools/README.getiges for help on changing radius
! parameter values.
!

END

$r = 1;             # Parameter index for radii def's in PARM file

while (<IN>) {

    s/\015?\012/\n/g;               # Fix CRLF's

    if (/^\s*\d/) {

        # Manipulate lines of the form:
        #    NO.     KEYPOINTS     RADIUS
        #     1       1     2    0.0000

        s/^\s+//;               # Remove any leading whitespace
        @cols = split(/\s+/);

        if ( $cols[3] == 0.0 ) {
            printg(*MAC,"L,km+$cols[1],km+$cols[2]","! lm + $cols[0]\n");
        } else {
            $found_center=0;
            for ($i=0; $i<=$#cent_kp; $i++) {
                $ep1=$cols[1];
                $ep2=$cols[2];

                $dist1 = sqrt(
                    sq($cent_x[$i] - $end_point{$ep1}[0]) +
                    sq($cent_y[$i] - $end_point{$ep1}[1]) +
                    sq($cent_z[$i] - $end_point{$ep1}[2])
                );

                $dist2 = sqrt(
                    sq($cent_x[$i] - $end_point{$ep2}[0]) +
                    sq($cent_y[$i] - $end_point{$ep2}[1]) +
                    sq($cent_z[$i] - $end_point{$ep2}[2])
                );

                if ( $EPS >= abs($cols[3]-$dist1) &&
                     $EPS >= abs($cols[3]-$dist2)) {

                    # Write radius parameters to parm file

                    if ($coord_rad{"$cols[3]"}) {
                        $rv = $coord_rad{"$cols[3]"};
                    } else {
                        $rv = $cols[3];
                        $coord_rad{"$cols[3]"} = "${R}r$r"
                    }

                    printg(*PARM,"${R}r$r=$rv","! Used for lm + $cols[0]\n");

                    printg(*MAC,"larc,km+$ep1,km+$ep2,km+$cent_kp[$i],${R}r$r","! lm + $cols[0]\n");
                    $r++;
                    $found_center=1;
                    last;
                }
            }
            if ($found_center == 0) {
                print MAC "! *** Unable to find center of arc: LINE# = $cols[0]\n";
            }
        }
    }
}

print MAC << 'END';

! Turn on KP and line numbers & switch to front view.
/pnum,kp,1
/pnum,line,1
/view,1,,,1
/ang, 1
/rep,fast
lplot

END

close(IN);
close(MAC);

open(IN,"$it{\"FNAME\"}.parm.tmp") ||
    die "Unable to open macro file $ARGV[0].parm.tmp: $!";

while (<IN>) {          # Copy contents of .parm.temp file to .parm file

    s/\015?\012/\n/g;               # Fix CRLF's

    print PARM ;
}

#-------------------------------------------------------------------------
# 8. Define model CS at end of parm file
#-------------------------------------------------------------------------

@csdef = split(/,/,$it{MOD_COORD_SYS});

print PARM << "END";

!
!------------------------ f.) Model C.S. Coordinates -----------------------
!
acs=$csdef[0]                           ! active coordinate system
!
xc=$csdef[1]                            ! x coordinate center
yc=$csdef[2]                            ! y coordinate center
zc=$csdef[3]                            ! z coordinate center
!
rotxyc=$csdef[4]                        ! xy rotation
rotyzc=$csdef[5]                        ! yz rotation
rotzxc=$csdef[6]                        ! zx rotation
!
!---------------------------------------------------------------------------

END

close(IN);
close(PARM);

unlink "$it{\"FNAME\"}.parm.tmp";

print "*** $it{\"FNAME\"}.mac and .parm files written to Ansys working directory.\n";

### End of main program

#-------------------------------------------------------------------------
# 9. Subroutine to locate an Ansys file.
#
#  Usage:  find_ansys_file(file_name)
#-------------------------------------------------------------------------
sub find_ansys_file {

# See if the file is in the current directory
if ( -f $_[0] ) {
    return $_[0];
}

# Check in the ANSYS_MACROLIB envirnoment variable if there is one
if ($ENV{"ANSYS_MACROLIB"}) {

    $_ = $ENV{"ANSYS_MACROLIB"};

    # This is needed to run from the Cygwin bash shell (not from Ansys)
    if ($ENV{"OSTYPE"} eq "cygwin") {
        s#(.):\\#//$1/#g;
        s#(.):#//$1#g;
        s#\\#/#g;
    }

    if ( /;/ ) {
        @am_path = split(/;/,$_);       # Parse DOS format string
    } else {
        @am_path = split(/:/,$_);       # Parse UNIX format string
    }

    # Look for the file in the MACRO LIB path
    foreach (@am_path) {
        if ( -f "$_/$_[0]") {
            return "$_/$_[0]";
        }
    }
}

die "Unable to find $_[0]\n";

}  ### End of find_ansys_file.

#-------------------------------------------------------------------------
# 10. Compute the square of a number
#-------------------------------------------------------------------------
sub sq {
    return $_[0] * $_[0];
}

#-------------------------------------------------------------------------
# 11. Print two strings with a gap between them
#
# This subroutine will output the columns such that they will be lined up
#
# Usage: printg(*file_handle, "str1", "str2");
#
# Place str2 at column number $NCOL
#-------------------------------------------------------------------------
sub printg {

local (*G) = @_;

print G "$_[1]", ' ' x ($NCOL - length $_[1]), "$_[2]";

}

# ---- *INF DEFINITION* --------------------------------------------------
#
# The following key/value pairs must be defined
# in any order (various values are shown as examples):
#
# FNAME sub_shaft
# CATEGORY  AAAV
# DATE  02/16/2001
# AUTHOR    D. Edwards
# CSNAME    STB
# ASSEMBLE  BLANK
# FIRST_MDL BLANK
# MAP_X X
# MAP_Y Y
# MOD_COORD_SYS ctstbcs,0,0,0,0,0,0
# CSDESCRIPTION Primary
# TITLE Stub Shaft - Configuration C
# UNITS bin
# MAT1  al6061
# MAT2  BLANK
# MAT3  BLANK
# MAT4  BLANK
# MAT5  BLANK
# ET_NUM1   1
# ET_NAME1  SOLID45
# ET_NUM2   2
# ET_NAME2  SHELL63
# DBNAME    stat068
# ARRY_NAME stt68
# PARM_PRE  BLANK


w:\ansys\mac\tools\mkmac.mac.html

!
!       TITLE:  mkmac.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!               Rev -     02/28/2001    D. Edwards
!               Rev A     04/13/2001    D. Edwards
!                 Operate on the selected line set instead of all
!                 lines and KP's in the database.
!---------------------------------------------------------------------------
!
! Make a new macro from the currently selected set of lines.
!
! Macro information is obtained through prompting in the Ansys Output
! window.  All the information to fill in the macro template and parm
! template files is prompted for.
!
! The resulting macro is written to the Ansys working directory.
!
! Keypoints are created at the center of each arc, if there are any.
!
!  NOTE:  This macro requires perl to be installed on the computer.
!         See ansys/tools/README.perl for more information.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! USAGE:  mkmac,'fname'
!         mkmac                  (All prompted input)
!
!   where fname = base file name (w/o extension) of temporary
!                 files to create while making the macro.
!
!------------------------------ Examples -----------------------------------
!
! Prompt for information needed to fill in the new macro and store it
! in flange.inf.
!
!   getiges 'flange'
!
! Running the command again will use the contents of flange.inf rather than
! prompt for all the same information again.  Any changes to the information
! is accomplished by editing flange.inf before rerunning the getiges macro.
!
!---------------------- List of Dependencies ------------------------------
!
!   mkmac.mac
!       tools/getinfo.pl
!       tools/mkmac.pl
!           tools/macro_template.mac
!           tools/parameter_file_template.parm
!           fname.inf
!           fname.des.inf  (optional)
!           kp_def.lis
!           kp_cent.lis
!           l_def.lis
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

! Prompt for base name if not given on command line
fname_=arg1
*get,ptype_,parm,fname_,type
*if,ptype_,eq,3,then
    fname_=arg1
*else
    *ask,fname_,Enter the base name of the .igs file:,'new_mac'
*endif

fini

/prep7

ksll,s

! This is optional and can be commented out without causing problems
numcmp,all

! Create a KP at the center of each arc
*get,lmin_,LINE,0,num,min
*get,lmax_,LINE,0,num,max

*do,i_,lmin_,lmax_
  *if,lsel(i_),eq,1,then
    *get,len_,LINE,i_,leng
    *get,kp1_,LINE,i_,kp,1
    *get,kp2_,LINE,i_,kp,2

    *if,len_,gt,distkp(kp1_,kp2_),then
      kcenter,line,i_
    *endif

  *endif
*enddo

! Generate KP listing
/out,kp_def,lis
klist,all,,,coord
/out

! Generate LINE listing
/out,l_def,lis
llist,,,,radius
/out

! Generate list of KP's at arc centers
ksll,u
/out,kp_cent,lis
klist,all,,,coord
/out

/pnum,kp,1
/pnum,line,1
lplot

! Generate an Ansys macro from the KP and line information
/syp,getinfo.pl,fname_
/syp,mkmac.pl,fname_

!
! Debugging lines (normally commented out)
!

! See which perl is in use
!/sys,perl -v

! Work
!/sys,perl -d e:\sl\ansys\dee\getinfo.pl test1

! Home
!/sys,perl -d j:\eng\ansys\dee\getinfo.pl 'test1'
!/sys,perl -d j:\eng\ansys\dee\mkmac\mkmac.pl 'fred'


w:\ansys\mac\tools\getinfo.pl.html

#!/usr/local/bin/perl
#
#   TITLE:  getinfo.pl (MANAGEMENT)
#
#---------------------------------------------------------------------------
#       Rev -   2/25/2001   D. Edwards <dee.engineering@usa.net>
#       Rev A   05/09/2001  D. Edwards
#               Added capability to map x, y and z coordinates to
#               any other combination of coordinates.
#       Rev B   06/08/01        D. Edwards
#               Updated to work with revised templates.
#---------------------------------------------------------------------------
#
# Collect information needed by mkmac.pl
#
# NOTE: This version is for those that prefer a simple shell prompt.
#       The information is obtained with <STDIN> through the Ansys
#       Output Window which is really just a DOS box..
#
#------------------------------ COMMAND SYNTAX -----------------------------
#
# getinfo.pl file_name
#
#   file_name   = The base name of the file to store the information in.
#
#---------------------------------------------------------------------------

# In case Ansys passes the surrounding quotes to as part of the argument,
# strip them off.
$ARGV[0] =~ s/\'//g;

#
# If file_name exsits, just exit and use the exsisting file.
#
if ( -f "$ARGV[0].inf") {
    exit 0;
}

#
# Open output file
#
open(OUT,">$ARGV[0].inf") || die "Unable to open $ARGV[0].inf: $!";

# Use the current date as default value
use POSIX qw(strftime);
$now = strftime "%m/%d/%Y", localtime;

$cygwin_root = find_cygwin();

# Try to get the default author
if ($ENV{USER}) {
    $user=$ENV{USER};
} else {
    $user=$ENV{USERNAME};
}

if ($user && $cygwin_root ne "NOT_FOUND" ) {

    if (open(PW, "$cygwin_root/etc/passwd")) {
        while (<PW>) {
            if (/^$user:/i) {
                @pw_list = split(/:/);
                $author = $pw_list[4];
                $author =~ s/^(\w)\w* +/$1\. /;
                $author =~ s/,.*//;
                last;
            }
        }
        close(PW);
    }
}

# Create a keyed hash of default values and prompt strings

%info = (
    FNAME           => [ 1,"$ARGV[0]", "Base name of macro to create" ],
    CATEGORY        => [ 2,"", "Category" ],
    DATE            => [ 3,"$now", "Macro date [dd/mm/yy]" ],
    AUTHOR          => [ 4,"$author", "Macro maintainer [X. XXXXX]" ],
    CSNAME          => [ 5,"_", "Model coordinate base name [XXX]" ],
    MAP_X           => [ 6,"x", "Map x-coordinates to [x,y,z]" ],
    MAP_Y           => [ 7,"y", "Map y-coordinates to [x,y,z]" ],
    MOD_COORD_SYS   => [ 8,"", "MOD_COORD_SYS arguments [acs,xc,yc,zc,rotxy,rotyz,rotzx]\n" ],
    CSDESCRIPTION   => [ 9,"", "Coordinate system description [A20]" ],
    TITLE           => [ 10,"", "Ansys /TITLE [A50]" ],
    UNITS           => [ 11,"bin", "Units [see Ansys manual]" ],
    MAT1            => [ 12,"", "Material library #1 [See MAT_SELECT]" ],
    MAT2            => [ 13,"", "Material library #2 [See MAT_SELECT]" ],
    MAT3            => [ 14,"", "Material library #3 [See MAT_SELECT]" ],
    MAT4            => [ 15,"", "Material library #4 [See MAT_SELECT]" ],
    MAT5            => [ 16,"", "Material library #5 [See MAT_SELECT]" ],
    ET_NUM1         => [ 17,"1", "First element type number [I4]" ],
    ET_NAME1        => [ 18,"SHELL63", "First element type name [See Ansys manual]" ],
    ET_NUM2         => [ 19,"2", "Second element type number" ],
    ET_NAME2        => [ 20,"SOLID45", "Second element type name [See Ansys manual]" ],
    DBNAME          => [ 21,"", "Database name [A8]" ],
    ARRY_NAME       => [ 22,"", "Array name [A5]" ],
    PARM_PRE        => [ 23,"", "Parameter name prefixes [A2]" ]
);

print << 'END';

*********************************************************************

Enter in the following prompted information.

Field width and type is indicated with FORTRAN style format specifiers and
are listed in < > brackets.

Default values are listed in [ ] brackets.

*********************************************************************

END

foreach $key ( sort { $info{$a}[0] <=> $info{$b}[0] } keys %info ) {

    print OUT "$key\t";

    # Don't prompt for remaining material names if flag is set.
    if ($f_MAT && $key =~ /MAT\d/) {
        print OUT "BLANK\n";
        next;
    }

    # Prompt for user input
    print "$info{\"$key\"}[2] [$info{\"$key\"}[1]]: ";
    $key_value = <STDIN>;
    chomp($key_value);

    $key_value =~ s/\t/ /g;     # Strip out any tabs

    # Handle condition when user just presses enter.
    if (! $key_value) {
        if ($info{"$key"}[1]) {
            $key_value = $info{"$key"}[1];
        } else {
            $key_value = "BLANK";
        }
    }

    print OUT "$key_value\n";

    # Handle special case prompting
    # Set default CS for mod_coord_system
    if ($key eq "CSNAME") {
        $info{MOD_COORD_SYS}[1]="CS${key_value}0,0,0,0,0,0,0";
    }

    # After 1st blank material name, quit prompting
    if ($key =~ /MAT\d/) {
        if ($key_value eq "BLANK") {
            $f_MAT = 1;
        }
    }

}

close(OUT);

#
# Open description output file
#
open(OUT,">$ARGV[0].des.inf") || die "Unable to open $ARGV[0].des.inf: $!";

print "\nEnter the macro description (type \"end\" on a line by itself";
print "\nto finish entering the description):\n\n";

while (1) {
    $line = <STDIN>;

    $line =~ s/\015?\012//g;                # Remove CRLF's

    if ("end" eq $line) {
        last;
    }

    print OUT "$line\n";
}

close(OUT);

if (-z "$ARGV[0].des.inf") {
    unlink "$ARGV[0].des.inf";
}

#-------------------- End of Main Program --------------------------------

#-------------------------------------------------------------------------
# Subroutine to locate cygwin root path.
#
#  Usage:  scalar = find_cygwin()
#-------------------------------------------------------------------------
sub find_cygwin {

# Just use "" if we are running under Cygwin or Solaris
if ($ENV{"OSTYPE"} =~ /cygwin|solaris/i) {
    return "";
}

# Check in the PATH envirnoment variable if there is one
if ($ENV{"PATH"}) {

    $_ = $ENV{"PATH"};

    print;

    if ( /;/ ) {
        @am_path = split(/;/,$_);       # Parse DOS format string
    } else {
        return "";                      # Assume UNIX or Cygwin is working
        #@am_path = split(/:/,$_);      # Parse UNIX format string
    }

    # Look for "cygwin" in each path

    foreach (@am_path) {
        if (/cygwin/i) {
            s/cygwin.*/cygwin/i;
            return $_;
        }
    }
}

return "NOT_FOUND";

}  ### End of find_cygwin


w:\ansys\mac\tools\profile_coords.mac.html

!   TITLE:  profile_coords.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/09/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates an output file of keypoint coordinates of a selected
!   set of lines.
!
!
!   COMMAND SYNTAX:
!
!                        (1)   (2)    (3)   (4)
!        PROFILE_COORDS, cs, strt_kp, prec, prm
!
!
!   ARGUMENTS:
!
!       (1) cs = the coordinate system number to measure KP coordinates relative
!                to. If desired C.S. is the active C.S., then simply input:
!
!                                       cs = 'a'
!
!       (2) strt_kp = the 1st keypoint in the line profile to begin tabulation
!                     of coordinates.
!
!       (3) prec = the desired decimal precision of the coordinates. Must be
!                  an integer value of 1 through 8.  If left blank, defaults
!                  to 3.
!
!       (4) prm = create keypoint structured file or parameter structured file.
!
!                   0 (or blank) = keypoint structured file
!                   1 = parameter structured file
!
!
!   DESCRIPTION:
!
!   Each line in the selected set must be connected in a continuous chain. The
!   line set may be open-ended or may form a closed loop.  However, the line
!   set cannot have any branching keypoints.
!
!   The coordinate system may be any type.  Whatever type the C.S., the X, Y
!   and Z components correspond to that ype of coordinate (e.g., X,Y,Z are
!   X,Y,Z in cartesian; X,Y,Z are R, THETA, Z in cylindrical; etc.) If the
!   active C.S. is desired, then the 1st argument is the character scalar 'a'.
!
!   The coordinates are full-precision real numbers.  A desired decimal may
!   be specified for argument 3, 'prec', and must be an integer value of 1
!   through 8. If this argument is left blank, the precision defaults to 3
!   decimal places of accuracy.
!
!   The output file has the following name:     pf_coord.mac
!
!   This file has 2 options for output:
!
!           1.) keypoint (numbered) structure file. This sets the numerical
!               value of the coordinates in the keypoint command, allowing
!               for cut-and-paste useage.
!
!           2.) parameter structured file. This creates the parameters for
!               the dimensions of each point in a profile, and the keypoint
!               commands in parameter form.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

csnum_=arg1
skp_=arg2
prec_=arg3
prm_=arg4
!
*get,acs1_,active,,csys
!
*get,ptyp_,parm,csnum_,type
!
*if,ptyp_,eq,3,then
    *if,csnum_,eq,'a',then
        csnum_=acs1_
    *else
        csnum_=0
    *endif
*endif
!
*if,prec_,eq,0,then
    prec_=3
*endif
!
cm,lnset_,line
*get,numlns_,line,,count
ksll,s
*get,kpcnt_,kp,,count
!
tol_=10**(-(prec_+1))
!
csys,csnum_
!
!------------------------- Create Coordinate File -------------------------
!
/output,pf_coord,mac
!
*msg,info

/output
*if,prm_,eq,0,then
    /output,pf_coord,mac,,append
!----------------------------------------------
*msg,info,%csnum_%
Keypoint Coordinates Measured From:  C.S. = %i
!----------------------------------------------
    /output
*elseif,prm_,eq,1,then
    /output,pf_coord,mac,,append
!--------------------------------------------------------
*msg,info,%csnum_%
Keypoint Coordinate Parameters Measured From:  C.S. = %i
!--------------------------------------------------------
    /output
*endif
!
/output,pf_coord,mac,,append
!
*msg,info

*msg,info
KP#     X       Y       Z
!
*msg,info

/output
!
*set,kp_1st_,
!
*do,aaa_,1,numlns_,1
    ksel,s,kp,,skp_
    !
    dx__=kx(skp_)
    !
    *if,abs(dx__),lt,tol_,then
        dx__=0
    *else
        round_num,dx__,prec_
        dx__=num_
    *endif
    !
    dy__=ky(skp_)
    !
    *if,abs(dy__),lt,tol_,then
        dy__=0
    *else
        round_num,dy__,prec_
        dy__=num_
    *endif
    !
    dz__=kz(skp_)
    !
    *if,abs(dz__),lt,tol_,then
        dz__=0
    *else
        round_num,dz__,prec_
        dz__=num_
    *endif
    !
    *if,skp_,ne,kp_1st_,then
        *if,prm_,eq,0,then
            /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_,%dx__%,%dy__%,%dz__%
%i ---  k,,%g, %g, %g
!------------------------------------
            /output
        *elseif,prm_,eq,1,then
            /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_
Keypoint # %i
*msg,info,%dx__%
Dx0 =%g
*msg,info,%dy__%
Dy0 =%g
*msg,info,%dz__%
Dz0 =%g
*msg,info
!
!------------------------------------
            /output
        *endif
    *endif
    !
    ln_skip=mod(aaa_,5)
    !
    *if,ln_skip,eq,0,then
        *if,aaa_,ne,1,then
            /output,pf_coord,mac,,append
!----------------------------------------------------------------
*msg,info
!
!----------------------------------------------------------------
            /output
        *endif
    *endif
    !
    cmsel,s,lnset_
    lslk,r,0
    !
    *if,aaa_,eq,1,then
        kp_1st_=skp_
        get_max_entity
        prfln_=lm
    *else
        lsel,u,line,,prfln_
        get_max_entity
        prfln_=lm
    *endif
    !
    *get,kp11_,line,prfln_,kp,1
    *get,kp12_,line,prfln_,kp,2
    !
    *if,skp_,eq,kp11_,then
        juncpt_=kp12_
    *else
        juncpt_=kp11_
    *endif
    !
    skp_=juncpt_
    !
    *set,juncpt_
    !
    *if,aaa_,eq,numlns_,then
        *if,skp_,ne,kp_1st_,then
            !
            dx__=kx(skp_)
            !
            *if,abs(dx__),lt,tol_,then
                dx__=0
            *else
                round_num,dx__,prec_
                dx__=num_
            *endif
            !
            dy__=ky(skp_)
            !
            *if,abs(dy__),lt,tol_,then
                dy__=0
            *else
                round_num,dy__,prec_
                dy__=num_
            *endif
            !
            dz__=kz(skp_)
            !
            *if,abs(dz__),lt,tol_,then
                dz__=0
            *else
                round_num,dz__,prec_
                dz__=num_
            *endif
            !
            *if,prm_,eq,0,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_,%dx__%,%dy__%,%dz__%
%i ---  k,,%g, %g, %g
!------------------------------------
                /output
            *elseif,prm_,eq,1,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_
Keypoint # %i
*msg,info,%dx__%
Dx0 =%g
*msg,info,%dy__%
Dy0 =%g
*msg,info,%dz__%
Dz0 =%g
*msg,info
!
!------------------------------------
                /output
            *endif
        *endif
    *endif
*enddo
!
init_entity_num
!
*if,prm_,eq,1,then
    /output,pf_coord,mac,,append
!------------------------------------
*msg,info
!
!------------------------------------
    /output
    !
    *do,aaa_,1,kpcnt_,1
        /output,pf_coord,mac,,append
!------------------------------------
*msg,info
k,,Dx0 ,Dy0 ,Dz0
!------------------------------------
        /output
        !
        ln_skip=mod(aaa_,5)
        !
        *if,ln_skip,eq,0,then
            *if,aaa_,ne,1,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info
!
!------------------------------------
                /output
            *endif
        *endif
        !
    *enddo
*endif
!
cmsel,s,lnset_
!
csys,acs1_
!
lplot
!
!-------------------------------------------------------------------------
!
!
*set,csnum_,
*set,acs1_,
*set,skp_,
*set,prfln_,
*set,juncpt_,
*set,aaa_,
*set,kp11_,
*set,kp12_,
*set,kp_1st_,
*set,dx__,
*set,dy__,
*set,dz__,
*set,ptyp_,
*set,num_,
*set,tol_,
*set,prec_,
*set,numlns_,
*set,prm_,
*set,ln_skip,
*set,kpcnt_,
cmdele,lnset_


w:\ansys\mac\tools\angle_line.mac.html

!   TITLE:  angle_line.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/16/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a line at a specified angle from a user specified line.
!
!
!   COMMAND SYNTAX:
!
!                     (1)    (2)     (3)    (4)   (5)   (6)    (7)
!        ANGLE_LINE, plncs, line#, kp_end, angle, dist, side, sfact
!
!
!   ARGUMENTS:
!
!       (1) plncs = the coordinate system whose XY plane is parallel to
!                   the plane which wiil contain the angled line.
!
!       (2) line# =  number of the original line to construct new angled line
!                    relative to.
!
!       (3) kp_end = the end keypoint of the original line to position the
!                    angled line from.
!
!       (4) angle =  angle of the new line relative to the original line.
!
!       (5) dist =  the perpendicular distance between the end keypoint and
!                   the angled line.
!
!       (6) side = the side of the end keypoint to create the angled line.
!
!                       't' = top
!                       'b' = bottom
!                       'l' = left
!                       'r' = right
!
!               *** NOTE: For vertical and horizontal lines, it is safest to
!                         specify the sides as follows:
!
!                           vertical - left ('l') or right ('r')
!                           horizontal - top ('t') or bottom ('b')
!
!       (7) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The angled line is created in the plane parallel to the XY plane of the
!   coordinate system specified in argument 1, 'plncs'.
!
!   This macro creates the angled line a normal distance 'dist' from
!   the specified end keypoint.  The line is created on the side specified by
!   argument 6.  TOP, BOTTOM, LEFT and RIGHT are relative positions, and
!   are based on the perspective of the user.  This 'perspective' is deter-
!   mined from the plane coordinate system specified in argument 1. From,
!   this coordinate system, TOP is the region in the +Y direction; BOTTOM is
!   the region in the -Y direction; LEFT is the region in the -X direction
!   and RIGHT is the region in the +X direction.  Therefore, the perspective
!   of the user is the XY plane with the +Z axis pointing out of the graphics
!   window.
!
!   The length of the new line is determined by the scaling factor, 'sfact',
!   specified in argument 4.  If left blank, the default value is 2.
!
!   The length of the new line is determined by the following formula:
!
!                       L_new = 2*(L_orig + sfact*(0.10*lnl_))
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered with each endpoint equidistant from the specified
!   end keypoint. Argument 7 allows the user to adjust the resulting length
!   of the new line if desired.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

usangln_=1
!
plncs_=arg1
origln2_=arg2
kpref_=arg3
rotang_=arg4
dist_=arg5
side_=arg6
sfact2_=arg7
!
init_entity_num
!
*if,sfact2_,le,0,then
    sfact2_=2
*endif
!
*get,acs1__,active,,csys
!
*get,plncstyp,cdsy,plncs_,attr,kcs
!
*if,plncstyp,ne,0,then
    create_cs,0,'plncs_',0,0,0,0,0,0,0
*endif
!
!--------------------------- Create Angles Line --------------------------
!
csys,plncs_
!
*get,lnl_,line,origln2_,leng
!
*get,kp11_,line,origln2_,kp,1
*get,kp12_,line,origln2_,kp,2
!
*if,kpref_,eq,kp11_,then
    kpx_=kp12_
*else
    kpx_=kp11_
*endif
!
clocal,csn+5,1,kx(kpref_),ky(kpref_),kz(kpref_),0,0,0
!
kpang_=ky(kpx_)
ang_convert,'kpang_',0
!
clocal,csn+6,0,0,0,0,kpang_,0,0
!
*if,kpang_,le,90,then
    clocal,csn+7,1,0,0,0,rotang_,0,0
*elseif,kpang_,le,180,then
    clocal,csn+7,1,0,0,0,180+rotang_,0,0
*elseif,kpang_,le,270,then
    clocal,csn+7,1,0,0,0,180+rotang_,0,0
*elseif,kpang_,le,360,then
    clocal,csn+7,1,0,0,0,rotang_,0,0
*endif
!
k,,lnl_+(sfact2_*(0.10*lnl_)),180,0
k,,lnl_+(sfact2_*(0.10*lnl_)),0,0
!
create_lines,,1
origln1_=lm
!
parallel_lines,plncs_,side_,dist_,origln1_
!
ldele,origln1_,,,1
!
init_entity_num
!
csdele,csn+5,csn+7,1
!
csys,acs1__
!
lplot
!
!-------------------------------------------------------------------------
!
*set,kpref_,
*set,kpx_,
*set,origln1_,
*set,origln2_,
*set,ptyp2_,
*set,rotang_,
*set,sfact2_,
*set,usangln_,


w:\ansys\mac\tools\angle_line_kp.mac.html

!   TITLE:  angle_line_kp.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/16/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates an angled line relative to a user specified line and
!   passing through a user specified keypoint.
!
!
!   COMMAND SYNTAX:
!
!                        (1)   (2)  (3)    (4)
!        ANGLE_LINE_KP, line#, kp, angle, sfact
!
!
!   ARGUMENTS:
!
!       (1) line# =  number of the original line to construct new angled line
!                    relative to.
!
!       (2) int_kp = the keypoint that the angled line passes thru (intercepts).
!
!       (3) angle =  angle of the new line relative to the original line.
!
!       (4) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The angled line is created in the plane containing the original line
!   and the intercept keypoint, and creates an angle with that original line
!   equal to that specified in argument 4.
!
!   The length of the new line is determined by the scaling factor, 'sfact',
!   specified in argument 4.  If left blank, the default value is 2.
!
!   The length of the new line is determined by the following formula:
!
!                       L_new = 2*(L_orig + sfact*(0.10*lnl_))
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered with each endpoint equidistant from the specified
!   keypoint. Argument 4 allows the user to adjust the resulting length
!   of the new line if desired.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

origln_=arg1
kpint_=arg2
rotang_=arg3
sfact_=arg4
!
init_entity_num
!
*if,sfact_,le,0,then
    sfact_=2
*endif
!
*get,acs1__,active,,csys
!
!--------------------------- Create Angles Line --------------------------
!
*get,lnl_,line,origln_,leng
!
*get,kp1_,line,origln_,kp,1
*get,kp2_,line,origln_,kp,2
!
cskp,csn+5,0,kp1_,kp2_,kpint_
!
clocal,csn+6,1,kx(kpint_),ky(kpint_),kz(kpint_),rotang_,0,0
!
k,,lnl_+(sfact_*(0.10*lnl_)),180,0
k,,lnl_+(sfact_*(0.10*lnl_)),0,0
!
create_lines,,1
!
csdele,csn+5,csn+6,1
!
csys,acs1__
!
lplot
!
!-------------------------------------------------------------------------
!
*set,acs1__,
*set,kpint_,
*set,kp1_,
*set,kp2_,
*set,origln_,
*set,rotang_,
*set,sfact_,
*set,lnl_,


w:\ansys\mac\tools\ara_create_part.mac.html

!   TITLE:  ara_create_part.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    01/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is used to partition a selected set of areas by creating
!   a partition line by position and orientation from a known C.S.
!
!   COMMAND SYNTAX:
!
!                            (1)   (2)       (3)     (4)     (5)
!           ARA_CREATE_PART, acs, ang_ln, dist_pln, x_dist, y_dist
!
!
!   ARGUMENTS:
!
!       (1) acs = the active C.S. located on the areas plane. The XY plane
!                 must be aligned coplanar with the selected areas
!
!       (2) ang_ln = the angle of the cutting line as measured from the
!                    C.S. +x axis.
!
!       (3) dist_ln = the normal distance of the line from the C.S. origin
!                     as measured in the XY plane of the active C.S.
!                     X_DIST and Y_DIST are ignored.
!
!       (4) x_dist = the distance along the x (+ or -) axis the line
!                    intersects as measured in the XY plane of the active
!                    C.S. Y_DIST and DIST_PLN are ignored.
!
!       (5) y_dist = the distance along the x (+ or -) axis the line
!                    intersects as measured in the XY plane of the active
!                    C.S. X_DIST and DIST_PLN are ignored.
!
!
!   DESCRIPTION:
!
!   The cutting line is created at a user specified angle, ANG_PLN, with
!   respect to the +x axis, and is an angle (in degrees) range of:
!
!                           0 < ang_pln < 180
!
!   The distance of the line (DIST_LN) is the magnitude of a vector from the
!   origin oriented normal to the line. Therefore, it is the perpendicular
!   distance of the line from the origin. The line is constructed such that
!   it lies in the XY plane of the active C.S., which is coplanar with the
!   selected area(s).
!
!   The line position may also be specified by the intercept with the X or
!   Y axis.  See the argument descriptions to verify proper useage.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

actcs_=arg1
ang_=arg2
dist_=arg3
xdist_=arg4
ydist_=arg5
!
!
csys,actcs_
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    create_cs,0,'acs_',0,0,0,0,0,0,0    ! create cartesian CS at same location.
*endif
!
cm,aset,area
!
max_enty_dim,'l'
!
lpln_=10*max_leng
!
*if,dist_,eq,0,then
    *if,xdist_,ne,0,then
        flag_=1
        create_cs,0,,1,xdist_,0,0,0,0,0
    *else
        *if,ydist_,ne,0,then
            flag_=1
            create_cs,0,,1,0,ydist_,0,0,0,0
        *endif
    *endif
*endif
!
*if,dist_,lt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_-90)*rconv)
        y_=abs(dist_)*sin((ang_-90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_-90)*rconv)
        y_=-abs(dist_)*sin((ang_-90)*rconv)
    *endif
*elseif,dist_,gt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_+90)*rconv)
        y_=abs(dist_)*sin((ang_+90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_+90)*rconv)
        y_=-abs(dist_)*sin((ang_+90)*rconv)
    *endif
*else
    *if,flag_,ne,1,then
        xdist_=0
        ydist_=0
        x_=0
        y_=0
    *endif
*endif
!
*if,flag_,ne,1,then
    create_cs,0,,1,x_,y_,0,0,0,0
*endif
!
k,,lpln_,ang_,0
k,,-lpln_,ang_,0
!
create_lines,,1
!
_lcut=lm
!
cmsel,s,aset
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*do,_iii,_alow,_ahigh,1
    *if,_alow,eq,_ahigh,then
        _kdv='delete'
    *else
        *if,_iii,ne,_ahigh,then
            _kdv='keep'             ! keep/delete decision variable
        *else
            _kdv='delete'
        *endif
    *endif
    !
    *if,asel(_iii),eq,1,then
        asbl,_iii,_lcut,,delete,_kdv
    *endif
*enddo
!
*get,_ptyp,parm,_lcut,type
!
*if,_ptyp,eq,3,then
    ldele,_lcut,,,1
*endif
!
*if,_ptyp,ne,3,then
    *if,lsel(_lcut),ne,0,then
        ldele,_lcut,,,1
    *endif
*endif
!
init_entity_num
!
csys,actcs_
!
*set,actcs_,
*set,_kdv,
*set,_alow,
*set,_ahigh,
*set,_lcut,
*set,_iii,
*set,_ptyp,
*set,x_,
*set,y_,
*set,ang_,
*set,dist_,
*set,xdist_,
*set,ydist_,
*set,lpln_,
*set,acstyp_,
*set,acs_,
*set,flag_,
cmdele,aset,


w:\ansys\mac\tools\ara_part_arc.mac.html

!   TITLE:  ara_part_arc.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    01/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is used to partition a selected set of areas by using
!   arced partitioning line.
!
!   COMMAND SYNTAX:
!
!                         (1)   (2)      (3)       (4)    (5)
!           ARA_PART_ARC, acs, ang_ln, dist_pln, x_dist, y_dist
!
!
!   ARGUMENTS:
!
!       (1) acs = the active C.S. located on the areas plane. The XY plane
!                 must be aligned coplanar with the selected areas
!
!       (1) ang_ln = the angle of the cutting line as measured from the
!                    C.S. +x axis.
!
!       (2) dist_ln = the normal distance of the line from the C.S. origin
!                     as measured in the XY plane of the active C.S.
!                     X_DIST and Y_DIST are ignored.
!
!       (3) x_dist = the distance along the x (+ or -) axis the line
!                    intersects as measured in a plane parrallel to the
!                    XY plane. If this is specified, DO NOT specify Y_DIST
!                    and DIST_PLN.
!
!       (4) y_dist = the distance along the y (+ or -) axis the line
!                    intersects as measured in a plane parrallel to the
!                    XY plane. If this is specified, DO NOT specify X_DIST
!                    and DIST_PLN.
!
!
!   DESCRIPTION:
!
!   The cutting line is created at a user specified angle, ANG_PLN, with
!   respect to the +x axis, and is an angle (in degrees) range of:
!
!                           0 < ang_pln < 180
!
!   The distance of the line is the magnitude of a vector from the origin
!   oriented normal to the line. Therefore, it is the perpendicular distance
!   of the line from the origin. The line is constructed such that it lies
!   in a plane parrallel to the selected area(s). Therefore, the active C.S.
!   must have one of its principal planes oriented parrallel to the plane of
!   the areas to be partitioned.
!   to the z axis of the active C.S.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

actcs_=arg1
ang_=arg2
dist_=arg3
xdist_=arg4
ydist_=arg5
!
!
csys,actcs_
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    create_cs,0,'acs_',0,0,0,0,0,0,0    ! create cartesian CS at same location.
*endif
!
cm,aset,area
!
max_enty_dim,'l'
!
lpln_=10*max_leng
!
*if,dist_,eq,0,then
    *if,xdist_,ne,0,then
        flag_=1
        create_cs,0,,1,xdist_,0,0,0,0,0
    *else
        *if,ydist_,ne,0,then
            flag_=1
            create_cs,0,,1,0,ydist_,0,0,0,0
        *endif
    *endif
*endif
!
*if,dist_,lt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_-90)*rconv)
        y_=abs(dist_)*sin((ang_-90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_-90)*rconv)
        y_=-abs(dist_)*sin((ang_-90)*rconv)
    *endif
*elseif,dist_,gt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_+90)*rconv)
        y_=abs(dist_)*sin((ang_+90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_+90)*rconv)
        y_=-abs(dist_)*sin((ang_+90)*rconv)
    *endif
*else
    *if,flag_,ne,1,then
        xdist_=0
        ydist_=0
        x_=0
        y_=0
    *endif
*endif
!
*if,flag_,ne,1,then
    create_cs,0,,1,x_,y_,0,0,0,0
*endif
!
!
!                (1)     (2)     (3)     (4)     (5)
! CREATE_ARCS, radius, ang_inc, n_arc, st_ang, fin_ang
!
create_arcs,

k,,lpln_,ang_,0
k,,-lpln_,ang_,0
!
create_lines,,1
!
_lcut=lm
!
cmsel,s,aset
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*do,_iii,_alow,_ahigh,1
    *if,_alow,eq,_ahigh,then
        _kdv='delete'
    *else
        *if,_iii,ne,_ahigh,then
            _kdv='keep'             ! keep/delete decision variable
        *else
            _kdv='delete'
        *endif
    *endif
    !
    *if,asel(_iii),eq,1,then
        asbl,_iii,_lcut,,delete,_kdv
    *endif
*enddo
!
*get,_ptyp,parm,_lcut,type
!
*if,_ptyp,eq,3,then
    ldele,_lcut,,,1
*endif
!
*if,_ptyp,ne,3,then
    *if,lsel(_lcut),ne,0,then
        ldele,_lcut,,,1
    *endif
*endif
!
init_entity_num
!
csys,actcs_
!
*set,actcs_,
*set,_kdv,
*set,_alow,
*set,_ahigh,
*set,_lcut,
*set,_iii,
*set,_ptyp,
*set,x_,
*set,y_,
*set,ang_,
*set,dist_,
*set,xdist_,
*set,ydist_,
*set,lpln_,
*set,actcs_,
*set,acstyp_,
*set,acs_,
*set,flag_,
cmdele,aset,


w:\ansys\mac\tools\create_arcs.mac.html

!   TITLE:  create_arcs.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      03/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a set of circular profile lines. It may be used
!   to create a full circle or a partial circle of arcs. The circle or arcs
!   may be created with various arc angle increments or number of arcs with-
!   in given start and finish angles.
!
!   The arguments for this macro are:
!
!       (1) radius = the radius of the arc
!
!       (2) z_loc = the location of the arc 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 full set
!                     of arcs with a series of arcs subtending an angle of
!                     'ANG_INC'.  When this parameter is desired, 'N_ARC'
!                     must be left blank.
!
!       (4) n_arc = The number of equal arc increments that the full set
!                   is constructed from.  If this argument is specified,
!                   then 'ANG_INC' is over-ridden and the full set is
!                   created by this number equal arcs.
!
!       (5) st_ang = The start angle of the first arc used in the
!                    construction of the full set of arcs.
!
!       (6) fin_ang = The finish angle of the entire arc set.
!
!   When arguments 3, 4, 5 and 6 are left blank, the algorithm defaults to a
!   single arc of 90 degrees starting at the X-axis (0 degrees).
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                (1)    (2)     (3)     (4)    (5)      (6)
! CREATE_ARCS, radius, z_loc, ang_inc, n_arc, st_ang, fin_ang
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

rad_=arg1
zloc_=arg2
anginc_=arg3
narc_=arg4
stang_=arg5
finang_=arg6
!
!
*get,ccs_,active,,csys
*get,ccstyp_,cdsy,ccs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,,1,0,0,0,0,0,0
*endif
!
*if,finang_,eq,0,then
    finang_=90
*endif
!
*if,narc_,eq,0,then
    *if,anginc_,eq,0,then
        anginc_=90
        narc_=1
    *else
        narc_=abs(finang_-stang_)/anginc_
    *endif
*else
    anginc_=abs(finang_-stang_)/narc_
*endif
!
*do,ii_,0,narc_,1
    !
    ang_=stang_+(ii_*anginc_)
    !
    k,,rad_,ang_,zloc_
*enddo
!
create_lines,1,1
!
csys,ccs_
!
!
*set,ii_,
*set,rad_,
*set,ang_,
*set,stang_,
*set,finang_,
*set,anginc_,
*set,narc_,
*set,ulimit_,
*set,ccs_,
*set,zloc_,
*set,ccstyp_,


w:\ansys\mac\tools\create_circle.mac.html

!   TITLE:  create_circle.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      01/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a set of circular profile lines. It may be used
!   to create a full circle or a partial circle of arcs. The circle or arcs
!   may be created with various arc angle increments or number of arcs with-
!   in given start and finish angles.
!
!   The arguments for this macro are:
!
!       (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,....etc. 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.
!
!   When arguments 2, 3 and 4 are left blank, the algorithm defaults to a
!   circle of 4 90 degree arcs starting at the X-axis (0 degrees).
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                  (1)    (2)     (3)     (4)    (5)
! CREATE_CIRCLE, radius, z_loc, ang_inc, n_arc, st_ang
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

rad_=arg1
zloc_=arg2
anginc_=arg3
narc_=arg4
stang_=arg5
!
!
*get,ccs_,active,,csys
*get,ccstyp_,cdsy,ccs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,,1,0,0,0,0,0,0
*endif
!
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
!
csys,ccs_
!
!
*set,ii_,
*set,rad_,
*set,stang_,
*set,finang_,
*set,anginc_,
*set,narc_,
*set,ccs_,
*set,ccstyp_,
*set,ang_,
*set,zloc_,


w:\ansys\mac\tools\create_lines.mac.html

!   TITLE:  create_lines.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/06/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates lines between newly created keypoints.
!
!
!   COMMAND SYNTAX:
!
!       CREATE_LINES, c_acs, seqnce
!
!
!   ARGUMENTS:
!
!       (1) c_acs = boolean operator to create lines in active coordinate
!                   system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!       (2) seqnce = boolean operator to create lines in a closed loop,
!                or lines in sequence from lowest to highest keypoint
!                order.
!
!               0 (or blank) = creates lines between KP's, forming a
!                              closed loop.
!
!               1 = creates lines between keypoints in sequence, but
!                   not forming a closed loop.
!
!
!   DESCRIPTION:
!
!   The lines may be created in a loop, or in sequence from lowest to high-
!   est keypoint values. This command is preceeded and followed by the command
!   INIT_ENTITY_NUM. Therefore, it may be used directly after the keypoint
!   commands (k,,XX,YY,ZZ); and directly before all other commands. The
!   retrieval of the maximum entities before and after the lines are created
!   is built in.
!
!   When creating lines, be sure that the proper coordinate system is active;
!   i.e., if arced lines are desired, then the active coordinate system must
!   be a cylindrical coordinate system; if spherical lines are desired, then
!   the active c.s. must be a spherical c.s.; etc.
!
!   Therefore, if straight lines in a closed loop is the desired objective,
!   no arguments need to be specified.  Only the macro title needs specified.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
init_entity_num
!
cacs_=arg1
seqnce_=arg2
!
newkps_=km-km_prev      ! number of new keypoints
!
*if,newkps_,ge,2,then
    *if,seqnce_,eq,0,then
        *if,cacs_,eq,0,then
            *do,iii_,1,newkps_,1
                *if,iii_,ne,newkps_,then
                    lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
                *else
                    lstr,km,km-(newkps_-1)
                *endif
            *enddo
        *endif
        !
        *if,cacs_,eq,1,then
            *do,iii_,1,newkps_,1
                *if,iii_,ne,newkps_,then
                    l,km-(newkps_-iii_),km-(newkps_-iii_-1)
                *else
                    l,km,km-(newkps_-1)
                *endif
            *enddo
        *endif
    *endif
    !
    !
    *if,seqnce_,eq,1,then
        *if,cacs_,eq,0,then
            *do,iii_,1,newkps_-1,1
                lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *enddo
        *endif
        !
        *if,cacs_,eq,1,then
            *do,iii_,1,newkps_-1,1
                l,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *enddo
        *endif
    *endif
*endif
!
*if,arg3,eq,0,then
    *set,newkps_,
*endif
!
init_entity_num
!
lplot
!
*set,iii_,
*set,seqnce_,
*set,cacs_,
!


w:\ansys\mac\tools\ln_filletB.mac.html

!   TITLE:  ln_fillet.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/27/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     01/14/2002    J. Rinaldi
!
!           Made provision for filleting all newly created and/or unattached
!           lines that may be selected by the 'isolate_lines' command.
!---------------------------------------------------------------------------
!       Rev B     TBD   J. Judd / J. Rinaldi
!       - Add error traps and warnings for 'zero radius', 'keypoint attached
!         to more than 2 lines', and 'fillet too large for existing lines'
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a line fillet(s) at the specified junction key-
!   point(s).
!
!   COMMAND SYNTAX:
!
!                   (1)   (2)
!        LN_FILLET, jkp, radius
!
!   ARGUMENTS:
!
!       (1) jkp = the keypoint number adjoining 2 lines to be filleted. This
!                 is a specific keypoint number (an integer value > or = to 0).
!
!               Otherwise:
!
!                   0 (or blank) = all selected keypoints adjoining two
!                                  lines will be filleted
!
!                   -1 = all keypoints adjoining two lines will be filleted,
!                        where the lines to be filleted are newly created and/or
!                        unattached (to areas and/or volumes) lines. (these
!                        lines may be selected by the 'isolate_lines' command).
!
!       (2) radius = the radius of the fillet.
!
!   DESCRIPTION:
!
!   This macro creates a fillet between 2 lines sharing the keypoint specified
!   in argument 1, 'jkp', with the fillet radius specified in argument 2.
!
!   If it is desired to create more than 1 fillet with the same radii, then
!   select all keypoints at the junction of the lines that are desired to be
!   filleted, and leave argument 1 blank. Fillets will be created at these
!   selected keypoints.
!
!   If any of the selected keypoints, or the specified keypoint 'jkp', are
!   not attached to only 2 lines, the algorithm will abort the fillet creation
!   at that keypoint, and proceed to the next junction keypoint in the selected
!   set, if more than 1 keypoint is selected.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
jkp_=arg1
rad_=arg2
!
*if,rad_,eq,0,then
   *msg,warn
   Fillet cannot be created because fillet radius input %/is zero or parameter is not defined.
*else
    *if,jkp_,le,0,then
        *if,jkp_,eq,-1,then
            isolate_lines
            ksll,s
        *endif
        !
        entity_array,'k','filkp_','array'
        numkps_=ecount
        !
        *do,abc_,1,numkps_,1
            ksel,s,kp,,filkp_(abc_,1)
            lslk,s,0
            !
            get_max_entity
            get_min_entity
            !
            *get,lcnt_,line,,count
            *get,llowl_,line,l_min,leng
            *get,lhighl_,line,lm,leng
            !
            *if,lcnt_,eq,2,then
                *if,llowl_,gt,rad_,then
                    *if,lhighl_,gt,rad_,then
                        lfillt,l_min,lm,rad_
                    *else
                        *MSG,WARN,lm
                        No fillet created, line %i is smaller than radius.
                    *endif
                *else
                    *MSG,WARN,l_min
                    No fillet created, line %i is smaller than radius.
                *endif
            *else
                *MSG,WARN,filkp_(abc_,1)
                No fillet created, KP %i joins more than 2 lines.
            *endif
        *enddo
        !
        *set,filkp_(1),
        *set,abc_,
        *set,numkps_,
        *set,ecount,
    *elseif,jkp_,gt,0,then
        ksel,s,kp,,jkp_
        lslk,s,0
        !
        get_max_entity
        get_min_entity
        !
        *get,lcnt_,line,,count
        *get,llowl_,line,l_min,leng
        *get,lhighl_,line,lm,leng
        !
        *if,lcnt_,eq,2,then
            *if,llowl_,gt,rad_,then
                *if,lhighl_,gt,rad_,then
                    lfillt,l_min,lm,rad_
                *else
                    *MSG,WARN,lm
                    No fillet created, line %i is smaller than radius.
                *endif
            *else
                *MSG,WARN,l_min
                No fillet created, line %i is smaller than radius.
            *endif
        *else
            *MSG,WARN,jkp_
            No fillet created, KP %i joins more than 2 lines.
        *endif
    *endif
*endif
!
init_entity_num
!
lplot
!
*set,jkp_,
*set,rad_,
*set,lcnt_,


w:\ansys\mac\tools\ln_series.mac.html

!   TITLE:  ln_series.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a series of disconnected lines between pairs of
!   newly created keypoints.
!
!
!   COMMAND SYNTAX:
!
!       LN_SERIES, c_acs
!
!
!   ARGUMENTS:
!
!       c_acs = boolean operator to create lines in active coordinate
!               system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!
!   DESCRIPTION:
!
!   This macro connects each pair of newly created keypoints by a single line.
!   Therefore, this command runs successfully only if the number of new key-
!   points is an even number. This generates a series of new lines, all dis-
!   connected, between each pair of keypoints in sequence.
!
!   The lines may be created as straight lines or lines in the active C.S.
!   The retrieval of the maximum entities before and after the lines are
!   created is built in. Therefore, when choosing argument 1 as 1, be sure
!   that the proper coordinate system is active; i.e., if arced lines are
!   desired, then the active coordinate system must be a cylindrical C.S.;
!   if spherical lines are desired, then the active c.s. must be a spherical
!   C.S.; etc. If straight lines in a closed loop is the desired objective,
!   no arguments need to be specified. Only the macro title needs specified.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

cacs_=arg1
!
init_entity_num
!
*if,cacs_,eq,0,then
    *do,iii_,km_prev+1,km,2
        lstr,iii_,iii_+1
    *enddo
*elseif,cacs_,eq,1,then
    *do,iii_,km_prev+1,km,2
        l,iii_,iii_+1
    *enddo
*endif
!
init_entity_num
!
lplot
!
*set,iii_,
*set,cacs_,


w:\ansys\mac\tools\norm.mac.html

!   TITLE:  norm.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/02/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a normal (perpendicular) line to a specified line
!   at a distance from one of the end keypoint.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)    (4)    (5)
!               NORM, line#, kp#, kp_pln, dist, leng
!
!
!   ARGUMENTS:
!
!       (1) line# = line number to create a normal line relative to
!
!       (2) kp# = end keypoint number of the specified line to measure from in
!                 construction of the normal line.
!
!       (3) kppln = keypoint defining the '+' direction of, and the plane con-
!                   taining, the Y axis.
!
!       (4) dist = the distance from the end keypoint to construct the line
!                  (positive or negative)
!
!       (5) leng = length of the normal line on either side of the specified
!                  line. This argument has 2 options:
!
!               a.) If the length is proceeded by a '+' sign (or blank),
!                   then the normal line will be constructed on the positive
!                   side of the specified line.
!
!               b.) If the length is proceeded by a '-' sign, then the normal
!                   line will be constructed on the negative side of the
!                   specified line.
!
!              If left blank, the length defaults to the length of the
!              specified line.
!
!
!   DESCRIPTION:
!
!   The line is constructed such that it is perpendicular to the specified
!   line, and is constructed a distance 'dist' from the specified end keypoint.
!
!   The line is constucted such that the specified keypoint is the origin of
!   a coordinate system (C.S.) with the +X axis oriented along the specified
!   line, and passes through the the opposite end keypoint. With this orien-
!   tation defined, the positive side of the specified line is the +Y axis
!   direction side, and the negative side on the -Y axis direction side. In
!   either case, the line is constructed such that it crosses the X axis (i.e.,
!   the infinite line colinear with the specified line) a distance 10% of the
!   specified or default length.
!
!   The normal line may be constructed a negative or positive distance from
!   the specified keypoint, allowing it to be constructed on either side.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

baseln_=arg1
cntkp_=arg2
kpln_=arg3
dist_=arg4
leng_=arg5
!
init_entity_num
!
*get,kp1_,line,baseln_,kp,1
*get,kp2_,line,baseln_,kp,2
!
*if,kp1_,eq,cntkp_,then
    kpopp_=kp2_
*else
    kpopp_=kp1_
*endif
!
*get,acs1_,active,,csys
!
cskp,csn+5,0,cntkp_,kpopp_,kpln_
!
*if,leng_,eq,0,then
    *get,leng_,line,baseln_,leng
    k,,dist_,-leng_,0
*else
    k,,dist_,-0.10*leng_,0
*endif
!
k,,dist_,leng_,0
!
create_lines,,1
!
csdele,csn+5
csys,acs1_
!
lplot
!
*set,baseln_,
*set,cntkp_,
*set,kpln_,
*set,kp1_,
*set,kp2_,
*set,acs1_,
*set,dist_,
*set,leng_,
*set,kpopp_,


w:\ansys\mac\tools\norm_kp.mac.html

!   TITLE:  norm_kp.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a normal (perpendicular) line to a specified line
!   through a specified keypoint.
!
!
!   COMMAND SYNTAX:
!
!                         (1)   (2)   (3)
!               NORM_KP, line#, kp#, kp_use
!
!
!   ARGUMENTS:
!
!       line# = line number to create a normal line relative to
!
!       kp# = keypoint number which the normal line must pass through.
!             This argument has 2 options:
!
!               a.) If the KP number is proceeded by a '+' sign (or blank),
!                   then the normal line will be constructed on the same
!                   side as the KP, passing through it. (DEFAULT)
!
!               b.) If the KP number is proceeded by a '-' sign, then the
!                   normal line will be constructed on the opposite side
!                   as the KP.
!
!       kp_use = use the keypoint as one of the normal line's endpoints:
!
!               0 (or blank) = do not use keypoint (constuct line such
!                              that it passes through the KP) (DEFAULT)
!
!               1 = use keypoint as one endpoint to the normal line.
!
!
!   DESCRIPTION:
!
!   The line is constructed such that it is perpendicular to the specified
!   line, and passes through a keypoint not colinear with the specified line.
!   The line is constucted such that it passes through the keypoint a distance
!   15% of the distance between the keypoint and the user specified line.
!
!   If it is desired to construct the line on the same side as the keypoint,
!   then simply enter the keypoint number in the 2nd argument. If it is
!   desired to construct the line on the opposite side as the keypoint, then
!   enter the keypoint number as a negative number. In either case, the line
!   will cross the specified line.
!
!   If it is desired to use the keypoint as one endpoint of the normal line,
!   then specify the 3rd argument, 'kp_use', as a 1. Whether the line is
!   constructed on either side, if 'kp_use' is 1, the line sill use the
!   specified keypoint as one of its endpoints.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

baseln_=arg1
basekp_=arg2
usekp_=arg3
!
init_entity_num
!
*get,kp1st_,line,baseln_,kp,1
*get,kp2nd_,line,baseln_,kp,2
!
*get,acs1_,active,,csys
!
cskp,csn+5,0,kp1st_,kp2nd_,abs(basekp_)
!
*if,basekp_,gt,0,then
    *if,usekp_,eq,0,then
        k,,kx(abs(basekp_)),1.1*ky(abs(basekp_)),0
        k,,kx(abs(basekp_)),-0.15*ky(abs(basekp_)),0
    *elseif,usekp_,eq,1,then
        k,,kx(abs(basekp_)),-0.15*ky(abs(basekp_)),0
    *endif
*elseif,basekp_,lt,0,then
    *if,usekp_,eq,0,then
        k,,kx(abs(basekp_)),-1.1*ky(abs(basekp_)),0
        k,,kx(abs(basekp_)),0.15*ky(abs(basekp_)),0
    *elseif,usekp_,eq,1,then
        k,,kx(abs(basekp_)),-1.1*ky(abs(basekp_)),0
    *endif
*endif
!
*if,usekp_,eq,0,then
    create_lines,,1
*elseif,usekp_,eq,1,then
    init_entity_num
    lstr,abs(basekp_),km
    init_entity_num
*endif
!
csdele,csn+5
csys,acs1_
!
lplot
!
*set,baseln_,
*set,basekp_,
*set,kp1st_,
*set,kp2nd_,
*set,acs1_,
*set,usekp_,


w:\ansys\mac\tools\parl_lines.mac.html

!   TITLE:  parl_lines.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a series of lines parallel to a set of selected lines.
!
!
!   COMMAND SYNTAX:
!
!                     (1)   (2)   (3)    (4)    (5)    (6)     (7)   (8)
!        PARL_LINES, plncs, side, dist, line#, sfact, zposCS, zposL, npl
!
!
!   ARGUMENTS:
!
!       (1) plncs = the coordinate system whose XY plane is parallel to
!                   the plane which wiil contain the parrallel lines.
!
!       (2) side = the side to the selected line to create the parallel line.
!
!                       't' = top
!                       'b' = bottom
!                       'l' = left
!                       'r' = right
!
!               *** NOTE: For vertical and horizontal lines, it is safest to
!                         specify the sides as follows:
!
!                           vertical - left ('l') or right ('r')
!                           horizontal - top ('t') or bottom ('b')
!
!
!       (3) dist =  the distance between parallel lines
!
!       (4) line# =  number of the line to construct parrallel to. This
!                    argument is valid only when an individual line is to
!                    be selected. (If a multiple-line set (>1) is to be
!                    used, then this argument is left blank, and the lines
!                    to be operated on are selected)
!
!       (5) sfact = new line length scaling factor (default = 2)
!
!       (6) zposCS = new line Z position RELATIVE to the plane C.S., which is
!                    the plane normal to the Z axis of the plane C.S. specified
!                    in argument 1.
!
!       (7) zposL = new line Z position RELATIVE to plane of the original line,
!                   which is the plane normal to the Z axis of the plane C.S.
!                   specified in argument 1.
!
!       (8) npl = number of consecutive parallel lines being created. This para-
!                 meter is specified in the first call of PARL_LINES when a group
!                 of parallel lines is to be created one after the other.
!
!
!   DESCRIPTION:
!
!   The parrallel line(s) are created in the plane parallel to the XY plane
!   of the plane coordinate system specified in argument 1, 'plncs'.
!
!   This macro creates the parallel line(s) a normal distance 'dist' from
!   the selected lines.  The lines are created on the side specified by
!   argument 2.  TOP, BOTTOM, LEFT and RIGHT are relative positions, and
!   are based on the perspective of the user.  This 'perspective' is deter-
!   mined from the plane coordinate system specified in argument 1. From,
!   this coordinate system, TOP is the region in the +Y direction; BOTTOM is
!   the region in the -Y direction; LEFT is the region in the -X direction
!   and RIGHT is the region in the +X direction.  Therefore, the perspective
!   of the user is the XY plane with the +Z axis pointing out of the graphics
!   window.
!
!   The length of the new lines are determined by the scaling factor, 'sfact',
!   specified in argument 4.  If left blank, the default value is 2.
!
!   The length of the new line is determined by the following formula:
!
!                       L_new = L_orig + 2*(sfact * dist)
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered parallel with the original line, with each end
!   greater in length by the amount (sfact * dist). Argument 5 allows the
!   user to adjust the resulting lengths of the new lines if desired.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
plncs_=arg1
side_=arg2
dist_=arg3
origln_=arg4
sfact_=arg5
zposcs_=arg6
zposl_=arg7
npl_=arg8
!
*if,npl_,gt,0,then
    excnt_=0                ! initialize execution counter for PARL_LINES
    nplhold_=npl_
*endif
!
*if,nplhold_,gt,0,then
    *if,npl_,eq,0,then
        excnt_=excnt_+1
    *endif
*endif
!
*if,origln_,ne,0,then
    origln_=origln_-excnt_
*endif
!
*if,sfact_,le,0,then
    sfact_=2
*endif
!
*get,acs1__,active,,csys
!
*get,plncstyp,cdsy,plncs_,attr,kcs
!
*if,plncstyp,ne,0,then
    clocal,csn+5,0,0,0,0,0,0,0
*endif
!
*if,origln_,eq,0,then
    cm,origlns_,line
*else
    lsel,s,line,,origln_
*endif
!
entity_array,'l','parln_','array'
lnmax_=ecount
!
*do,aaa_,1,lnmax_,1
    csys,plncs_
    !
    *get,lnl_,line,parln_(aaa_,1),leng
    !
    *get,kp11_,line,parln_(aaa_,1),kp,1
    *get,kp12_,line,parln_(aaa_,1),kp,2
    !
    offset_=kz(kp11_)
    clocal,csn+6,1,kx(kp11_),ky(kp11_),offset_,0,0,0
    !
    kpang_=ky(kp12_)
    ang_convert,'kpang_',0
    !
    *if,kpang_,le,89,then
        k,,1,90,0
    *elseif,kpang_,le,179,then
        k,,1,180,0
    *elseif,kpang_,le,269,then
        k,,1,270,0
    *elseif,kpang_,le,359,then
        k,,1,0,0
    *elseif,kpang_,gt,359,then
        k,,1,90,0
    *endif
    !
    init_entity_num
    thrdkp_=km
    !
    cskp,csn+7,0,kp11_,kp12_,thrdkp_
    !
    *if,kpang_,le,90,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,180,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,270,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *elseif,kpang_,le,360,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *endif
    !
    *if,zposcs_,eq,0,then
        *if,zposl_,eq,0,then
            zpos_=0
        *else
            zpos_=zposl_
        *endif
    *else
        zpos_=zposcs_-offset_
    *endif
    !
    *if,dist_,ne,0,then
        k,,-sfact_*dist_,sign_*dist_,zpos_
        k,,lnl_+(sfact_*dist_),sign_*dist_,zpos_
    *else
        k,,-sfact_*(0.10*lnl_),0,zpos_
        k,,lnl_+(sfact_*(0.10*lnl_)),0,zpos_
    *endif
    !
    create_lines,,1
    !
    kdele,thrdkp_
    init_entity_num
    !
    lplot
*enddo
!
lsel,s,line,,lm-(aaa_-1),lm,1
cm,newlns,line
!
init_entity_num
!
*if,usangln_,ne,1,then
    csdele,csn+5,csn+7,1
*endif
!
lplot
!
csys,acs1__
!
*if,excnt_,eq,nplhold_-1,then
    *set,excnt_,
    *set,nplhold_,
*endif
!
*set,plncs_,
*set,acs1__,
*set,origln_,
*set,plncstyp,
*set,lnmax_,
*set,parln_(1),
*set,kpang_,
*set,sign_,
*set,sfact_,
*set,lnl_,
*set,thrdkp_,
*set,dist_,
*set,side_,
*set,aaa_,
*set,kp11_,
*set,kp12_,
*set,zpos_,
*set,zposl_,
*set,zposcs_,
*set,offset_,
*set,npl_,


w:\ansys\mac\tools\profile_close.mac.html

!   TITLE:  profile_close.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/29/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates an enclosed profile from a series of overlaping, dis-
!   connected lines.
!
!
!   COMMAND SYNTAX:
!
!        PROFILE_CLOSE
!
!
!   DESCRIPTION:
!
!   A set of independent, overlapping lines with no intersection points, and
!   whose combined paths form a closed loop path, or series of closed paths,
!   are transformed into a connected, continuous closed loop chain profile.
!   Each line must be overlapped by other lines at at least 2 points along its
!   length. After execution, the resulting closed path is a set of lines that
!   share common end keypoints. The extraneous line segments resulting from the
!   line overlap operation (LOVLAP) are 'cleaned' from the new path.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

isolate_lines
!
lovlap,all
init_entity_num
!
isolate_lines
ksll,s
!
entity_array,'k','kset1_','array'
numkps_=ecount
!
*do,aaa_,1,numkps_,1
    ksel,s,kp,,kset1_(aaa_,1)
    lslk,s,0
    *get,numcl_,line,,count
    !
    *if,numcl_,lt,2,then
        ldele,all,,,1
    *endif
*enddo
!
init_entity_num
!
lplot
!
*set,numkps_,
*set,ecount,
*set,kset1_(1),
*set,numcl_,
*set,aaa_,


w:\ansys\mac\tools\profile_lines.mac.html

!   TITLE:  profile_lines.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/29/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a continuous line profile from a set of selected lines.
!
!
!   COMMAND SYNTAX:
!
!        PROFILE_LINES, strt_pt, fin_pt
!
!
!   ARGUMENTS:
!
!       (1) strt_pt = the first or starting keypoint in the line profile.
!
!       (2) fin_pt = the last or finish keypoint in the line profile.
!
!
!   DESCRIPTION:
!
!   A set of independent, overlapping lines with no intersection points is
!   transformed into a connected chain profile.  The lines should not form
!   ANY closed path, and must overlap other lines at only 1 point for each
!   overlapping line.
!
!   The desired profile is determined from a start keypoint in the chain, and
!   terminate at a finish keypoint.  After execution, the resulting path is
!   a set of lines that share common keypoints, and form a continuous path
!   from the specified start and finish keypoints.  The extraneous line seg-
!   ments resulting from the line overlap operation (LOVLAP) are 'cleaned'
!   from the new path.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
skp_=arg1
fkp_=arg2
!
!------------------------ Combine / Overlap Lines ------------------------
!
*get,origtyp_,comp,origlns_,type
!
*if,origtyp_,eq,7,then
    cmsel,u,origlns_
*endif
!
*get,numlns_,line,,count
!
lovlap,all
init_entity_num
!
isolate_lines
!
*if,origtyp_,eq,7,then
    cmsel,u,origlns_
*endif
!
lplot
!
!-------------------------- Create Line Profile --------------------------
!
*do,aaa_,1,numlns_,1
    ksel,s,kp,,skp_
    !
    lslk,s,0
    !
    *if,aaa_,eq,1,then
        get_max_entity
        prfln_=lm
    *else
        lsel,u,line,,prfln_
        get_max_entity
        prfln_=lm
    *endif
    !
    *get,kp11_,line,prfln_,kp,1
    *get,kp12_,line,prfln_,kp,2
    !
    *if,skp_,eq,kp11_,then
        juncpt_=kp12_
    *else
        juncpt_=kp11_
    *endif
    !
    *if,juncpt_,eq,fkp_,then
        *exit
    *else
        ksel,s,kp,,juncpt_
        !
        lslk,s,0
        lsel,u,line,,prfln_
        !
        *get,ptyp__,parm,lnset_,type
        !
        *if,ptyp__,ne,-1,then
            *set,lnset_(1),
        *endif
        !
        entity_array,'l','lnset_','array'
        nchkln_=ecount
        !
        *if,nchkln_,gt,0,then
            !
            *set,drlns_,
            !
            *do,bbb_,1,nchkln_,1
                *if,drlns_,eq,0,then
                    lsel,s,line,,lnset_(bbb_,1)
                    !
                    *get,kpls1_,line,lnset_(bbb_,1),kp,1
                    *get,kpls2_,line,lnset_(bbb_,1),kp,2
                    !
                    *if,kpls1_,eq,juncpt_,then
                        juncpt2_=kpls2_
                    *else
                        juncpt2_=kpls1_
                    *endif
                    !
                    ksel,s,kp,,juncpt2_
                    !
                    lslk,s,0
                    lsel,u,line,,lnset_(bbb_,1)
                    !
                    *get,numcl_,line,,count
                    !
                    *if,juncpt2_,ne,fkp_,then
                        *if,numcl_,eq,0,then
                            lsel,s,line,,lnset_(bbb_,1)
                            ldele,all,,,1
                        *else
                            drlns_=1
                        *endif
                    *else
                        drlns_=1
                    *endif
                *else
                    lsel,s,line,,lnset_(bbb_,1)
                    ldele,all,,,1
                *endif
            *enddo
        *else
            *exit
        *endif
    *endif
    !
    skp_=juncpt_
    !
    *set,juncpt_
    *set,juncpt2_
    !
    init_entity_num
    !
    lplot
*enddo
!
init_entity_num
!
lplot
!
!-------------------------------------------------------------------------
!
!
*set,skp_,
*set,fkp_,
*set,lnset_(1),
*set,prfln_,
*set,drlns_,
*set,numcl_,
*set,juncpt_,
*set,juncpt2_,
*set,bbb_,
*set,aaa_,
*set,kp11_,
*set,kp12_,
*set,kpls1_,
*set,kpls2_,
*set,origtyp_,
cmdele,origlns_
cmdele,conln_


w:\ansys\mac\tools\rctwrc.mac.html

!   TITLE:  rctwrc.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!               Rev B   05/18/2001          J. Judd
!---------------------------------------------------------------------------
!
!   Rectangle with potential radiused corners and line mesh definition.
!
!   Can make rectangles perpendicular and parallel to the current cartesian CS.
!   The ANSYS command RECT restricts to being in the XY working plane.
!
!   Option: If define {RAD}, add 4 equivalent radiused corners to the rectangle.
!   Option: If define {Area_}, will create a rectangle, subtract it from the
!           area(s) defined by {Area_}, and then recreate the rectangle.
!            One purpose of this is to allow mesh control to be defined in the
!           interior of an area without leaving a hole.
!   Option: If define {Ln1,Ln2,Ln3,Ln4,Rn}, mesh control is defined using line divisions
!           or line spacing.  A null or zero entry will result in no line mesh
!           definition.  The convention for association of the rectangle's lines
!           with order of macro's blanks is illustrated in figure TBD.
!---------------------------------------------------------------------------
!   COMMAND SYNTAX
!   rctwrc,x1,x2,y1,y2,z1,z2,RAD,Area_,DivType,Ln1,Ln2,Ln3,Ln4,Rn
!
!     See Argument assignment below for definitions
!
!---------------------------------------------------------------------------

! NEW INTERNAL VARIABLES: (see end of file where reset)
! NEW GLOBAL VARIABLES:  (global variables remaining after macro)

! ASSUMED VARIABLES: (variables assumed to be defined prior to invoking macro)
!   None
! OTHER MACROS CALLED: init_entity_num, isolate_lines

! COMMENTS:
! - Need to add error handling if radius size deletes connecting line (coincident kp's)
!   or a negative line
! - Consider how to allow for numbering of line divisions on cut out when new lines aren't
!   shared after subtraction.  If area subtracting is not within boundaries of area
!   subtracting from (included ExtraCut) then have this problem.
! - Add in error handling in form of *Get for result of last command.

! SAMPLES:
!      rctwrc,x1,x2,y1,y2,z1,z2,RAD,Area_,DivType,Ln1,Ln2,Ln3,Ln4,Rn
!       'AreaNum' in 2nd line of each example may have to be modified to make hole in
!       area created by first line.
!    mod_assemb_prep
!    rctwrc,0,1,0,2,3,3,0.25,,3,1,2,3,4,5   !X-Y plane
!       rctwrc,0.25,0.75,0.5,1.5,3,3,0.125,am,3,1,2,3,4,5   !cut from above
!    rctwrc,0,1,2,2,0,3,,,3,1,2,3,4         !X-Z plane
!    rctwrc,1,1,0,2,0,3,0.25,,3,1,2,3,4,5   !Y-Z plane
!    rctwrc,1,1,.5,1.5,1,2,0.15,am,3,1,2,3,4,5     !cut from above
!    mod_assemb_prep
!    rctwrc,0,1,0,2,3,3,-0.25,,3,1,2,3,4,5   !Warning negative radius
!    rctwrc,0,1,2,2,0,3,1,,3,1,2,3,4         !Warning radius too large
!    csys,1
!    rctwrc,1,1,0,2,0,3,0.25,,3,1,2,3,4,5    !Warning not cartesian CS
!---------------------------------------------------------------------------
!   TABLE OF CONTENTS
!       - Rename input arguments (ARG)
!       - Check for cartesian and (TBD: correct if not)
!       - Move and Rotate WPCSYS
!       - Setup Loop for subtract/recreate from area?
!       - Create Rectangle
!       - Radius corners?
!       - Create Line Divisions
!       - Subtract new area from Area_
!       - Select newly created area and lines
!       - Erase internal variables
!       - Revert to original CS's wpcsys

*get,prkey_,active,0,prkey
/nopr

!----------------------------------------------------------------------
!------------ Rename input arguments (ARG) ----------------
!----------------------------------------------------------------------
X1_=ARG1           !X dimension of 1st edge in current CS
X2_=ARG2           !X dimension of 2nd edge in current CS
Y1_=ARG3           !Y dimension of 1st edge in current CS
Y2_=ARG4           !Y dimension of 2nd edge in current CS
Z1_=ARG5           !Z dimension of 1st edge in current CS
Z2_=ARG6           !Z dimension of 2nd edge in current CS
RAD_=ARG7          !radius of corners
Area_=ARG8      !Area to subtract and then add back to.
                   !If -1 then subtract from ALL areas currently selected. (TBD)
                   !If -2 then subtract from ALL areas of current part.
                   !If -3 then subtract from ALL areas.
DivType_=ARG9      !DivType: 1=size; 2=angular size; 3=number divisions; 4=spacing ratio
Ln1_=AR10          !Line Divisions on line 1
Ln2_=AR11          !Line Divisions on line 2
Ln3_=AR12          !Line Divisions on line 3
Ln4_=AR13          !Line Divisions on line 4
Rn_=AR14           !Line Divisions on radius-ed corners

!----------------------------------------------------------------------
!------------ Check for cartesian -----------
!----------------------------------------------------------------------
stop_=0
*GET,CS_,ACTIVE,,CSYS
*GET,CStype_,CDSY,CS_,ATTR,KCS
*IF,CStype_,NE,0,THEN
    *MSG,WARN
Must be in a cartesian CS when invoke rctwrc.mac
    stop_=1
*ENDIF

*IF,stop_,EQ,0,THEN
!----------------------------------------------------------------------
!------------ Move and Rotate WPCSYS -----------
!----------------------------------------------------------------------
wpcsys
*IF,X1_,EQ,X2_,THEN     !Rotate X to Z and act as if Z=X
    wpoffs,X1_
    wprotat,0,0,-90
*ELSEIF,Y1_,EQ,Y2_,THEN     !Rotate Y to Z and act as if Z=Y
    wpoffs,,Y1_
    wprotat,0,90
*ELSEIF,Z1_,EQ,Z2_,THEN
    wpoffs,,,Z1_
    !Do not need to rotate wpcsys
*ENDIF

!----------------------------------------------------------------------
!------------ Setup Loop for subtract/recreate from area? -----------
!----------------------------------------------------------------------
! Decide whether go through one pass or two pass.
! Two pass is only for when create area, subtract, recreate.
*IF,Area_,ABLT,0.1,THEN    !If not defined will be 0 or ~7.888E-31, comparison on LT and GT is within 1E-10
   i_=1
*ELSE  !If negative number (ALL?) or positive number is specific area.
   i_=2
*ENDIF
*DO,j_,1,i_  !*ENDDO is at end of program

!----------------------------------------------------------------------
!------------ Create Rectangle -----------
!----------------------------------------------------------------------
init_entity_num

*IF,X1_,EQ,X2_,THEN     !Rotate X to Z and act as if Z=X
    RECT,Z1_,Z2_,Y1_,Y2_
*ELSEIF,Y1_,EQ,Y2_,THEN     !Rotate Y to Z and act as if Z=Y
    RECT,X1_,X2_,Z1_,Z2_
*ELSEIF,Z1_,EQ,Z2_,THEN
    RECT,X1_,X2_,Y1_,Y2_
*ENDIF

!----------------------------------------------------------------------
!------------ Radius corners? -----------
!----------------------------------------------------------------------
*IF,RAD_,LT,0,THEN
    *MSG,WARN
In rctwrc.mac, the corner radius must be greater than zero.  Ignore radius.
*ENDIF

*IF,RAD_,GT,0,THEN
    DoRad_=1   !initially set as true
    !-- check if will delete lines because radius too large
    *IF,Z1_,EQ,Z2_,THEN
        *IF,ABS(X1_-X2_),LE,2*RAD_,THEN
            DoRad_=0
        *ELSEIF,ABS(Y1_-Y2_),LE,2*RAD_,THEN
            DoRad_=0
        *ENDIF
    *ELSEIF,Y1_,EQ,Y2_,THEN
        *IF,ABS(X1_-X2_),LE,2*RAD_,THEN
            DoRad_=0
        *ELSEIF,ABS(Z1_-Z2_),LE,2*RAD_,THEN
            DoRad_=0
        *ENDIF
    *ELSEIF,X1_,EQ,X2_,THEN
        *IF,ABS(Z1_-Z2_),LE,2*RAD_,THEN
            DoRad_=0
        *ELSEIF,ABS(Y1_-Y2_),LE,2*RAD_,THEN
            DoRad_=0
        *ENDIF
    *ENDIF

    *IF,DoRad_,EQ,0,THEN
        *MSG,WARN
In rctwrc.mac, the corner radius was too large (would have deleted edge lines).  Ignore Radius.
        RAD_=0
    *ELSEIF,DoRad_,EQ,1,THEN
        adele,am+1
        LFILLT,lm+1,lm+2,RAD_
        LFILLT,lm+2,lm+3,RAD_
        LFILLT,lm+3,lm+4,RAD_
        LFILLT,lm+4,lm+1,RAD_
        isolate_lines           !calls init_entity_num
        AL,all
    *ENDIF  !(DoRad_)
*ENDIF  !(RAD_)

!----------------------------------------------------------------------
!------------ Create Line Divisions -----------
!----------------------------------------------------------------------
init_entity_num

*IF,RAD_,GT,0,THEN
    lmin_=lm-7
*ELSE
    lmin_=lm-3
*ENDIF

*IF,DivType_,EQ,3,THEN   !number of divisions
    lesize,lmin_+0,,,Ln1_
    lesize,lmin_+1,,,Ln2_
    lesize,lmin_+2,,,Ln3_
    lesize,lmin_+3,,,Ln4_
    *IF,RAD_,GT,0,THEN
        lesize,lmin_+4,,,Rn_
        lesize,lmin_+5,,,Rn_
        lesize,lmin_+6,,,Rn_
        lesize,lmin_+7,,,Rn_
    *ENDIF
*ELSEIF,DivType_,EQ,1,THEN   !size
    lesize,lmin_+0,Ln1_
    lesize,lmin_+1,Ln2_
    lesize,lmin_+2,Ln3_
    lesize,lmin_+3,Ln4_
    *IF,RAD_,GT,0,THEN
        lesize,lmin_+4,Rn_
        lesize,lmin_+5,Rn_
        lesize,lmin_+6,Rn_
        lesize,lmin_+7,Rn_
    *ENDIF
*ENDIF

!----------------------------------------------------------------------
!------------ Subtract new area from Area_ ----------------
!----------------------------------------------------------------------
! If i_=2, subtracts area created from 'Area_'
!   and if i_=2 there is one more DO loop to finish which
!   creates area once again.
*IF,i_,EQ,2,THEN
    init_entity_num
    *IF,Area_,GT,0,THEN
        asel,a,area,,Area_
        asba,Area_,am,,DELETE,DELETE
    *ELSEIF,Area_,EQ,-1,THEN                    !Area_=-1 then all areas in part
        *MSG,WARN
        In rctwrc.mac, the option for Area_=-1 has not been implemented.
    *ELSEIF,Area_,EQ,-2,THEN                    !Area_=-1 then all areas in part
        asba,ALL,AR20,,DELETE,DELETE
    *ELSEIF,Area_,EQ,-3,THEN                    !Area_=-2 then all areas
        asel,all
        asba,ALL,AR20,,DELETE,DELETE
    *ELSE
        *MSG,WARN
        In rctwrc.mac, Area_=%Area_% is not a valid choice and is corrupting.
    *ENDIF
    init_entity_num

    i_=1   !Redefine i_ so that do not do second time.
*ENDIF
*ENDDO   !*DO is at beginning of program

!----------------------------------------------------------------------
!------------ Select newly created area and lines  ----------------
!----------------------------------------------------------------------
asel,s,area,,am
lsla,s,1
aplo

!----------------------------------------------------------------------
!------------ Erase internal variables  ----------------
!----------------------------------------------------------------------
*set,CS_
*set,CStype_
*set,i_
*set,j_
*set,lmin_

*ENDIF  !(stop_)
*set,stop_

*set,X1_
*set,X2_
*set,Y1_
*set,Y2_
*set,Z1_
*set,Z2_
*set,RAD_
*set,Area_
*set,DivType_
*set,Ln1_
*set,Ln2_
*set,Ln3_
*set,Ln4_
*set,Rn_

!----------------------------------------------------------------------
!------------ Revert to original CS's wpcsys  ----------------
!----------------------------------------------------------------------
wpcsys


w:\ansys\mac\tools\ara_fillet.mac.html

!   TITLE:  ara_fillet.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     08/06/2000        J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an area fillet surfacebetween to planar area
!   surfaces.
!
!
!   COMMAND SYNTAX:
!
!    OPTION 1:
!
!                   (1)   (2)     (3)     (4)   (5)     (6)     (7)
!       ARA_FILLET, opt, area1, area1cs, dir1, area2, area2cs, dir2,
!
!                   offsetd
!                     (8)
!
!    OPTION 2:
!
!                   (1)   (2)    (3)    (4)    (5)    (6)    (7)    (8)
!       ARA_FILLET, opt, area1, ckpa1, xkpa1, ykpa1, area2, ckpa2, xkpa2,
!
!                    ykpa2, offsetd
!                     (9)    (10)
!
!    OPTION 3:
!
!                   (1)   (2)     (3)   (4)  (5)  (6)   (7)     (8)     (9)
!       ARA_FILLET, opt, actvcs, area1, xc1, yc1, zc1, rotxy1, rotyz1, rotzx1,
!
!                   area2, xc2,  yc2,  zc2, rotxy2, rotyz2, rotzx2, offsetd
!                   (10)   (11)  (12)  (13)  (14)    (15)    (16)     (17)
!
!
!   ARGUMENTS:
!
!       The first parameter argument is OPT, option. Their are 3 different
!       input argument structures for this command:
!
!           Option 1 (opt = 1):
!
!               This 1st option allows the user to create areas from pre-
!               existing coordinate systems.  These coordinate systems are
!               assumed to have their centers coplanar, and with their z
!               axes oriented normal, to the plane of their respective areas.
!               If they are not, then options 2 or 3 must be used.
!
!               In the case that these pre-existing coordinate systems are not
!               consistently oriented, this option allows the user to choose
!               the side of the coordinate system (+z or -z) to create the areas,
!               by specifying the parameters 'dir1' and 'dir2'.
!
!           Option 2 (opt = 2):
!
!               This option allows the user to create coordinate systems,
!               with z axes normal to their respective areas, by using the
!               keypoints of their corresponding areas.  This employs the
!               use of the CSKP command.  The proper choice of the center,
!               x axis, and y axis keypoints must be made to insure that
!               the z axis is oriented normal to and outward from the areas.
!               (The direction of the +z axis is outward from the areas,
!               where outward is defined as the side of the areas away from
!               the fillet.)
!
!           Option 3 (opt = 3):
!
!               This option allows the user to create coordinate systems,
!               with z axes normal to their respective areas by using a
!               coordinate position center and orientation.  This employs
!               the use of the CLOCAL command.  The proper choice of the
!               center x, y and z coordinates and rotation angles must be
!               made orient the to insure that the z axis is oriented normal
!               to and outward from the areas.
!
!       The following input needed for each option is as follows:
!
!       - Option 1:
!
!               area1 = number of the 1st area to be filleted.
!
!               area1cs = coordinate system # associated with area 1.
!
!               dir1 = z axis direction, positive or negative, that is
!                      outward from area 1. Options for this argument are:
!
!                       0 (or blank) = +z direction
!                       1 = -z direction
!
!               area2 = number of the 2nd area to be filleted.
!
!               area2cs = coordinate system # associated with area 2.
!
!               dir2 = z axis direction, positive or negative, that is
!                      outward from area 2.
!
!                       0 (or blank) = +z direction
!                       1 = -z direction
!
!               offsetd = offset distance at which the new areas will be
!                         placed, which is the fillet radius between areas
!                         1 and 2.
!
!       - Option 2:
!
!               area1 = number of the 1st area to be filleted.
!
!               ckpa1 = center keypoint of area 1 c.s.
!
!               xkpa1 = keypoint used to define +x axis of area 1 c.s.
!
!               ykpa1 = keypoint used to define +y axis of area 1 c.s.
!
!               area2 = number of the 2nd area to be filleted.
!
!               ckpa2 = center keypoint of area 2 c.s.
!
!               xkpa2 = keypoint used to define +x axis of area 2 c.s.
!
!               ykpa2 = keypoint used to define +y axis of area 2 c.s.
!
!               offsetd = offset distance at which the new areas will be
!                         placed, which is the fillet radius between areas
!                         1 and 2.
!
!       - Option 3:
!
!               area1 = number of the 1st area to be filleted.
!
!               xc1 = x coordinate of area 1 c.s.
!
!               yc1 = y coordinate of area 1 c.s.
!
!               zc1 = z coordinate of area 1 c.s.
!
!               rotxy1 = 1st rotation angle (+x to +y) of area 1 c.s.
!
!               rotyz1 = 2nd rotation angle (+y to +z) of area 1 c.s.
!
!               rotzx1 = 3rd rotation angle (+z to +x) of area 1 c.s.
!
!               area2 = number of the 2nd area to be filleted.
!
!               xc2 = x coordinate of area 2 c.s.
!
!               yc2 = y coordinate of area 2 c.s.
!
!               zc2 = z coordinate of area 2 c.s.
!
!               rotxy2 = 1st rotation angle (+x to +y) of area 2 c.s.
!
!               rotyz2 = 2nd rotation angle (+y to +z) of area 2 c.s.
!
!               rotzx2 = 3rd rotation angle (+z to +x) of area 2 c.s.
!
!               offsetd = offset distance at which the new areas will be
!                         placed, which is the fillet radius between areas
!                         1 and 2.
!
!
!   DESCRIPTION:
!
!   This sub-macro calculates the position of the axis of a filleted area
!   pair.  This is achieved by finding the intersection of two planes con-
!   structed parrallel to the planes to be filleted, each at a specified
!   distance which is equal to the fillet radius of the areas. This axis
!   will then be used to create a cylindrical coordinate system whose z axis
!   is aligned along the fillet axis.  This may then be used to create arc
!   lines and areas of the fillet.
!
!
!------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
opt=arg1
!
!
*if,opt,eq,1,then
    area1=arg2
    area1cs=arg3
    dir1=arg4
    area2=arg5
    area2cs=arg6
    dir2=arg7
    offsetd=arg8
*endif
!
!
*if,opt,eq,2,then
    area1=arg2
    ckpa1=arg3
    xkpa1=arg4
    ykpa1=arg5
    area2=arg6
    ckpa2=arg7
    xkpa2=arg8
    ykpa2=arg9
    offsetd=ar10
*endif
!
!
*if,opt,eq,3,then
    actvcs=arg2
    area1=arg3
    xc1=arg4
    yc1=arg5
    zc1=arg6
    rotxy1=arg7
    rotyz1=arg8
    rotzx1=arg9
    area2=ar10
    xc2=ar11
    yc2=ar12
    zc2=ar13
    rotxy2=ar14
    rotyz2=ar15
    rotzx2=ar16
    offsetd=ar17
*endif
!
!
*if,opt,eq,1,then
    !
    csys,area1cs                ! create 1st area
    !
    *if,dir1,eq,0,then
        rfil=-offsetd
    *else
        rfil=offsetd
    *endif
    !
    create_cs,0,'offarea1',0,0,0,rfil,0,0,0
    !
    csys,area1cs
    !
    atran,offarea1,area1,,,,0,0
    !
    init_entity_num
    !
    lplot
    !
    !
    !
    csys,area2cs                ! create 2nd area
    !
    *if,dir2,eq,0,then
        rfil=-offsetd
    *else
        rfil=offsetd
    *endif
    !
    create_cs,0,'offarea2',0,0,0,rfil,0,0,0
    !
    csys,area2cs
    !
    atran,offarea2,area2,,,,0,0
    !
    init_entity_num
    !
    lplot
*endif
!
!
*if,opt,eq,2,then
    !
    create_cs,1,'area1cs',0,ckpa1,xkpa1,ykpa1       ! create area 1 c.s.
    !
    create_cs,1,'area2cs',0,ckpa2,xkpa2,ykpa2       ! create area 2 c.s.
    !
    !
    csys,area1cs                ! create 1st area
    !
    create_cs,0,'offarea1',0,0,0,-offsetd,0,0,0
    !
    csys,area1cs
    !
    atran,offarea1,area1,,,,0,0
    !
    init_entity_num
    !
    lplot
    !
    !
    !
    csys,area2cs                ! create 2nd area
    !
    create_cs,0,'offarea2',0,0,0,-offsetd,0,0,0
    !
    csys,area2cs
    !
    atran,offarea2,area2,,,,0,0
    !
    init_entity_num
    !
    lplot
*endif
!
!
*if,opt,eq,3,then
    !
    csys,actvcs                 ! create area 1 c.s.
    !
    create_cs,0,'area1cs',0,xc1,yc1,zc1,rotxy1,rotyz1,rotzx1
    !
    csys,actvcs                 ! create area 2 c.s.
    !
    create_cs,0,'area2cs',0,xc2,yc2,zc2,rotxy2,rotyz2,rotzx2
    !
    csys,area1cs                ! create 1st area
    !
    create_cs,0,'offarea1',0,0,0,-offsetd,0,0,0
    !
    csys,area1cs
    !
    atran,offarea1,area1,,,,0,0
    !
    init_entity_num
    !
    lplot
    !
    !
    !
    csys,area2cs                ! create 2nd area
    !
    create_cs,0,'offarea2',0,0,0,-offsetd,0,0,0
    !
    csys,area2cs
    !
    atran,offarea2,area2,,,,0,0
    !
    init_entity_num
    !
    lplot
*endif
!
!
aina,am-1,am                    ! perform boolean, area intersects area
!
init_entity_num
!
*get,kp1,line,lm,kp,1           ! retrieve KP's of intersection line
*get,kp2,line,lm,kp,2
!
asel,s,area,,area1              ! retrieve KP's and count of area 1
lsla,s
ksll,s
entity_array,'k','kpa1','array'
kpcnta1=ecount
!
!
asel,s,area,,area2              ! retrieve KP's and count of area 2
lsla,s
ksll,s
entity_array,'k','kpa2','array'
kpcnta2=ecount
!
init_entity_num
!
*set,exchk,
!
*do,iii,1,kpcnta1,1             ! retrieve a KP shared by areas 1 & 2
    *do,jjj,1,kpcnta2,1
        *if,kpa1(iii,1),eq,kpa2(jjj,1),then
            kp3=kpa1(iii,1)
            exchk=1
            *exit
        *endif
    *enddo
    !
    *if,exchk,eq,1,then
        *set,exchk,
        *exit
    *endif
*enddo
!
create_cs,1,,0,kp1,kp2,kp3
!
create_cs,0,'filltcs1',1,0,0,0,0,0,-90
!                           create 1st fillet c.s. at kp1
!
create_cs,0,'filltcs2',1,kx(kp2),ky(kp2),kz(kp2),0,0,0
!                           create 2nd fillet c.s. at kp2
!
ldele,lm,,,1
!
init_entity_num
!
lplot
!
!------------------------------------------------------------------------
!
*set,area1,
*set,area1cs,
*set,area2,
*set,area2cs,
*set,offsetd,
*set,kp1,
*set,kp2,
*set,kp3,
*set,offarea1,
*set,offarea2,
*set,iii,
*set,jjj,
*set,kpcnta1,
*set,kpcnta2,
*set,kpa1(1),
*set,kpa2(1),
*set,ecount,
!
*if,opt,eq,1,then
    *set,dir1,
    *set,dir2,
    *set,rfil,
*endif
!
*if,opt,eq,2,then
    *set,ckpa1,
    *set,xkpa1,
    *set,ykpa1,
    *set,ckpa2,
    *set,xkpa2,
    *set,ykpa2,
*endif
!
*if,opt,eq,3,then
    *set,actvcs,
    *set,xc1,
    *set,yc1,
    *set,zc1,
    *set,rotxy1,
    *set,rotyz1,
    *set,rotzx1,
    *set,xc2,
    *set,yc2,
    *set,zc2,
    *set,rotxy2,
    *set,rotyz2,
    *set,rotzx2,
*endif
!
*set,opt,


w:\ansys\mac\tools\chamfer_area.mac.html

!   TITLE:  chamfer_area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     04/24/2000    J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     06/06/2000    J. Rinaldi
!
!       Added angle input capability (option 2).  Added 'if-then'
!       structure for opt=2 to the macro line code to accomodate
!       the existing structure.
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates a chamfer at the intersetion of two lines,
!   line#1 and line#2. Their intersection MUST be a right angle. This
!   chamfer is a planar (area) chamfer at the intersection of 2 lines.
!
!   This macro gives 2 options for creating the chamfer.  The first option
!   (opt=1) creates the chamfer by specifying each distance along both lines.
!   The chamfer dimensions, CHMFDIM1 and CHMFDIM2, are the dimensions
!   of the chamfer along lines LINE#1 and LINE#2, respectively. Input for
!   this macro:
!
!       opt = option to create the chamfer.
!
!           1 = create chamfer by distance along both lines
!
!           2 = create chamfer by a distance along and an angle
!               adjacent to one of the lines
!
!       line#1 = 1st line to having chamfer length of CHMFDIM1
!       line#2 = 2nd line to having chamfer length of CHMFDIM2
!
!       chmfdim1 = chamfer dimension along line#1
!       chmfdim2 = chamfer dimension along line#2
!
!       chmfdim = a distance along one of the specified lines
!
!       chmfang1 = angle adjacent to line#1
!       chmfang2 = angle adjacent to line#2
!
!   In option 1 (opt=1), if CHMFDIM2 is left blank, then CHMFDIM2 is assumed
!   to be the same as CHMFDIM1, leading to a 45 degree chamfer.
!
!   In the case where an angle is specified at a chamfer, the user may
!   create the chamfer by specifying option 2 (opt=2).  In this option,
!   the two lines again must be specified, a distance along one of the sel-
!   ected lines, and the angle adjacent to that line. The algorithm will
!   then perform the necessary calculations to create the chamfer.  If the
!   first angle, CHMFANG1, is specified, then the distance CHMFDIM, is the
!   distance along LINE#1, and CHMFANG1 is the angle adjacent to LINE#1. If
!   the 2nd angle, CHMFANG2, is specified, then the distance, CHMFDIM, is
!   the distance along LINE#2, and CHMFANG2 is the angle adjacent to LINE#2.
!
!   ** NOTE:  Specify ONLY 1 of the angles, not both.
!
!
!------------------------ COMMAND SYNTAX / option 1 ------------------------
!
! CHAMFER_AREA, opt, line#1, line#2, chmfdim1, chmfdim2
!
!-------------------------------- option 2 ---------------------------------
!
! CHAMFER_AREA, opt, line#1, line#2, chmfdim, chmfang1, chmfang2
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

opt=arg1
!
*if,opt,eq,1,then
    ln1=arg2
    ln2=arg3
    chmfdim1=arg4
    chmfdim2=arg5
*endif
!
*if,opt,eq,2,then
    ln1=arg2
    ln2=arg3
    chmfdim=arg4
    chmfang1=arg5
    *if,chmfang1,ne,0,then
        lnchk=1
        chmfang2=90-chmfang1
    *elseif,chmfang1,eq,0,then
        lnchk=2
        chmfang2=arg6
        chmfang1=90-chmfang2
    *endif
    !
    *if,lnchk,eq,1,then
        chmfdim1=chmfdim
        chmfdim2=chmfdim1*tan(chmfang1*rconv)
    *elseif,lnchk,eq,2,then
        chmfdim2=chmfdim
        chmfdim1=chmfdim2*tan(chmfang2*rconv)
    *endif
*endif
!
*if,opt,eq,1,then
    *if,chmfdim2,eq,0,then
        chmfdim2=chmfdim1
    *endif
*endif
!
*get,k11,line,ln1,kp,1
*get,k12,line,ln1,kp,2
!
*get,k21,line,ln2,kp,1
*get,k22,line,ln2,kp,2
!
!
*if,k11,eq,k21,then
    ikp=k11             ! intersection KP of lines line#1 and line#2
    create_cs,1,'chmfcs',0,k11,k12,k22
*elseif,k11,eq,k22,then
    ikp=k11
    create_cs,1,'chmfcs',0,k11,k12,k21
*elseif,k12,eq,k21,then
    ikp=k12
    create_cs,1,'chmfcs',0,k12,k11,k22
*elseif,k12,eq,k22,then
    ikp=k12
    create_cs,1,'chmfcs',0,k12,k11,k21
*endif
!
k,,chmfdim1,0,0
k,,0,chmfdim2,0
!
init_entity_num
!
lstr,km-1,km
!
init_entity_num
!
lsel,s,line,,ln1
lsel,a,line,,ln2
lsel,a,line,,lm
!
ln_part_ln,lm
!
lstr,km-1,km
!
init_entity_num
!
*get,k1,line,lm-3,kp,1
*get,k2,line,lm-3,kp,2
    !
    *if,k1,eq,ikp,then
        ldele,lm-3,,,1
    *elseif,k2,eq,ikp,then
        ldele,lm-3,,,1
    *endif
    !
*get,k1,line,lm-2,kp,1
*get,k2,line,lm-2,kp,2
    !
    *if,k1,eq,ikp,then
        ldele,lm-2,,,1
    *elseif,k2,eq,ikp,then
        ldele,lm-2,,,1
    *endif
    !
*get,k1,line,lm-1,kp,1
*get,k2,line,lm-1,kp,2
    !
    *if,k1,eq,ikp,then
        ldele,lm-1,,,1
    *elseif,k2,eq,ikp,then
        ldele,lm-1,,,1
    *endif
    !
*get,k1,line,lm,kp,1
*get,k2,line,lm,kp,2
    !
    *if,k1,eq,ikp,then
        ldele,lm,,,1
    *elseif,k2,eq,ikp,then
        ldele,lm,,,1
    *endif
    !
init_entity_num
!
*set,ikp,
*set,k1,
*set,k2,
*set,k11,
*set,k12,
*set,k21,
*set,k22,
*set,ln1,
*set,ln2,
*set,chmfdim1,
*set,chmfdim2,
*set,chmfang1,
*set,chmfang2,
*set,lnchk,
*set,chmfdim,


w:\ansys\mac\tools\cir_ara_pattern.mac.html

!   TITLE:  cir_ara_pattern.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    03/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a pattern of areas by repeating an area, or selected
!   set of areas, about the center of the active coordinate system (CS).
!
!   The active CS may be any type of CS (i.e., cartesian, cylindrical, etc.).
!   The origin of the active CS only serves as a center of rotation for the
!   area pattern. Only the existing area(s) which are to be patterned should
!   be selected.  They are stored in a component group and their pattern
!   repeated about the center of the active CS.
!
!   The pattern of areas may be created by either specifying the number of
!   patterns, or by specifying the repeat angle of the pattern. In addition,
!   the total pattern angle defaults to 360, or a total pattern angle between
!   0 and 360 may be specified.
!
!   The arguments for this macro are as follows:
!
!       (1)  num_pats = The number of repeat patterns to be created
!                       within the total pattern angle. When specifying
!                       this parameter, argument 2 (ANG_INC) must be
!                       left blank.
!
!       (2)  ang_inc = The angle between repeated area patterns. Specifying
!                      this parameter over-rides argument 1 (NUM_PATS),
!                      and will use this value to create the pattern. This
!                      parameter must be an integral divisor of the total
!                      pattern angle (PAT_ANG).
!
!       (3)  pat_ang = The total pattern angle.  This parameter defaults
!                      to 360, but may be specified with an angle value
!                      between 0 and 360.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                     (1)      (2)      (3)
! CIR_ARA_PATTERN, num_pats, ang_inc, pat_ang
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

numpats_=arg1
anginc_=arg2
patang_=arg3
!
cm,sourcea_,area
!
*get,basecs_,active,,csys
patcs_=basecs_
*get,ccstyp_,cdsy,basecs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,'patcs_',1,0,0,0,0,0,0
*endif
!
*if,patang_,eq,0,then
    patang_=360
*elseif,patang_,ge,360,then
    patang_=360
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,eq,360,then
        anginc_=patang_/numpats_
        aoffset_=2*anginc_
    *else
        anginc_=patang_/(numpats_-1)
        aoffset_=anginc_
    *endif
*else
    *if,patang_,eq,360,then
        aoffset_=2*anginc_
    *else
        aoffset_=anginc_
    *endif
*endif
!
arnum_=0
!
*do,xyz_,0,(patang_-aoffset_),anginc_
    !
    csys,patcs_
    !
    arnum_=arnum_+1
    !
    create_cs,0,,1,0,0,0,arnum_*anginc_,0,0
    !
    csys,patcs_
    !
    atran,csn+1,sourcea_,,,,0,0
    !
    init_entity_num
*enddo
!
csys,basecs_
!
*set,numpats_,
*set,anginc_,
*set,aoffset_,
*set,radpat_,
*set,strtang_,
*set,patang_,
*set,arnum_,
*set,xyz_,
*set,basecs_,
*set,patcs_,
*set,ccstyp_,
cmdele,sourcea_
:w


w:\ansys\mac\tools\create_area.mac.html

!   TITLE:  create_area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  07/11/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates areas from newly created keypoints.
!
!
!   COMMAND SYNTAX:
!
!           CREATE_AREAS, c_acs
!
!
!   ARGUMENTS:
!
!       (1) c_acs = boolean operator to create lines in active coordinate
!                   system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!
!   DESCRIPTION:
!
!   This macro uses the macro command CREATE_LINES.  From these keypoints
!   the lines are first created, then the area from the lines. Therefore,
!   this macro serves as a replacement step for the series of steps in creating
!   lines and then creating areas.  The argument used here is the same as
!   CREATE_LINES, and its values is transferred directly to CREATE_LINES.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
c_acs=arg1
!
create_lines,c_acs,0,1
!
*if,newkps_,ge,2,then
    ksel,s,kp,,km-(newkps_-1),km
    lslk,s,1
    al,all
*endif
!
init_entity_num
!
lplot
!
*set,newkps_,
*set,c_acs,
!


w:\ansys\mac\tools\create_area-lines.mac.html

!   TITLE:  create_area-lines.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      01/09/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates areas from newly created lines that are not
!   attached to any higher-level solid model entities (i.e., areas or
!   volumes). This is acheived by isolating the lines and creating the
!   area using the AL command. There are no arguments for this command.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! CREATE_AREA-LINES
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

init_entity_num
!
isolate_lines
!
al,all
!
init_entity_num
!
lplot


l:\ansys\mac\tools\cyl_area.mac.html

!  TITLE: cyl_area.mac (SM_TOOL)
!
!-----------------------------------------------------------------------------
!   Rev -    03/21/2001     J. Judd
!------------------------------------------------------------------------------
!   Rev A    03/04/2002     J. Judd
!   - deleted component carCA1_ at end
!------------------------------------------------------------------------------
!   Rev B    03/14/2002     J. Judd
!   - corrected potential error in deleting endcaps
!   - select new entities and entities which were active when invoked command.
!   - allow non cartesian CS when invoke.
!   - Reset to view which was active when invoked command.
!------------------------------------------------------------------------------
!
! OBJECTIVE:
!
!  Create cylindrical area or pie slice area
!
! COMMAND SYNTAX:
!
!              (1)     (2)     (3)   (4)  (5)    (6)    (7)
!   cyl_area,CenterX,CenterY,CenterZ,Rad,Theta1,Theta2,Depth
!
! ARGUMENTS:
!
!   CenterX, CenterY, CenterZ = X,Y,Z location of beginning end circle
!   Rad = Radius of circle
!   Theta1, Theta2 = beginning and ending angle of circle section
!   Depth = length of cylinder from beginning end circle in z direction.
!
! DESCRIPTION:
!
!   Creates a cylindrical area or pie slice area at specified radius and
!   Z depth centered at a specified X,Y,Z cartesian location from current
!   coordinate system.
!
!   Comment:  Good for creating area for cutting volume.
!             See also norm_cut_pln.mac for non-pie sections
!
! WARNING:
!
!   - end with cartesian working plane located at active coordinate system.
!
! EXAMPLES:
!
!   See cyl_area_test.mac
!
! TO BE DONE:
!
!---------------------------------------------------------------------------
*GET,AR67,ACTIVE,,PRKEY
/NOPR

Xcenter_=ARG1
Ycenter_=ARG2
Zcenter_=ARG3
Rad_=ARG4
Theta1_=ARG5
Theta2_=ARG6
Depth_=ARG7

!- Save View
/GSAVE,cyl_area,view

!- Error trap for cartesian CS
*GET,AR20,ACTIVE,,CSYS
*GET,AR21,CDSY,AR20,ATTR,KCS
*IF,AR21,NE,0,THEN
   create_cs,0,,0
*ENDIF

!- Group current entities for reselection at end.
cm,carCK_,KP
cm,carCL_,LINE
cm,carCA_,AREA
cm,carCV_,VOLU
cm,carCN_,NODE
cm,carCE_,ELEM
esel,none  $nsel,none  $vsel,none  $asel,none  $lsel,none  $ksel,none

!- Offset working plane in z direction
wpcsys
wpoffs,0,0,Zcenter_

init_entity_num,2

!CYL4, XCENTER, YCENTER, RAD1, THETA1, RAD2, THETA2, DEPTH
cyl4,Xcenter_,Ycenter_,0,Theta1_,Rad_,Theta2_,Depth_   !make cylindrical volume
init_entity_num,2

!** erase everything but outer area(s)
vsel,s,volu,,vm      !selects cylindrical volume
aslv  $lsla  $ksll     !selects areas, lines, kp associated with this volume
cm,carCA1_,area          !groups areas as component
vdel,all               !deletes cylindrical volume
init_entity_num,2

cmsel,s,carCA1_     !deletes first end cap area
lsla  $ksll
ksel,r,loc,z,Zcenter_
lslk,r,1
asll,r,1
adel,all,,,1
init_entity_num,2

cmsel,s,carCA1_    !deletes 2nd end cap area
lsla  $ksll
ksel,r,loc,z,Zcenter_+Depth_
lslk,r,1
asll,r,1
adel,all,,,1
init_entity_num,2

!- Reselect entities and add new entities
cmsel,s,carCA1_
lsla  $ksll
cmsel,a,carCK_
cmsel,a,carCL_
cmsel,a,carCA_
cmsel,a,carCV_
cmsel,a,carCN_
cmsel,a,carCE_

cmdele,carCK_
cmdele,carCL_
cmdele,carCA_
cmdele,carCV_
cmdele,carCN_
cmdele,carCE_
cmdele,carCA1_

csys,AR20  !Returns to original CS.
wpcsys    !Returns working plane to be aligned with CS.

!- Reset View  ----------------
/GRESU,cyl_area,view
fix_line_div,0        !to reshow line divisions
/DELETE,cyl_area,view

!- area plot
aplo

!Erase variables used internally
*set,Xcenter_
*set,Ycenter_
*set,Zcenter_
*set,Rad_
*set,Theta1_
*set,Theta2_
*set,Depth_

*IF,AR67,EQ,1,THEN
  /GOPR


w:\ansys\mac\tools\equilat_poly.mac.html

!   TITLE:  equilat_poly.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/19/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an equilateral symmetric polygon.
!
!
!   COMMAND SYNTAX:
!
!       METHOD = 's':
!                           (1)     (2)       (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, side_leng, num_side, a_or_l, strt_ang, z_pos
!
!
!       METHOD = 'o':
!                           (1)   (2)     (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, r_out, num_side, a_or_l, strt_ang, z_pos
!
!
!       METHOD = 'i':
!                           (1)   (2)     (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, r_in, num_side, a_or_l, strt_ang, z_pos
!
!
!   ARGUMENTS:
!
!       (1) mthd = the method used to create the polygon
!
!               's' = known side length
!
!               'o' = known outer radius
!
!               'i' = known inner radius
!
!       (2) (mthd = 's') side_leng = the length of each side of the polygon.
!
!           (mthd = 'o') r_out = the outer radius of the corners.
!
!           (mthd = 'i') r_in = the inner radius, measured from the origin
!                               of the active C.S. to the sides of the polygon.
!
!       (3) num_side = number of sides to the polygon.
!
!       (4) a_or_l = argument to determine if an area is to be made of the
!                    polygon or remain as lines:
!
!                   0 (or blank)= create lines only
!
!                   1 = create an area form the polygon
!
!       (5) strt_ang = the start angle of the 1st corner of the polygon.
!
!       (6) z_pos = the Z position of the polygon along the Z axis.
!
!
!   DESCRIPTION:
!
!   The polygon is created such that the Z axis of the active coordinate
!   system is concentric to the polygon. The coordinate system need not be
!   a cylindrical C.S.
!
!   The polygon may be created by 1 of 3 methods:
!
!           1.)     A user defined side length ('s')
!           2.)     A user defined outer corner radius ('o')
!           3.)     A user defined inner side radius ('i')
!
!   The number of sides of the polygon, the start angle of the first outer
!   corner, and the Z position must be specified.
!
!   This macro returns the values of side length, inner radius and outer
!   radius calculated by the algorithm in the parameters SLENG_, RIN_ and
!   ROUT_, respectively.  These values may be used for future modeling tasks
!   if desired.
!
!   Run EQUILAT_POLY_DRAW.MAC for a diagram of arguments.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

!
mthd_=arg1
dim_=arg2
numsid_=arg3
aorl_=arg4
strtang_=arg5
zpos_=arg6
!
!
*get,ptyp_,parm,mthd_,type
!
*if,ptyp_,ne,3,then
    mthd_='o'
*endif
!
a_=360/numsid_
!
*if,mthd_,eq,'s',then
    sleng_=dim_
    rout_=(sleng_/2)/(sin((a_/2)*rconv))
    rin_=rout_*cos((a_/2)*rconv)
*elseif,mthd_,eq,'o',then
    rout_=dim_
    sleng_=2*rout_*sin((a_/2)*rconv)
    rin_=rout_*cos((a_/2)*rconv)
*elseif,mthd_,eq,'i',then
    rin_=dim_
    rout_=rin_/(cos((a_/2)*rconv))
    sleng_=2*rout_*sin((a_/2)*rconv)
*endif
!
*get,actcs_,active,,csys
*get,ccstyp_,cdsy,actcs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,,1,0,0,0,0,0,0
*endif
!
*if,strtang_,le,0,then
    ang_convert,'strtang_',0,'ulimit'
    ulimit=ulimit-a_
    !
    *if,ulimit,lt,0,then
        ang_convert,'ulimit'
    *endif
*else
    ulimit=(360+strtang_)-a_
*endif
!
*do,ij_,strtang_,ulimit,a_
    k,,rout_,ij_,zpos_
*enddo
!
*if,aorl_,eq,0,then
    create_lines
*else
    create_area
*endif
!
csys,actcs_
!
lplot
!
*set,ij_,
*set,dim_,
*set,numsid_,
*set,strtang_,
*set,zpos_,
*set,ptyp_,
*set,ulimit_,
*set,a_,
*set,actcs_,
*set,ccstyp_,
*set,aorl_,
*set,rin_,
*set,rout_,
*set,mthd_,
*set,sleng_,


w:\ansys\mac\tools\equilat_poly_draw.mac.html

!   TITLE:  equilat_poly_draw.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/19/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
clear_start_new
mod_assemb_prep
!
/title,Equilateral Polygon Legend of Parameters (equilat_poly.mac)
!
csys,0
!
!       METHOD = 's':
!                           (1)     (2)       (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, side_leng, num_side, a_or_l, strt_ang, z_pos
!
!
!       METHOD = 'o':
!                           (1)   (2)     (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, r_out, num_side, a_or_l, strt_ang, z_pos
!
!
!       METHOD = 'i':
!                           (1)   (2)     (3)       (4)     (5)      (6)
!            EQUILAT_POLY, mthd, r_in, num_side, a_or_l, strt_ang, z_pos
!
EQUILAT_POLY,'i',1,8,1,0,0
!
front_view
!
lplot
!
/ANUM ,0,     3, 0.69704    ,-0.25032
/LINE , 1.241,-0.010, 1.240,-0.253
/LINE , 0.330,-0.007, 0.329,-0.249
/LINE , 0.922,-0.226, 1.230,-0.227
/LINE , 0.647,-0.225, 0.339,-0.224
/LSYM , 1.230,-0.227, 359,4, 1.000
/LSYM , 0.339,-0.224, 179,4, 1.000
/TSPEC, 15, 1.000,   1, 359,   0
/TLAB , 0.697,-0.250,ROUT_
!
/ANUM ,0,     3, 0.57341    , 0.33434
/LINE , 0.326, 0.016, 0.232, 0.250
/LINE , 1.102, 0.331, 1.007, 0.564
/LINE , 0.518, 0.339, 0.250, 0.230
/LINE , 0.740, 0.429, 1.008, 0.537
/LSYM , 0.250, 0.230, 202,4, 1.000
/LSYM , 1.008, 0.537,  22,4, 1.000
/TSPEC, 15, 1.000,   1,  22,   0
/TLAB , 0.573, 0.334,RIN_
/rep
!
/ANUM ,0,     3,-0.36340    , 0.26465
/LINE ,-0.294, 0.636,-0.055, 0.539
/LINE ,-0.554,-0.004,-0.315,-0.101
/LINE ,-0.189, 0.275,-0.082, 0.540
/LINE ,-0.227, 0.182,-0.334,-0.082
/LSYM ,-0.082, 0.540,  67,4, 1.000
/LSYM ,-0.334,-0.082, 247,4, 1.000
/TSPEC, 15, 1.000,   1, 337,   0
/TLAB ,-0.363, 0.265,SLENG_
!
lplot


w:\ansys\mac\tools\flng_ptrn_1.mac.html

!   TITLE:  flng_ptrn_1.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    01/05/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an evenly spaced circular flange bolt pattern
!   about the Z axis of a selected coordinate system.
!
!
!   COMMAND SYNTAX:
!
!
!                     (1)   (2)     (3)   (4)     (5)    (6)     (7)    (8)
!       FLNG_PTRN_1, csnum, rpat,  zpos,  numh,  stang, secang, dhole, radbf,
!
!                    radout, radin, radbh, rfil
!                     (9)     (10)   (11)  (12)
!
!
!   ARGUMENTS:
!
!       (1) csnum = coordinate system number that the pattern is con-
!                   structed around (must be a cylindrical c.s.)
!
!       (2) rpat = radius of hole pattern (i.e., the radial distance at
!                  which the hole local c.s. is placed)
!
!       (3) zpos = z position relative to 'csnum' at which the pattern
!                  is created
!
!       (4) numh = number of bolt holes around the perimeter
!
!       (5) stang = start angle at which the pattern is initiated
!
!       (6) secang = the angle subtended by a user defined section of the
!                    flange inner radius. The flange inner radius profile
!                    will be divided up into an integral number of these
!                    angular sections for the purpose of aligning the flange
!                    profile to a rotated set of volumes. Therefore, 'secang'
!                    must be an integral divisor of 360; e.g., 10,20,30,40,45,
!                    60,90,120,...etc.
!
!       (7) * dhole = bolt hole diameter.
!
!                 * If no holes are desired in the flange, then simply placing
!                   a zero for this argument, or leaving this argument blank,
!                   will create the flange without the bolt holes.
!
!       (8) radbf = radius of the bolt flange, which is the circular profile
!                   surrounding each of the bolt holes around the outer per-
!                   imeter of the flange.
!
!       (9) radout = outer radius of circular flange.
!
!       (10) radin = inside radius of circular flange
!
!       (11) radbh = radius of bolt head
!
!       (12) rfil = flange fillet radii
!
!
!   DESCRIPTION:
!
!   This flange pattern has protruding circular bosses enclosing the bolt holes,
!   with the flange as a simple circular perimeter between the bosses. The flange
!   may contain the evenly spaced holes around the perimeter, or be created with
!   no holes. This configuration is named FLANGE PATTERN #1.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
cnum=arg1
rpt=arg2
zp=arg3
nh=arg4
sta=arg5
secang=arg6
dh=arg7
radbf=arg8
radout=arg9
radin=ar10
radbh=ar11
rfil_=ar12
!
ang=360/nh
!
hole_pattern,cnum,rpt,zp,nh,,sta,360,2*radbf
!
adele,am-(nh-1),am,1,1
!
init_entity_num
!
*do,ii_,1,nh,1
    csys,csn-(nh-ii_)
    k,,rpt-radout,180,0
*enddo
!
csys,cnum
create_lines,1
!
*do,ii_,1,nh,1
    csys,csn-(nh-ii_)
    !
    k,,radbf,190,0
    k,,radbf,0,0
    k,,radbf,170,0
    !
    create_lines,1,1
*enddo
!
isolate_lines
!
lovlap,all
!
init_entity_num
!
*do,ii_,1,nh,1
    csys,csn-(nh-ii_)
    !
    isolate_lines
    ksll,s
    ksel,r,loc,x,0,abs(rpt-radout)
    !
    *if,(rpt-radout),gt,0,then
        ksel,r,loc,y,180
    *elseif,(rpt-radout),lt,0,then
        ksel,r,loc,y,0
    *endif
    !
    lslk,r,0
    ldele,all,,,1
*enddo
!
init_entity_num
!
csys,cnum
isolate_lines
ksll,s
ksel,u,loc,x,radout,radout+radbf+(rpt-radout)
lslk,r,0
ldele,all,,,1
!
init_entity_num
!
isolate_lines
cm,lset1,line
!
*do,ii_,1,nh,1
    csys,cnum
    !
    lsel,s,line,,lset1
    lsel,r,loc,y,((ii_-1)*ang)+sta,((ii_-1)*ang)+sta+ang/2
    !
    get_max_entity
    get_min_entity
    !
    lfillt,lm,l_min,rfil_
    !
    lsel,s,line,,lset1
    lsel,r,loc,y,((ii_-1)*ang)+sta+ang/2,((ii_-1)*ang)+sta+ang
    !
    get_max_entity
    get_min_entity
    !
    lfillt,lm,l_min,rfil_
    !
    init_entity_num
    !
*enddo
!
isolate_lines
!
al,all
!
init_entity_num
!
create_circle,radin,zp,secang,,sta
create_area-lines
!
asba,am-1,am,,delete,delete
!
init_entity_num
!
lplot
!
*if,radbh,gt,0,then
    hole_pattern,cnum,rpt,zp,nh,,sta,360,2*radbh
    !
    asel,s,area,,am-(nh-1),am
    cm,aset1,area
    !
    init_entity_num
    !
    asba,am-nh,aset1,,delete,keep
    !
    init_entity_num
    !
    isolate_areas
    !
    csys,cnum
    !
    asel,r,loc,x,rpt
    cm,aset1,area
    !
    init_entity_num
    !
    lplot
*endif
!
*if,dh,gt,0,then
    hole_pattern,cnum,rpt,zp,nh,,sta,360,dh
    !
    asel,s,area,,am-(nh-1),am
    cm,aset2,area
    !
    init_entity_num
    !
    *if,radbh,gt,0,then
        asba,aset1,aset2,,delete,delete
    *else
        asba,am-nh,aset2,,delete,delete
    *endif
    !
    init_entity_num
    !
    lplot
*endif
!
*set,ang,
*set,cnum,
*set,cstran,
*set,nh,
*set,rpt,
*set,zp,
*set,sta,
*set,secang,
*set,dh,
*set,ii_,
*set,radbf,
*set,radin,
*set,radbh,
*set,rfil_,
cmdele,lset1
!


w:\ansys\mac\tools\flng_ptrn_2.mac.html

!   TITLE:  flng_ptrn_2.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -   04/29/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates an evenly spaced flange pattern around a center
!   line.  This pattern contains the evenly spaced holes around the peri-
!   meter.  This pattern is flange pattern #2, which is a flange with a
!   rounded fillet fitting tangent to the bolt flange profiles.The input
!   variables are as follows:
!
!       csnum = coordinate system number that the pattern is con-
!               structed around (must be a cylindrical c.s.)
!
!       rpat = radius of hole pattern (i.e., the radial distance at
!              which the hole local c.s. is placed)
!
!       zpos = z position relative to 'csnum' at which the pattern
!              is created
!
!       numh = number of holes around the perimeter (if left blank,
!              then the angular increment must be specified)
!
!       stang = start angle at which the pattern is initiated
!
!       secang = the angle subtended by a user defined section of the
!                flange inner radius. The flange inner radius profile
!                will be divided up into an integral number of these
!                angular sections for the purpose of aligning the flange
!                profile to a rotated set of volumes. Therefore, 'secang'
!                must be an integral divisor of 360; e.g., 10,20,30,40,45,
!                60,90,120,...etc.
!
!       dhole = hole diameter
!
!       radbf = radius of the bolt flange, which is the circular profile
!               surrounding each of the bolt holes around the outer per-
!               imeter of the flange.
!
!       radff = radius of the outer perimeter flange fillet between the
!               each of the bolt holes.
!
!       radin = inside radius of flange
!
!       radbh = radius of bolt head
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!               (1)  (2)   (3)  (4)  (5)   (6)    (7)  (8)    (9)   (10)
! FLNG_PTRN_2, cnum, rpt,  zp,  nh,  sta, secang, dh, radbf, radff, radin,
!
!              radbh
!              (11)
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

cnum=arg1
rpt=arg2
zp=arg3
nh=arg4
sta=arg5
secang=arg6
dh=arg7
radbf=arg8
radff=arg9
radin=ar10
radbh=ar11
!
ang=360/nh
stangh=sta
stangff=sta+ang/2
!
y=(asin((rpt/(radbf+radff))*sin((ang/2)*rconv)))*dconv
!
x=180-(ang/2)-y
!
rfc=sqrt(rpt**2+(radbf+radff)**2-2*rpt*(radbf+radff)*cos(x*rconv))
!
hole_pattern,cnum,rpt,zp,nh,,stangh,360,2*radbf
hole_pattern,cnum,rfc,zp,nh,,stangff,360,2*radff
!
init_entity_num
!
adele,am-(2*nh-1),am,1,1
!
init_entity_num
!
*do,ii,(cstran-(cstran-1)),nh,1
    !
    *if,ii,eq,(cstran-(cstran-1)),then
        jj=cstran
        kk=ii+nh
    *else
        jj=ii+(nh-1)
        kk=ii+nh
    *endif
    !
    csys,patcs%jj%
        !
        *if,ii,eq,(cstran-(cstran-1)),then
            k,,radff,2*rtangle,0
            *get,k1,kp,,num,max
        *endif
        !
        k,,radff,(2*rtangle)-y,0
        !
        init_entity_num
        !
        l,km-1,km
        !
        init_entity_num
        !
    csys,patcs%ii%
        !
        k,,radbf,0,0
        !
        init_entity_num
        !
        l,km-1,km
        !
        init_entity_num
        !
    csys,patcs%kk%
        !
        k,,radff,(2*rtangle)+y,0
        !
        *if,ii,ne,nh,then
            k,,radff,2*rtangle,0
        *endif
        !
        init_entity_num
        !
    csys,patcs%ii%
        !
        *if,ii,ne,nh,then
            l,km-2,km-1
        *else
            l,km-1,km
        *endif
        !
    csys,patcs%kk%
        !
        *if,ii,ne,nh,then
            l,km-1,km
        *else
            l,km,k1
        *endif
        !
        init_entity_num
*enddo
!
lsel,selv,line,,lm-(4*nh-1),lm,1
!
al,all
!
init_entity_num
!
csys,cnum
!
*do,ii,sta,sta+4*rtangle-secang,secang
    k,,radin,ii,zp
*enddo
!
init_entity_num
!
sec=4*rtangle/secang
!
*do,ii,1,sec,1
    *if,ii,lt,sec,then
        l,km-(sec-ii),km-((sec-ii)-1)
    *else
        l,km-(sec-ii),km-(ii-1)
    *endif
*enddo
!
init_entity_num
!
lsel,selv,line,,lm-(sec-1),lm,1
!
al,all
!
init_entity_num
!
asba,am-1,am,,delete,delete
!
init_entity_num
!
hole_pattern,cnum,rpt,zp,nh,,stangh,360,2*radbh
!
init_entity_num
!
asel,selv,area,,am-(nh-1),am
cm,aset1,area
!
init_entity_num
!
asba,am-nh,aset1,,delete,keep
!
init_entity_num
!
hole_pattern,cnum,rpt,zp,nh,,stangh,360,dh
!
init_entity_num
!
asel,selv,area,,am-(nh-1),am
cm,aset2,area
!
init_entity_num
!
asba,aset1,aset2,,delete,delete
!
init_entity_num
!
*set,cnum,
*set,nh,
*set,rpt,
*set,zp,
*set,sta,
*set,secang,
*set,stangh,
*set,patang,
*set,dh,
*set,maxang,
*set,m,
*set,ii,
*set,jj,
*set,kk,
*set,zzz,
*set,radbf,
*set,radff,
*set,radin,
*set,radbh,


w:\ansys\mac\tools\oval_area.mac.html

!   TITLE:  oval_area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an oval shaped area.
!
!
!   COMMAND SYNTAX:
!
!                   (1) (2)    (3)     (4)
!        OVAL_AREA, cs, wid, ov_leng, z_loc
!
!
!   ARGUMENTS:
!
!       (1) cs = coordinate system to build area relative to.
!
!       (2) wid = the width of the oval.
!
!       (3) ov_leng = the over-all length of the oval.
!
!       (4) z_loc = location of the plane of the area along the Z axis
!                   of the coordinate system specified in argument 1.
!
!
!   DESCRIPTION:
!
!   The oval is created relative to a coordinate system specified in argument
!   1. This coordinate system aligns itself with the mid-point of the straight
!   edge with the positive Y-axis pointing toward the centroid of the area. The
!   plane of the area is located along the Z axis of the specified C.S. by arg-
!   ument 4. This default value is 0 (i.e., the plane of the area is the XY
!   plane of the specified C.S.).
!
!   The width of the oval is the diameter of the semi-circular ends of the
!   area; and the over-all length is the length of the rectangular mid-sec-
!   tion of the area plus the diameter of the semi-circular ends.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

cs_=arg1
wid_=arg2
ovl_=arg3
zloc_=arg4
!
*get,acs_,active,,csys
!
csys,cs_
!
*get,cstyp_,cdsy,cs_,attr,kcs
!
*if,cstyp_,ne,0,then
    create_cs,0,,0,0,0,0,0,0,0
    cs_=csn+1
    csys,cs_
*endif
!
k,,(ovl_/2)-(wid_/2),0,zloc2_
k,,(ovl_/2)-(wid_/2),wid_,zloc2_
k,,-((ovl_/2)-(wid_/2)),wid_,zloc2_
k,,-((ovl_/2)-(wid_/2)),0,zloc2_
!
create_area
!
clocal,csn+10,0,(ovl_/2)-(wid_/2),wid_/2,0,0,0,0
clocal,csn+11,1,0,0,0,0,0,0
!
*do,abc_,0,270,90
    k,,wid_/2,abc_,zloc_
*enddo
!
create_area,1
!
csys,csn+10
clocal,csn+12,0,-(ovl_-wid_),0,0,0,0,0
clocal,csn+13,1,0,0,0,0,0,0
!
*do,abc_,0,270,90
    k,,wid_/2,abc_,zloc_
*enddo
!
create_area,1
!
aadd,am-2,am-1,am
!
init_entity_num
!
csdele,csn+10,csn+13,1
csys,acs_
!
lplot
!
*set,acs_,
*set,cs_,
*set,wid_,
*set,ovl_,
*set,zloc2_,


w:\ansys\mac\tools\cir_vol_pattern.mac.html

!   TITLE:  cir_vol_pattern.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    03/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a pattern of volumes by repeating an area, or selected
!   set of volumes, about the center of the active coordinate system (CS).
!
!   The active CS may be any type of CS (i.e., cartesian, cylindrical, etc.).
!   The origin of the active CS only serves as a center of rotation for the
!   area pattern. Only the existing area(s) which are to be patterned should
!   be selected.  They are stored in a component group and their pattern
!   repeated about the center of the active CS.
!
!   The pattern of volumes may be created by either specifying the number of
!   patterns, or by specifying the repeat angle of the pattern. In addition,
!   the total pattern angle defaults to 360, or a total pattern angle between
!   0 and 360 may be specified.
!
!   The arguments for this macro are as follows:
!
!       (1)  num_pats = The number of repeat patterns to be created
!                       within the total pattern angle. When specifying
!                       this parameter, argument 2 (ANG_INC) must be
!                       left blank.
!
!       (2)  ang_inc = The angle between repeated area patterns. Specifying
!                      this parameter over-rides argument 1 (NUM_PATS),
!                      and will use this value to create the pattern. This
!                      parameter must be an integral divisor of the total
!                      pattern angle (PAT_ANG).
!
!       (3)  pat_ang = The total pattern angle.  This parameter defaults
!                      to 360, but may be specified with an angle value
!                      between 0 and 360.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                     (1)      (2)      (3)
! CIR_VOL_PATTERN, num_pats, ang_inc, pat_ang
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
numpats_=arg1
anginc_=arg2
patang_=arg3
!
cm,sourcev_,volu
!
*get,basecs_,active,,csys
patcs_=basecs_
*get,ccstyp_,cdsy,basecs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,'patcs_',1,0,0,0,0,0,0
*endif
!
*if,patang_,eq,0,then
    patang_=360
*elseif,patang_,ge,360,then
    patang_=360
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,eq,360,then
        anginc_=patang_/numpats_
        voffset_=2*anginc_
    *else
        anginc_=patang_/(numpats_-1)
        voffset_=anginc_
    *endif
*else
    *if,patang_,eq,360,then
        voffset_=2*anginc_
    *else
        voffset_=anginc_
    *endif
*endif
!
vlnum_=0
!
*do,xyz_,0,(patang_-voffset_),anginc_
    !
    csys,patcs_
    !
    vlnum_=vlnum_+1
    !
    clocal,csn+5,1,0,0,0,vlnum_*anginc_,0,0
    !
    csys,patcs_
    !
    vtran,csn+5,sourcev_,,,,0,0
    !
    init_entity_num
*enddo
!
vlnum_=vlnum_+1
!
vsel,s,volu,,vm-(vlnum_-1),vm,1
cm,vpatrn_,volu
!
init_entity_num
!
csdele,csn+5
csys,basecs_
!
lplot
!
*set,numpats_,
*set,anginc_,
*set,voffset_,
*set,radpat_,
*set,strtang_,
*set,patang_,
*set,vlnum_,
*set,xyz_,
*set,basecs_,
*set,patcs_,
*set,ccstyp_,
cmdele,sourcev_


w:\ansys\mac\tools\cir_bore.mac.html

!   TITLE:  cir_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/15/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   06/27/2001      J. Rinaldi
!
!       Revised code to exclude creation of a coordinate system for creating
!       the bore volume.  It allows yhe use of any type of coordinate system
!       to be used as the active C.S.
!---------------------------------------------------------------------------
!
!   This sub-macro is used to create a circular cylinder or cone-shaped bore
!   into a volume, or set of volumes.  The bore may be a right circular
!   cylinder (phibev = 0), or have a side angle (0 < phibev < 90). For the
!   angled conic bore, the diameter of the circular end surfaces may be
!   specified at the top (opt = 0), or at the bottom (inside base) of the bore.
!
!   The cylindrical or conic shaped bore volume has its axis centered about
!   the Z axis of the active C.S.  It has one end surface coplanar with the XY
!   plane of the active C.S., with the other end located a specified depth,
!   DCUT, in the -Z direction of the active C.S.
!
!   if the depth parameter, DCUT, is left blank ( or 0 ), then a circular area
!   of a specified diameter is created.  This allows the user to duplicate
!   and/or extruded the area into a hole pattern if desired.
!
!   Input arguments are:
!
!       A selected set of volume(s)
!
!       (1) opt = input options:
!
!               0 (or blank) = diameter of cut at the surface of the part
!
!               1 = diameter of cut at the base of the part
!
!       (2) dia_cut = diameter of cut/volume:
!
!               a.) at the surface of the part if OPT=0
!
!               b.) at the base of the part if OPT=1
!
!       (3) dcut = the depth or thickness of the cut. If this argument is 0
!                  or blank, then a circular shaped area is created in the
!                  XY plane of the active C.S. with no depth.
!
!       (4) phibev = angle of bevel as measured from the axis of the
!                    cylindrical cut volume.
!
!
!------------------------------- COMMAND SYNTAX ------------------------------
!
!               (1)    (2)    (3)    (4)
!     CIR_BORE, opt, dia_cut, dcut, phibev
!
!-----------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
cm,v2bcut,volu                          ! selected volume to be (2b) cut
!
*get,ccs_,active,,csys
*get,ccstyp_,cdsy,ccs_,attr,kcs
!
*if,ccstyp_,ne,1,then
    create_cs,0,,1,0,0,0,0,0,0
*endif
!
opt_=arg1
diacut_=arg2
dcut_=arg3
phibev_=arg4
!
x_=dcut_*tan(phibev_*rconv)
!
*if,opt_,eq,1,then
    diacut_=diacut_+2*x_
*endif
!
*do,ii_,0,3*rtangle,rtangle
    k,,diacut_/2,ii_,0
*enddo
!
*if,dcut_,ne,0,then
    *if,(diacut_/2-x_),ge,0,then
        !
        *do,ii_,0,3*rtangle,rtangle
            k,,(diacut_/2-x_),ii_,-dcut_
        *enddo
        !
        init_entity_num
        !
        v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
        !
        init_entity_num
        !
        vsbv,v2bcut,vm,,delete,delete
        !
        init_entity_num
        !
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        !
        init_entity_num
    *endif
*else
    create_area,1
*endif
!
lplot
!
csys,ccs_
!
*set,opt_,
*set,phibev_,
*set,dcut_,
*set,diacut_,
*set,x_,
*set,ii_,
*set,ccs_,
cmdele,v2bcut,


w:\ansys\mac\tools\create_volume.mac.html

!   TITLE:  create_volume.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  08/20/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a volume from a newly created set of keypoints.
!
!
!   COMMAND SYNTAX:
!
!                       (1)    (2)
!       CREATE_VOLUME, c_acs, d_ext
!
!
!   ARGUMENTS:
!
!       (1) c_acs = boolean operator to create lines in the active
!                   coordinate system:
!
!               0 (or blank) = creates straight lines between KP's,
!                              regardless of active c.s.
!
!               1 = creates lines in active c.s.
!
!       (2) d_ext = extrusion distance of area that forms the new volume.
!
!
!   DESCRIPTION:
!
!   The keypoints are connected by lines which will bound a newly formed
!   area. This is achieved by using the macro command CREATE_AREA, and
!   extruding a given distance, D_EXT.  The arguments used here are the same
!   as in CREATE_LINES, except for SEQNCE which is not used since the lines
!   must form a closed loop in order to create an area. Therefore, option
!   zero (0 or blank) is always specified in CREATE_LINES, which is called
!   in CREATE_AREA. The value of C_ACS is transferred directly to
!   CREATE_LINES, along with the 0 value of SEQNCE. The argument D_EXT is
!   transferred to the ANSYS command VOFFST. (See CREATE_LINES for the options
!   on the C_ACS argument)
!
!   In the case that it is desired to retain the base area that is created and
!   extruded to form the new volume, this area number is stored in the parameter
!   A_BASE, and returned to the main part macro for use in future operations, if
!   desired.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_cacs=arg1
_dext=arg2
!
create_area,_cacs
!
a_base=am
voffst,am,_dext
!
init_entity_num
!
lplot
!
*set,_dext,
*set,_cacs,


w:\ansys\mac\tools\create_vol-lines.mac.html

!   TITLE:  create_vol-lines.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  11/17/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a volume from a newly created set of lines. The
!   set of lines must form a closed loop which bound an area. The algorithm
!   then isolates the lines and forms the area, and then extrudes the area
!   a given distance, D_EXT.  The argument D_EXT is transferred to the ANSYS
!   command VOFFST.
!
!   In the case that it is desired to retain the base area that is created and
!   extruded to form the new volume, this area number is stored in the parameter
!   A_BASE, and returned to the main part macro for use in future operations.
!
!
!           d_ext = extrusion distance of area that forms the new volume.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! CREATE_VOL-LINES, d_ext
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_dext=arg1
!
create_area-lines
!
a_base=am
voffst,am,_dext
!
init_entity_num
!
lplot
!
*set,_dext,


w:\ansys\mac\tools\create_vol-area.mac.html

!   TITLE:  create_vol-area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  11/18/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a volume from a newly created area. The algorithm
!   isolates the area and extrudes it a given distance, D_EXT.  The argument
!   D_EXT is transferred to the ANSYS command VOFFST.
!
!   In the case that it is desired to retain the base area that is extruded
!   to form the new volume, this area number is stored in the parameter
!   A_BASE, and returned to the main part macro for use in future operations.
!
!
!           d_ext = extrusion distance of area that forms the new volume.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! CREATE_VOL-AREA, d_ext
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_dext=arg1
!
init_entity_num
!
isolate_areas
!
get_max_entity
!
a_base=am
voffst,am,_dext
!
init_entity_num
!
lplot
!
*set,_dext,


w:\ansys\mac\tools\extrude_aset.mac.html

!   TITLE:  extrude_aset.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/02/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro extrudes a selected set of areas by a given
!   distance, dext.  It then restores the selected set to the full
!   model set that is currently under construction. The only input
!   necessary is:
!
!       A selected set of areas (each to be extruded)
!
!       dext = extrusion distance
!
!--------------------------------- COMMAND SYNTAX --------------------------
!
! EXTRUDE_ASET, dext
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

!
_dext=arg1
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*do,_iii,_alow,_ahigh,1
    *if,asel(_iii),eq,1,then
        voffst,_iii,_dext
    *endif
*enddo
!
init_entity_num
!
*set,_dext,
*set,_iii,
*set,_alow,
*set,_ahigh,


w:\ansys\mac\tools\hollow_cylinder.mac.html

!   TITLE:  hollow_cylinder.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -    08/25/2000     J. Rinaldi
!---------------------------------------------------------------------------
!
!   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.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                   (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,


w:\ansys\mac\tools\revolve_aset.mac.html

!   TITLE:  revolve_aset.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!   Rev -   RELEASED    06/14/2000      J. Rinaldi
!---------------------------------------------------------------------------
!   Rev A   09/28/2001      J. Rinaldi
!
!   Allows the option to use a specified coordinate system to revolve around
!   Z axis of. This eliminates the necessity for creating keypoints to revolve
!   about if they are not already available.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro revolves a selected set of areas around an axis defined by
!   2 keypoints, or an axis defined by the Z axis of a specified coordinate
!   system.
!
!
!   COMMAND SYNTAX:
!
!       -- OPTION 1:
!
!                             (1)   (2)    (3)     (4)
!               REVOLVE_ASET, axp1, axp2, revang, numseg
!
!
!       -- OPTION 2:
!
!                              (1)    (2)     (3)
!               REVOLVE_ASET, csnum, revang, numseg
!
!
!   ARGUMENTS:
!
!       -- OPTION 1:
!
!           (1) axp1 = 1st axis point of revolution
!
!           (2) axp2 = 2nd axis point of revolution
!
!           (3) revang = total angle of revolution of selected areas
!
!           (4) numseg = number of volume segments in the revolve angle (revang)
!
!
!       -- OPTION 2:
!
!           (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)
!
!
!   DESCRIPTION:
!
!   -- OPTION 1:
!
!   The selected set of areas are revolved about an axis defined by 2 keypoints,
!   AXP1 and AXP2. The total angle of revolve is defined by REVANG; and the
!   number of volume segments in the revolve are specified by NUMSEG.
!
!
!   -- OPTION 2:
!
!   The selected set of areas are revolved about the Z axis of a specified co-
!   ordinate system. The total angle of revolve is defined by REVANG; and the
!   number of volume segments in the revolve are specified by NUMSEG. The rot-
!   ation direction is consistent with the vector definition of the right-hand
!   rule, with positive rotations counter-clockwise about the positive Z axis.
!
!   -- GENERAL:
!
!   Either option is exercised by the algorithm automatically. When the 4th
!   argument is used, i.e., the total number of revolve volumes is greater
!   than or equal to 1, then option 1 is used. When the 4th argument is left
!   blank, option 2 is used.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

numseg_=arg4
!
*get,alow_,area,,num,min
*get,ahigh_,area,,num,max
!
*if,numseg_,ge,1,then
    axp1_=arg1
    axp2_=arg2
    revang_=arg3
    !
    *do,iiii_,alow_,ahigh_,1
        *if,asel(iiii_),ne,0,then
            vrotat,iiii_,,,,,,axp1_,axp2_,revang_,numseg_
        *endif
    *enddo
*else
    csnum_=arg1
    revang_=arg2
    numseg_=arg3
    !
    *get,actcs_,active,,csys
    !
    csys,csnum_
    !
    *get,cstyp_,cdsy,csnum_,attr,kcs
    !
    *if,cstyp_,ne,0,then
        create_cs,0,,0,0,0,0,0,0,0
        csnum_=csn+1
    *endif
    !
    k,,0,0,0
    k,,0,0,1
    !
    get_max_entity
    !
    axp1_=km-1
    axp2_=km
    !
    *do,iiii_,alow_,ahigh_,1
        *if,asel(iiii_),ne,0,then
            vrotat,iiii_,,,,,,axp1_,axp2_,revang_,numseg_
        *endif
    *enddo
    !
    kdele,axp1_,axp2_,1
    !
    csys,actcs_
    !
    *set,csnum_,
    *set,actcs_,
    *set,cstyp_,
*endif
!
init_entity_num
!
lplot
!
*set,iiii_,
*set,axp1_,
*set,axp2_,
*set,revang_,
*set,numseg_,
*set,alow_,
*set,ahigh_,


w:\ansys\mac\tools\subassy_revolve.mac.html

!   TITLE:  subassy_revolve.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!   Rev -   RELEASED    06/05/2001      D. Edwards
!---------------------------------------------------------------------------
!   Rev A   07/11/2001      J. Rinaldi
!
!   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 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
!
*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
!
init_entity_num
!
*if,shropt_,eq,0,then
    aglue,all
    init_entity_num
*endif
!
csys,revcs_
    k,,0,0,0
    k,,0,0,1
init_entity_num
!
axp11_=km-1
axp12_=km
!
revolve_aset,axp11_,axp12_,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_,


w:\ansys\mac\tools\trim.mac.html

!   TITLE:  trim.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/05/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro trims the length of a line.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)     (3)
!               TRIM, line#, kp#, trim_leng
!
!
!   ARGUMENTS:
!
!       (1) line# = number of the line to extend
!
!       (2) kp# = end keypoint number to extend from
!
!       (3) trim_leng = the amount of length to trim line
!
!
!   DESCRIPTION:
!
!   The line is trimmed (shortened) from the specified end keypoint side. The
!   original length of the line is shortened in length by the amount specified
!   in argument 3, 'trim_leng'.
!
!   If the end keypoint is attached to only 1 line, then the line number
!   need not be specified; only arguments 2 and 3. In this case, the line
!   is trimmed to make 1 shorter line. If the end keypoint is attached to more
!   than 1 line, then the line number to be extended must be specified.
!
!   The end keypoint may be attached to other lines, but the original line must
!   not be attached to any higher order entities (i.e., areas, volumes, etc.).
!   This command is valid only for straight lines.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

baseln_=arg1
endkp_=arg2
triml_=arg3
!
init_entity_num
!
ksel,s,kp,,endkp_
lslk,s,0
get_max_entity
lhold_=lm
*get,numlns_,line,,count
!
init_entity_num
!
*if,numlns_,eq,1,then
    baseln_=lhold_
*endif
!
*get,kp1_,line,baseln_,kp,1
*get,kp2_,line,baseln_,kp,2
!
*if,kp1_,eq,endkp_,then
    kxp_=kp2_
*else
    kxp_=kp1_
*endif
!
*get,acs1_,active,,csys
!
clocal,csn+5,1,kx(endkp_),ky(endkp_),kz(endkp_),0,0,0
kxpang_=ky(kxp_)
clocal,csn+6,0,0,0,0,kxpang_,0,0
!
k,,0,1,0
init_entity_num
kpln_=km
!
cskp,csn+7,0,endkp_,kxp_,kpln_
!
kdele,kpln_
init_entity_num
!
*if,triml_,gt,0,then
    k,,triml_,0,0
    !
    init_entity_num
    !
    lstr,endkp_,km
    !
    init_entity_num
    !
    lovlap,baseln_,lm
    !
    init_entity_num
    !
    ldele,lm-1,,,1
    !
    init_entity_num
*endif
!
csdele,csn+5,csn+7,1
csys,acs1_
!
lplot
!
*set,baseln_,
*set,endkp_,
*set,kpln_,
*set,kp1_,
*set,kp2_,
*set,acs1_,
*set,triml_,
*set,lhold_,
*set,numlns_,
*set,kxp_,
*set,kxpang_,


w:\ansys\mac\tools\drill_pattern.mac.html

!   TITLE:  drill_pattern.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -  RELEASED     11/8/2001       J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an evenly spaced drill pattern in a selected set
!   of volumes around a center axis.
!
!
!   COMMAND SYNTAX:
!
!                       (1)   (2)    (3)   (4)   (5)     (6)    (7)
!       DRILL_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang,
!
!                       (8)   (9)    (10)    (11)    (12)
!                      dhole, tool, depth, r_or_ang, btol
!
!
!   ARGUMENTS:
!
!       (1) csnum = coordinate system number whose Z axis the pattern is con-
!                   structed around (need not be a cylindrical c.s.).
!
!       (2) rpat = radius of hole pattern (i.e., the radial distance at
!                  which the hole local c.s. is placed)
!
!       (3) zpos = z position relative to 'csnum' from which the pattern
!                  is created
!
!       (4) numh = number of holes around the perimeter (if left blank,
!                  then the angular increment must be specified)
!
!       (5) anginc = angular spacing increment for the hole pattern
!                    (if left blank, then the number of holes must
!                    be specified)
!
!       (6) stang = start angle at which the pattern is initiated
!
!       (7) patang = the total pattern angle, measured from 'stang'
!                    (if left blank, defaults to 360)
!
!       (8) dhole = hole diameter
!
!       (9) tool = tool type:
!
!                   'f' = flat cutting tool
!                   'b' = ball cutting tool
!                   'c' = cone-shaped cutting tool
!
!       (10) depth = hole depth as measured from 'zpos' (argument 3)
!
!       (11) r_or_ang = specification of cutting tool fillet radius OR
!                       angle
!
!                   (a) If 'tool' = 'f', then this argument specifies
!                       the fillet radius of the flat cutting tool.
!
!                   (b) If 'tool' = 'c', then this argument specifies
!                       the angle of the conic cutting tool.
!
!                   NOTE: For 'tool' = 'b', this argument is ignored.
!
!       (12) btol = boolean tolerance value:
!
!                   0 (or blank) = 0.0001   (default)
!                   1 = 0.001
!                   2 = 0.01
!
!           Note: This argument need only be specified when the volume addition
!                 or subtraction operations fail at the creation of the tool.
!                 If an operation fails, then simply go to the next higher level
!                 boolean tolerance (first 0, then 1, then 2), and reattempt the
!                 operation.
!
!
!   DESCRIPTION:
!
!   The drill pattern is used for creating drilled holes in a circumferential
!   pattern around the Z axis of a specified C.S. in argument 1. This C.S. does
!   not need to be a cylindrical C.S., but have its Z axis oriented in the
!   desired direction for creating the pattern. The +Z axis must be oriented
!   out of the part, which is the opposite direction to the direction of drill.
!
!   The Z position of the drill pattern may be specified so that the proper
!   hole depth may be drilled.  From this Z position the hole depth is calc-
!   ulated in the -Z direction (see 'mach_op.mac' help).
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

csnum_=arg1
rpat_=arg2
zpos_=arg3
numh_=arg4
anginc_=arg5
stang_=arg6
patang_=arg7
dhole_=arg8
ttyp_=arg9
dpth_=ar10
rorang_=ar11
bt_=ar12
!
cm,vset1_,volu
!
*get,actcs_,active,,csys
!
*if,patang_,eq,0,then
    patang_=4*rtangle
*endif
!
*if,numh_,eq,0,then
    numh_=patang_/anginc_
*endif
!
*if,anginc_,eq,0,then
    *if,patang_,lt,4*rtangle,then
        anginc_=patang_/(numh_-1)
    *else
        anginc_=patang_/numh_
    *endif
    !
*endif
!
*if,patang_,eq,4*rtangle,then
    maxang_=stang_+patang_-anginc_
*else
    maxang_=stang_+patang_
*endif
!
csys,csnum_
!
*get,acs_,active,,csys
*get,acstyp_,cdsy,acs_,attr,kcs
!
*if,acstyp_,ne,1,then
    clocal,csn+20,1,0,0,0,0,0,0
    csnum_=csn+20
*endif
!
clocal,csn+21,0,rpat_,stang_,zpos_,0,0,0
!
mach_op,,ttyp_,dhole_,rorang_,dpth_,csn+21,bt_
!
cmsel,u,vset1_
csys,csnum_
cir_vol_pattern,numh_,anginc_,patang_
!
vsbv,vset1_,vpatrn_,,delete,delete
init_entity_num
!
csdele,csn+20,csn+21,1
csys,actcs_
!
lplot
!
*set,csnum_,
*set,rpat_,
*set,zpos_,
*set,numh_,
*set,anginc_,
*set,stang_,
*set,patang_,
*set,dhole_,
*set,maxang_,
*set,rorang_,
*set,actcs_,
*set,acs_,
*set,acstyp_,


w:\ansys\mac\tools\fil_rec_bore.mac.html

!   TITLE:  fil_rec_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/20/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates a filleted rectangular shaped bore into a
!   selceted volume. It is similar to REC_BORE.MAC, but now has fillets
!   in the corners.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume
!
!       opt = input options: 1,2,3,4,5,6,7,8,9,10,11 or 12
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       dcut = the depth or thickness of the volume
!       phibev = angle of bevel as measured from the normal
!            to the rectangular surfaces (from volume cut
!            coordinate system z axis)
!       xwcut = width of cut/volume (along local c.s. x axis)
!       yhcut = height of cut/volume (along local c.s. y axis)
!       x23 = x coordinate value for KP's in quadrants 2 and 3
!       x14 = x coordinate value for KP's in quadrants 1 and 4
!       y12 = y coordinate value for KP's in quadrants 1 and 2
!       y34 = y coordinate value for KP's in quadrants 3 and 4
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for options 1,2,7 and 8 (See below). From
!   this c.s., the local coordinate system building this volume is placed.
!   Options 3,4,9 and 10 allow construction of the cut volume from a c.s.
!   defined by 3 KP's. Lastly, options 5,6,11 and 12 allow construction from
!   a pre-existing c.s.  Options 7 thru 12 correspond to the same input as
!   1 thru 6, except that these options are used when the dimensions of the
!   base rectangle are specified.
!
!
!   The 12 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       2.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       3.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       4.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       5.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       6.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       7.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       8.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       9.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       10. Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       11. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       12. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!
!----------------------- COMMAND SYNTAX / OPTION 1 & 7 -----------------------
!
!               (1)   (2)    (3)    (4)    (5)     (6)     (7)    (8)  (9)
! FIL_REC_BORE, opt, xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc, x23, x14,
!
!               y12,  y34,  dcut, phibev, filrad
!               (10)  (11)  (12)   (13)    (14)
!
!-------------------------------- OPTION 2 & 8 -------------------------------
!
!               (1)   (2)    (3)    (4)    (5)     (6)      (7)    (8)
! FIL_REC_BORE, opt, xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc, xwcut,
!
!               yhcut, dcut, phibev, filrad
!                (9)   (10)   (11)    (12)
!
!-------------------------------- OPTION 3 & 9 -------------------------------
!
!               (1)   (2)  (3)  (4) (5)  (6)  (7)  (8)  (9)    (10)    (11)
! FIL_REC_BORE, opt,  p1,  p2,  p3, x23, x14, y12, y34, dcut, phibev, filrad
!
!-------------------------------- OPTION 4 & 10 ------------------------------
!
!               (1)   (2)  (3)  (4)  (5)    (6)    (7)   (8)      (9)
! FIL_REC_BORE, opt,  p1,  p2,  p3, xwcut, yhcut, dcut, phibev, filrad
!
!-------------------------------- OPTION 5 & 11 ------------------------------
!
!               (1)   (2)  (3)  (4)  (5)  (6)  (7)    (8)     (9)
! FIL_REC_BORE, opt, acs1, x23, x14, y12, y34, dcut, phibev, filrad
!
!-------------------------------- OPTION 6 & 12 -------------------------------
!
!               (1)  (2)    (3)    (4)   (5)    (6)     (7)
! FIL_REC_BORE, opt, acs1, xwcut, yhcut, dcut, phibev, filrad
!
!-----------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

!
opt=arg1
!
*if,opt,eq,1,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    x23=arg8
    x14=arg9
    y12=ar10
    y34=ar11
    dcut=ar12
    phibev=ar13
    filrad=ar14
*endif
!
*if,opt,eq,2,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    xwcut=arg8
    yhcut=arg9
    dcut=ar10
    phibev=ar11
    filrad=ar12
*endif
!
*if,opt,eq,3,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    x23=arg5
    x14=arg6
    y12=arg7
    y34=arg8
    dcut=arg9
    phibev=ar10
    filrad=ar11
*endif
!
*if,opt,eq,4,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    xwcut=arg5
    yhcut=arg6
    dcut=arg7
    phibev=arg8
    filrad=arg9
*endif
!
*if,opt,eq,5,then
    acs1=arg2
    !
    x23=arg3
    x14=arg4
    y12=arg5
    y34=arg6
    dcut=arg7
    phibev=arg8
    filrad=arg9
*endif
!
*if,opt,eq,6,then
    acs1=arg2
    !
    xwcut=arg3
    yhcut=arg4
    dcut=arg5
    phibev=arg6
    filrad=arg7
*endif
!
*if,opt,eq,7,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    x23=arg8
    x14=arg9
    y12=ar10
    y34=ar11
    dcut=ar12
    phibev=ar13
    filrad=ar14
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,8,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    xwcut=arg8
    yhcut=arg9
    dcut=ar10
    phibev=ar11
    filrad=ar12
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,9,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    x23=arg5
    x14=arg6
    y12=arg7
    y34=arg8
    dcut=arg9
    phibev=ar10
    filrad=ar11
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,10,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    xwcut=arg5
    yhcut=arg6
    dcut=arg7
    phibev=arg8
    filrad=arg9
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,11,then
    acs1=arg2
    !
    x23=arg3
    x14=arg4
    y12=arg5
    y34=arg6
    dcut=arg7
    phibev=arg8
    filrad=arg9
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,12,then
    acs1=arg2
    !
    xwcut=arg3
    yhcut=arg4
    dcut=arg5
    phibev=arg6
    filrad=arg7
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
get_max_entity
!
cm,v2bcut,volu      ! selected volume to be (2b) cut
!
*if,opt,eq,1,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,3,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,4,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,5,then
    csys,acs1
*endif
!
*if,opt,eq,6,then
    csys,acs1
*endif
!
*if,opt,eq,7,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,8,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,9,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,10,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,11,then
    csys,acs1
*endif
!
*if,opt,eq,12,then
    csys,acs1
*endif
!
*if,opt,eq,2,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,4,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,6,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,1,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,3,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,5,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,8,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,10,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,12,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,7,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,9,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,11,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
create_lines
!
*do,ii,1,4,1
    *if,ii,lt,4,then
        lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
    *else
        lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
    *endif
*enddo
!
init_entity_num
!
lsel,selv,line,,lm-7,lm
!
al,all
!
init_entity_num
!
a1=am
!
x=dcut*tan(phibev*rconv)
!
*if,opt,eq,2,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,4,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,6,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,1,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,3,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,5,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,8,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,10,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,12,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,7,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,9,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,11,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            create_lines
            !
            *do,ii,1,4,1
               *if,ii,lt,4,then
                    lfillt,lm-(4-ii),lm-((4-ii)-1),filrad,km+(3*ii)
               *else
                    lfillt,lm-(4-ii),lm-(ii-1),filrad,km+(3*ii)
               *endif
            *enddo
            !
            init_entity_num
            !
            lsel,selv,line,,lm-7,lm
            !
            al,all
            !
            init_entity_num
            !
            a2=am
            !
            a,km-1,km-17,km-18,km-2
            a,km-10,km-26,km-27,km-11
            a,km-8,km-24,km-23,km-7
            a,km-5,km-21,km-20,km-4
            !
            a,km-11,km-27,km-17,km-1
            a,km-8,km-24,km-26,km-10
            a,km-7,km-23,km-21,km-5
            a,km-2,km-18,km-20,km-4
            !
            init_entity_num
            !
            asel,s,area,,am-9,am,1
            !
            va,all
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,x23,
*set,x14,
*set,y12,
*set,y34,
*set,phibev,
*set,dcut
*set,xwcut
*set,yhcut
*set,x,
*set,ii,


w:\ansys\mac\tools\hole_pattern.mac.html

!   TITLE:  hole_pattern.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -       04/29/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an evenly spaced circular hole pattern about the
!   Z axis of a selected coordinate system.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)   (4)     (5)    (6)    (7)     (8)
!       HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang, dhole
!
!
!   ARGUMENTS:
!
!       (1) csnum = coordinate system number that the pattern is con-
!                   structed around (must be a cylindrical c.s.)
!
!       (2) rpat = radius of hole pattern (i.e., the radial distance at
!                  which the hole local c.s. is placed)
!
!       (3) zpos = z position relative to 'csnum' at which the pattern
!                  is created
!
!       (4) numh = number of holes around the perimeter (if left blank,
!                  then the angular increment must be specified)
!
!       (5) anginc = angular spacing increment for the hole pattern
!                    (if left blank, then the number of holes must
!                    be specified)
!
!       (6) stang = start angle at which the pattern is initiated
!
!       (7) patang = the total pattern angle, measured from 'stang'
!                    (if left blank, defaults to 360)
!
!       (8) dhole = hole diameter
!
!
!   DESCRIPTION:
!
!   The macro is used for creating a series of cylindrical holes in a part
!   area or volumes(s), or for creating a circular patterned set of new
!   cylindrical parts.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
csnum=arg1
rpat_=arg2
zpos=arg3
numh=arg4
anginc=arg5
stang=arg6
patang=arg7
dhole=arg8
!
*if,patang,eq,0,then
    patang=4*rtangle
*endif
!
*if,numh,eq,0,then
    numh=patang/anginc
*endif
!
*if,anginc,eq,0,then
    *if,patang,lt,4*rtangle,then
        anginc=patang/(numh-1)
    *else
        anginc=patang/numh
    *endif
    !
*endif
!
*if,patang,eq,4*rtangle,then
    maxang=stang+patang-anginc
*else
    maxang=stang+patang
*endif
!
*if,cstran,ne,0,then        ! coordinate system counter
    mm=cstran+1
*else
    mm=1
*endif
!
csys,csnum
!
*do,ii,stang,maxang,anginc
    !
    create_cs,0,'patcs%mm%',1,rpat_,ii,zpos,0,0,0
    !
    cstran=mm               ! c.s. transfer parameter
    !
    *do,jj,0,3*rtangle,rtangle
        k,,dhole/2,jj,0
    *enddo
    !
    init_entity_num
    !
    a,km-3,km-2,km-1,km
    !
    csys,csnum
    !
    mm=mm+1
*enddo
!
init_entity_num
!
*set,csnum,
*set,rpat_,
*set,zpos,
*set,numh,
*set,anginc,
*set,stang,
*set,patang,
*set,dhole,
*set,maxang,
*set,mm,
*set,ii,
*set,jj,
!


w:\ansys\mac\tools\mach_op.mac.html

!   TITLE:  mach_op.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      11/06/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro performs machining operations on a selected set of
!   solid model volumes.
!
!
!   COMMAND SYNTAX:
!
!       (a) DRILLING / BORING (op_typ = 'd'):
!
!                     (1)      (2)       (3)     (4)      (5)   (6)  (7)
!           MACH_OP, op_typ, tool_typ, d_tool, r_or_ang, depth, rcs, btol
!
!
!       (b) MILLING (op_typ = 'm'):
!
!                     (1)      (2)       (3)     (4)      (5)   (6)
!           MACH_OP, op_typ, tool_typ, d_tool, r_or_ang, depth, rcs
!
!
!       (c) TURNING (op_typ = 't'):
!
!                     (1)      (2)       (3)     (4)      (5)   (6)   (7)
!           MACH_OP, op_typ, tool_typ, d_tool, r_or_ang, depth, rcs, rsurf
!
!                     (8)    (9)    (10)  (11)
!                    stang, finang, zpos, btol
!
!
!   ARGUMENTS:
!
!       Arguments common to ALL machining operations:
!
!           (1) op_typ = machining operation type:
!
!                   'd' = drilling / boring
!                   'm' = milling
!                   't' = turning
!
!               If left blank, the algorithm defaults to creating a
!               cutting tool with no succesive operations.
!
!           (2) tool_typ = tool type:
!
!                   'f' = flat cutting tool
!                   'b' = ball cutting tool
!                   'c' = cone-shaped cutting tool
!
!           (3) d_tool =  tool diameter
!
!           (4) r_or_ang = specification of cutting tool fillet radius OR
!                          angle
!
!                   (a) If 'tool_typ' = 'f', then this argument specifies
!                       the fillet radius of the flat cutting tool.
!
!                   (b) If 'tool_typ' = 'c', then this argument specifies
!                       the angle of the conic cutting tool.
!
!                   NOTE: For 'tool_typ' = 'b', this argument is ignored.
!
!           (5) depth = drilling/milling cut depth
!
!           (6) rcs = relative coordinate system. The drilling operation
!                     is performed relative to this C.S. such that:
!
!               (a) the drilling/boring operation is normal to the XY plane,
!                   and centered along the Z axis of this coordinate system.
!
!               (b) the drilling/boring operation is in the -Z direction, with
!                   the cut depth measured from the origin (Z=0) into a part
!                   volume a depth Z = -depth. (This implies that the +Z axis
!                   points out of the part volume)
!
!               NOTE: 'rcs' may be any coordinate system type.
!
!       Argument specific to DRILLING operations:
!
!           (7) btol = boolean tolerance value:
!
!                   0 (or blank) = 0.0001   (default)
!                   1 = 0.001
!                   2 = 0.01
!
!           Note: This argument need only be specified when the volume addition
!                 or subtraction operations fail at the creation of the tool.
!                 If an operation fails, then simply go to the next higher level
!                 boolean tolerance (first 0, then 1, then 2), and reattempt the
!                 operation.
!

!       (3) path_typ = cutting path type:
!
!                   'p' = planar
!                   't' = turning
!
!
!   DESCRIPTION:
!
!   The array can be input up to 18 elements.  These angles are the
!   volume interval distances around a circle that the user defines for
!   input into PROFILE_BORE.MAC. This allows for the user to specify a
!   special shaped profile volume at the angular intervals of this array.
!   All angles must be placed in a clockwise order for correct execution
!   in ANG_DIFF.MAC.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

cm,v2bcut_,volu
!
optyp_=arg1
ttyp_=arg2
dtool_=arg3
dpth_=arg5
rcs_=arg6
!
*get,opptyp_,parm,optyp_,type
!
*if,opptyp_,eq,0,then
    optyp_='x'
*endif
!
csys,rcs_
!
*get,acs_,active,,csys
*get,acstyp_,cdsy,acs_,attr,kcs
!
*if,optyp_,eq,'t',then
    rsrf_=arg7
    sta_=arg8
    fina_=arg9
    zp_=ar10
    !
    *if,acstyp_,ne,1,then
        clocal,csn+10,1,0,0,0,0,0,0
        rccs_=csn+10
    *else
        rccs_=rcs_
    *endif
    !
    clocal,csn+11,0,rsrf_,sta_,zp_,0,0,90
    rcs_=csn+11
*else
    *if,acstyp_,ne,0,then
        clocal,csn+10,0,0,0,0,0,0,0
        rcs_=csn+10
    *endif
*endif
!
*if,ttyp_,eq,'f',then
    rtool_=arg4
    !
    k,,0,0,-dpth_
    k,,dtool_/2,0,-dpth_
    k,,dtool_/2,0,1
    k,,0,0,1
    !
    create_lines
    !
    ln_fillet,km-2,rtool_
    create_area-lines
    !
    *if,optyp_,eq,'x',then
        asel,s,area,,am
        revolve_aset,km-2,km-5,360,4
    *elseif,optyp_,eq,'d',then
        asel,s,area,,am
        revolve_aset,km-2,km-5,360,4
    *else
        arsym,x,am,,,,1,0
    *endif
    !
    *set,rtool_,
*elseif,ttyp_,eq,'b',then
    k,,dtool_/2,0,-dpth_+(dtool_/2)
    k,,dtool_/2,0,1
    k,,0,0,1
    k,,0,0,-dpth_
    !
    create_lines,,1
    !
    clocal,csn+12,1,0,0,-dpth_+(dtool_/2),0,90,0
    l,km,km-3
    !
    init_entity_num
    !
    csys,rcs_
    !
    create_area-lines
    !
    *if,optyp_,eq,'x',then
        asel,s,area,,am
        revolve_aset,km,km-1,360,4
    *elseif,optyp_,eq,'d',then
        asel,s,area,,am
        revolve_aset,km,km-1,360,4
    *else
        arsym,x,am,,,,1,0
    *endif
    !
    csdele,csn+12
*elseif,ttyp_,eq,'c',then
    angtool_=arg4
    !
    k,,0,0,-dpth_
    k,,dtool_/2,0,-dpth_+((dtool_/2)/tan((angtool_/2)*rconv))
    k,,dtool_/2,0,1
    k,,0,0,1
    !
    create_area
    !
    *if,optyp_,eq,'x',then
        asel,s,area,,am
        revolve_aset,km-3,km,360,4
    *elseif,optyp_,eq,'d',then
        asel,s,area,,am
        revolve_aset,km-3,km,360,4
    *else
        arsym,x,am,,,,1,0
    *endif
    !
    *set,angtool_,
*endif
!
*if,optyp_,eq,'x',then
    bt_=arg7
    !
    *if,bt_,eq,1,then
        btol,0.001
    *elseif,bt_,eq,2,then
        btol,0.01
    *endif
    !
    vadd,vm-3,vm-2,vm-1,vm
    btol,defa
    init_entity_num
*elseif,optyp_,eq,'d',then
    bt_=arg7
    !
    *if,bt_,eq,1,then
        btol,0.001
    *elseif,bt_,eq,2,then
        btol,0.01
    *endif
    !
    vadd,vm-3,vm-2,vm-1,vm
    btol,defa
    init_entity_num
    !
    vsel,s,volu,,vm
    cm,vcut_,volu
    init_entity_num
    !
    vsbv,v2bcut_,vcut_,,delete,delete
    init_entity_num
*elseif,optyp_,eq,'m',then

*elseif,optyp_,eq,'t',then
    csys,rccs_
    !
    k,,rsrf_-dpth_,fina_,zp_
    init_entity_num
    !
    l,kp(rsrf_-dpth_,sta_,zp_),km
    init_entity_num
    dln_=lm
    !
    aadd,am-1,am
    init_entity_num
    !
    vdrag,am,,,,,,dln_
    ldele,dln_,,,1
    !
    init_entity_num
    v1_=vm
    !
    bt__=ar11
    !
    acs__=acs_
    ttyp__=ttyp_
    optyp__=optyp_
    dtool__=dtool_
    dpth__=dpth_
    rorang_=arg4
    !
    cmsel,s,v2bcut_
    cm,v2bc__,volu
    init_entity_num
    !
    csys,rccs_
    clocal,csn+13,0,rsrf_,sta_,zp_,0,0,90
    !
    *if,bt__,eq,1,then
        btol,0.001
    *elseif,bt__,eq,2,then
        btol,0.01
    *endif
    !
    mach_op,,'%ttyp__%',dtool__,rorang_,dpth__,csn+13,bt__
    v2_=vm
    !
    csys,rccs_
    clocal,csn+13,0,rsrf_,fina_,zp_,0,0,90
    !
    mach_op,,'%ttyp__%',dtool__,rorang_,dpth__,csn+13,bt__
    v3_=vm
    !
    *if,bt__,eq,1,then
        btol,0.001
    *elseif,bt__,eq,2,then
        btol,0.01
    *endif
    !
    vsel,s,volu,,v1_
    vsel,a,volu,,v2_
    vsel,a,volu,,v3_
    cm,vcut_,volu
    !
    init_entity_num
    vsbv,v2bc__,vcut_,,delete,delete
    init_entity_num
    !
    *set,rccs_,
    *set,rsrf_,
    *set,sta_,
    *set,fina_,
    *set,zp_,
    *set,v1_,
    *set,v2_,
    *set,v3_,
    *set,bt__,
    *set,ttyp__,
    *set,dtool__,
    *set,dpth__,
    *set,rorang_,
    cmdele,v2bc__
*endif
!
*if,acstyp_,ne,0,then
    csdele,rcs_
*endif
!
init_entity_num
!
*get,opptyp__,parm,optyp__,type
!
*if,opptyp__,ne,-1,then
    csys,acs__
    *set,acs__,
    *set,optyp__,
*else
    csys,acs_
    *set,acs_
*endif
!
csdele,csn+10,csn+13,1
!
lplot
!
*set,optyp_,
*set,opptyp_,
*set,opptyp__,
*set,ttyp_,
*set,dtool_,
*set,dpth_,
*set,rcs_,
*set,bt_,
*set,acstyp_,
cmdele,v2bcut_,
cmdele,vcut_,


w:\ansys\mac\tools\test_mach_op.mac.html

!   TITLE: test_mach_op.mac
!
mod_assemb_prep
!
r=3
l=8
!
csys,0
!
create_circle,r
create_vol-lines,l
!
!create_cs,0,'sfcut',2,0,r,l/2,0,-90,0
!create_cs,0,'sfcut',0,0,0,l/2,0,-90,0
!
!                     (1)      (2)       (3)     (4)      (5)   (6)   (7)
!           MACH_OP, op_typ, tool_typ, d_tool, r_or_ang, depth, rcs, rsurf
!
!                     (8)    (9)    (10)
!                    stang, finang, zpos
!
!MACH_OP,'d','c',2,120,4.1,sfcut
!MACH_OP,'t','b',1,,1,1,r,0,150,3,0
!MACH_OP,'t','f',1,0.1,1,1,r,0,130,3,0
MACH_OP,'t','c',1,120,1,1,r,0,130,3,0
!
!MACH_OP,,'b',1,0.1,0,sfcut
!MACH_OP,,'b',2,120,4.1,sfcut
!
lplot

*go,:skip

!csys,0
!k,,
!init_entity_num
!lstr,km,1
!vdele,all
lplot

!                       (1)   (2)    (3)   (4)   (5)     (6)    (7)
!       DRILL_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang,
!
!                       (8)   (9)    (10)    (11)
!                      dhole, tool, depth, r_or_ang
!
csys,0
create_cs,0,,0,0,0,0,0,0,180
DRILL_PATTERN,12,2,0,9,,30,360,0.8,'c',4,120

:skip


w:\ansys\mac\tools\profile_cut.mac.html

!   TITLE:  profile_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    05/10/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a circular cut with a particular
!   profile into a volume, thereby partitioning a volume into 2 separate
!   special shaped volumes, one within the other. This will allow for tran-
!   sition meshing from an irregular volume to a map meshable volume. The
!   partitioning may be created at varying angles or at 90 degree intervals
!   if preferred. (See PROFILE_BORE.MAC)
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume set
!
!       output from (in order):
!
!               ANG_ARRAY.MAC
!               RADIUS.MAC
!               DEPTH.MAC
!
!       opt = input options: 1,2 or 3
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for option 1. From this c.s., the local
!   coordinate system building these areas is placed. Option 2 allows
!   construction of the cut areas from a c.s. defined by 3 KP's. Lastly,
!   option 3 allows construction from a pre-existing c.s., acs1.  acs1
!   must be a cylindrical c.s.
!
!   The 3 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!
!       2.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!
!       3.  Use pre-existing c.s., input: acs1
!
!
!------------------------ COMMAND SYNTAX / OPTION 1 ------------------------
!
! PROFILE_CUT,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
!
!--------------------------------- OPTION 2 --------------------------------
!
! PROFILE_CUT,opt,p1,p2,p3
!
!--------------------------------- OPTION 3 --------------------------------
!
! PROFILE_CUT,opt,acs1
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

cm,v2bcut,volu      ! selected volume(s) to be (2b) cut
!
opt=arg1
!
!------------------------ Create Input By Option ----------------------
!
*if,opt,eq,1,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
*endif
!
*if,opt,eq,2,then
    p1=arg2
    p2=arg3
    p3=arg4
*endif
!
*if,opt,eq,3,then
    acs1=arg2
*endif
!
!----------------------- Create Coordinate System ---------------------
!
*if,opt,eq,1,then
    csn=csn+1
    circutcs=csn
    clocal,circutcs,1,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    csn=csn+1
    circutcs=csn
    cskp,circutcs,1,p1,p2,p3
*endif
!
*if,opt,eq,3,then
    csys,acs1
*endif
!
!------------------------- Create Area Profiles ------------------------
!
num_lns=num_pnt-1
!
*do,i,1,num_pnt,1
    k,,rad(i,1),ang(1,1),-z(i,1)
*enddo
!
init_entity_num
!
*do,i,1,num_lns,1
    lstr,km-(num_lns-(i-1)),km-(num_lns-i)
*enddo
!
init_entity_num
!
*do,i,1,num_ang,1
    !
    *if,i,ne,num_ang,then
        !
        lsel,selv,loc,y,ang(i,1)
        max_value,'rad',num_rad
        lsel,r,loc,x,0,radm
        cm,lset1,line
        !
        k,,rad(1,1),ang(i+1,1),0
        !
        init_entity_num
        !
        l,kp(rad(1,1),ang(i,1),0),km
        !
        init_entity_num
        !
        adrag,lset1,,,,,,lm
        !
        init_entity_num
    *else
        lsel,selv,loc,y,ang(i,1)
        max_value,'rad',num_rad
        lsel,r,loc,x,0,radm
        cm,lset1,line
        !
        l,kp(rad(1,1),ang(i,1),0),kp(rad(1,1),ang(1,1),0)
        !
        init_entity_num
        !
        adrag,lset1,,,,,,lm
        !
        init_entity_num
    *endif
*enddo
!
nummrg,kp
!
init_entity_num
!
asel,selv,area,,am-(num_ang*num_lns-1),am
cm,aset1,area
!
init_entity_num
!
vsba,v2bcut,aset1,,delete,delete
!
init_entity_num
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,ang(1),
*set,d_angle,
*set,z(1),
*set,rad(1),
*set,xx,


w:\ansys\mac\tools\pocket_cut.mac.html

!   TITLE:  pocket_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/10/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a pocket cut into a volume, where
!   the pocket shape is inscribed within the selected area profile on the
!   volume, and whose lines are parallel to the selected area lines. The
!   distance between the parallel lines is 'wall_thk', which is the thick-
!   ness of the remaining wall after the operation is completed. This
!   results in a "hollwed-out" volume of constant wall thickness. The
!   lines must be straight lines, i.e., no arc or splined lines.
!
!   For automatic extrusion, the program will choose the correct direc-
!   tion of extrusion if ALL REMAINING keypoints (all keypoints exclud-
!   ing the keypoints of the selected area) in the volume lie on one
!   side of the z axis.  For the case of a complex volume where key-
!   points in the volume lie on both the positive and negative side,
!   the over-ride direction option should be used. This is done by spec-
!   ifying a KP number for 'p1od'.  If 'p1od' is specified, then the pro-
!   gram will relinquish direction control to the user.
!
!   NOTE:   The centroid of the selected area profile is assumed to be
!           at or near the center of the selected area, and therefore
!           within the confines of the area line loop. There can be an
!           ill-formed area profile that WILL violate the intended ex-
!           ecution of this macro. If the centroid is located outside
!           of the loop, or any such location that will cause the dir-
!           ection of any of the KP c.s.'s to be reversed, the boolean
!           operation will fail to execute properly or at all.
!
!           A general 'rule-of-thumb' is to choose areas that are close
!           to a symmetric form around the centroid of area such that
!           the centroid lies within the line loop.
!
!   Input data necessary to run this macro:
!
!       A selected area
!
!       wall_thk = desired wall thickness
!
!       dcut_n = depth of cut into volume (distance along a path
!                normal to the surface)
!
!       offset = boolean variable to choose either normal extrude
!                or skewed extrude. Valid arguments:
!
!                offset='normal'
!                offset='skew'
!
!   The following arguments are valid only when offset='skew'. If
!   offset='normal', they need not be specified:
!
!       dcut_s = depth of cut into volume (distance along the skew
!                path)
!
!            *NOTE: If dcut_s is left blank or 0, dcut_n will be
!                   used to calculate the skew path length.
!
!       phi_xz = skew angle as measured from the -z axis, in the
!                xz plane:
!
!                phixz < 0: skew toward - x axis direction
!                phixz > 0: skew toward + x axis direction
!
!       phi_elev = skew angle as measured from xz plane to a line
!                  that connects the origin of p1cs to a point in
!                  space (y coordinate of point is not 0):
!
!                  phi_elev < 0: skew toward - y direction
!                  phi_elev > 0: skew toward + y direction
!
!           The skew line direction is measured from p1cs. This
!           is the active c.s. that is used to measure phi_xz
!           and phi_elev from. Therefore, phi_xz is measured
!           from the p1cs -z axis, and phi_elev is measured from
!           the p1cs xz plane.  Note that p1cs has its origin
!           located at the minimum keypoint number of the selected
!           area keypoints, kset1.
!
!   A case for complex shaped volumes may exist where the user may
!   want to over-ride the extrude direction. For this case, set the
!   parameters:
!
!           p1od = origin keypoint of 1st c.s.
!           p2od = x axis keypoint, which establishes
!                  the extrude direction
!
!   If these parameters are not specified, then the program will
!   will choose the direction of extrusion, which may be incorrect.
!
!
!----------------------------- COMMAND SYNTAX ---------------------------
!
!                (1)      (2)   (3)   (4)     (5)      (6)       (7)
!  POCKET_CUT, wall_thk, p1od, p2od, offset, phi_xz, phi_elev, dcut_n,
!
!              dcut_s
!               (8)
!
!------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

wall_thk=arg1
p1od=arg2
p2od=arg3
offset=arg4
phi_xz=arg5
phi_elev=arg6
dcut_n=arg7
dcut_s=arg8
!
!-------------------------------------------------------------------------
!- A. - Create Volume, Area, Line, and Keypoint Sets for Operations ------
!-------------------------------------------------------------------------
!
get_max_entity
!
a2bcut=am                   ! area surface to be (2b) cut into (selected)
!
csys,0
!
asum,default
!
*get,pcx,area,,cent,x       ! x, y and z location of area centroid
*get,pcy,area,,cent,y
*get,pcz,area,,cent,z
!
k,,pcx,pcy,pcz              ! place keypoint at centroid
!
*get,pc,kp,,num,max         ! assign parameter to centroid KP number
!
lsla,selv   `               ! select lines associated with a2bcut
cm,lset1,line
!
ksll,selv                   ! select keypoints associated with lines of a2bcut
ksel,a,kp,,pc               ! plus area centroid KP.
cm,kset1,kp
!
vsla,selv,0                 ! select volume associated with a2bcut
cm,vset1,volu
!
aslv,s                      ! select all areas of volume excluding a2bcut
asel,u,area,,a2bcut
!
vsel,s,volu,,vset1
aslv,s
lsla,s                      ! select all keypoints of volume excluding the
ksll,s                      ! keypoints of a2bcut
ksel,u,kp,,kset1
cm,kset2,kp
!
!----------------------------------------------------------------------
!-- B. --- Check Path Direction for Correct Extrude Direction ---------
!----------------------------------------------------------------------
!
*if,p1od,eq,0,then
    !
    init_entity_num
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
    *get,kmin,kp,,num,min       ! retrieve MIN keypoint number in a2bcut
    !
    ksel,r,kp,,kmin             ! select first kp to set up c.s. on
    lslk,r,0                    ! select lines attached to kmin
    *get,ln1,line,,num,min      ! retieve lines ln1 and ln2
    *get,ln2,line,,num,max
    !
    *get,k1,line,ln1,kp,1       ! check that 2nd KP of line 1 is not kmin
    *if,k1,eq,kmin,then         ! and assign k1 that KP number
        *get,k1,line,ln1,kp,2
    *endif
    !
    *get,k2,line,ln2,kp,1       ! check that 2nd KP of line 2 is not kmin
    *if,k2,eq,kmin,then         ! and assign k2 that KP number
        *get,k2,line,ln2,kp,2
    *endif
    !
    ksel,selv,kp,,kset1
    !
    create_cs,1,'p1cs',0,kmin,k1,pc ! create 1st c.s. using k1 for x direction
    !
    ksel,s,kp,,kset2            ! select KP's of kset2
    *get,k2max,kp,,num,max      ! retrieve MAX KP number in kset2
    ksel,a,kp,,k1               ! reselect k1 and k2
    ksel,a,kp,,k2
    !
    ksel,selv,kp,,kset1
    !
    *if,kz(k2max),gt,0,then             ! if z position of k2max is positive, then
        create_cs,1,'p1cs',0,kmin,k2,pc ! recreate c.s. using k2 for x direction
    *endif
*else
    init_entity_num
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
    create_cs,1,'p1cs',0,p1od,p2od,pc
*endif
!
!----------------------------------------------------------------------
!-- C. ------------------- Create Keypoint C.S.'s ---------------------
!----------------------------------------------------------------------
!
init_entity_num
!
asel,selv,area,,a2bcut          ! select all entities of a2bcut
lsel,selv,line,,lset1
ksel,selv,kp,,kset1
!
*get,kcount,kp,,count           ! number of keypoints in a2bcut
!
max_enty_dim,'l'                ! retrieve MAX line length
!
*do,i,1,kcount,1
    !
    j=i+1
    m=i+2
    !
    csys,p%i%cs
    !
    ksel,r,loc,x,0              ! retrieve KP at c.s. origin
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    *get,k%i%,kp,,num,max
    !
    ksel,s,kp,,kset1            ! reselect KP's of kset1
    !
    lsel,r,loc,x,0,1.2*max_leng ! select line along x axis of p%i%cs
    lsel,r,loc,y,0
    !
    *get,lnum,line,,num,max
    !
    lsel,s,line,,lset1          ! reselect lines of lset1
    !
    *get,k%j%,line,lnum,kp,1        ! check that 2nd KP of line 2 is
    *if,k%j%,eq,k%i%,then           ! not kmin and assign k2 that KP
        *get,k%j%,line,lnum,kp,2    ! number
    *endif
    !
    ksel,r,kp,,k%j%             ! select 2nd kp to set up c.s. on
    lslk,r,0                    ! select lines attached to kmin
    *get,ln1,line,,num,min      ! retieve lines ln1 and ln2
    *get,ln2,line,,num,max
    !
    *if,ln1,ne,lnum,then        ! assign to 'lnum' the line 'ln1' or 'ln2'
        lnum=ln1                ! that is not equal to 'lnum'
    *else
        lnum=ln2
    *endif
    !
    ksel,selv,kp,,kset1         ! reselect KP's of kset1
    !
    lsel,r,line,,lnum           ! select keypoints associated with 'lnum
    ksll,r
    *get,k1lnum,kp,,num,min
    *get,k2lnum,kp,,num,max
    !
    *if,k1lnum,ne,k%j%,then     ! assign to 'k%m%' the KP 'k1lnum'
        k%m%=k1lnum             ! or 'k2lnum' that is not equal to 'k%j%'
    *else
        k%m%=k2lnum
    *endif
    !
    ksel,selv,kp,,kset1         ! reselect KP's of kset1
    !
    create_cs,1,'p%j%cs',0,k%j%,k%m%,pc ! create next c.s.
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
*enddo
!
asel,selv,area,,a2bcut          ! select all entities of a2bcut
lsel,selv,line,,lset1
ksel,selv,kp,,kset1
!
!----------------------------------------------------------------------
!-- D. --------------------- Create Area Profile ----------------------
!----------------------------------------------------------------------
!
*do,i,1,kcount,1
    !
    j=i+1
    m=i-1
    !
    csys,p%i%cs
    !
    k,,-0.5*max_leng,wall_thk,0
    k,,1.5*max_leng,wall_thk,0
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    csys,p%j%cs
    !
    k,,-0.5*max_leng,wall_thk,0
    k,,1.5*max_leng,wall_thk,0
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    init_entity_num
    !
    lsbl,lm-1,lm,,delete,delete
    !
    init_entity_num
    !
    p%i%=km
    !
    ldele,lm-1,lm,1
    !
    init_entity_num
    !
    *if,i,gt,1,then
        lstr,p%m%,p%i%
    *endif
    !
*enddo
!
pdrgl=%p1%              ! point of origin for the drag line
!
init_entity_num
!
lsel,selv,line,,lm-(kcount-2),lm
ksll,selv
!
nummrg,kp,.001,.001
!
al,all
!
init_entity_num
!
!----------------------------------------------------------------------
!-- E. ------------------ Perform Boolean Operation -------------------
!----------------------------------------------------------------------
!
*if,offset,eq,'normal',then
    !
    voffst,am,-dcut_n
    !
    init_entity_num
    !
    vsbv,vset1,vm,,delete,delete
    !
    init_entity_num
    !
    lplot
    !
*elseif,offset,eq,'skew',then
    !
    *if,dcut_s,eq,0,then
        !
        x=dcut_n*tan(phi_xz*rconv)
        c=sqrt((dcut_n**2)+(x**2))
        y=c*tan(phi_elev*rconv)
        z=dcut_n
        !
        csys,p1cs
        !
        create_cs,0,,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *else
        y=dcut_s*sin(phi_elev*rconv)
        c=dcut_s*cos(phi_elev*rconv)
        x=c*sin(phi_xz*rconv)
        z=c*cos(phi_xz*rconv)
        !
        csys,p1cs
        !
        create_cs,0,,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *endif
*endif
!
!----------------------------------------------------------------------
!-- E. ---------------------- Undefine Parameters ---------------------
!----------------------------------------------------------------------
!
init_entity_num
!
*do,i,2,(kcount+1),1
    csdele,p%i%cs
    *set,p%i%,
    *set,p%i%cs,
*enddo
!
*set,wall_thk,
*set,offset,        ! undefine parameters that may be used in
*set,dcut_s,        ! future macro calls
*set,dcut_n,
*set,phi_xz,
*set,phi_elev,
*set,ovr_dir,
*set,pdrgl,
*set,p1od,
*set,p2od,
*set,kcount,


w:\ansys\mac\tools\u_spe_poc_cut.mac.html

!   TITLE:  u_spe_poc_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/20/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a more user specified pocket cut into
!   a volume, where the pocket shape is inscribed within the selected area
!   profile on the volume, utilizing a specified set of lines. This dif-
!   fers from the 'pocket_cut' macro in that it allows for the creation of
!   a controlled pocket shape such that the lines are parallel to a select-
!   ed subset of the selected area lines. The pocket may then take on a
!   simpler shape then the selected area.
!
!   The distance between the parallel lines is either a constant, 'wall_thk',
!   which is the thickness of the remaining wall after the operation is
!   completed; or it may have a varying wall thickness, wall%i%, where i
!   is the side line number. This results in a "hollwed-out" volume. The
!   lines must be straight lines, i.e., no arc or splined lines. Be sure
!   that the lines that choose to create form a closed path INSIDE of the
!   selected area. A boolean operation may be performed that will erase
!   an undesired portion of the volume.
!
!   NOTE:   The centroid of the selected area profile is assumed to be
!       at or near the center of the selected area, and therefore
!       within the confines of the area line loop. There can be an
!       ill-formed area profile that WILL violate the intended ex-
!       ecution of this macro. If the centroid is located outside
!       of the loop, or any such location that will cause the dir-
!       ection of any of the KP c.s.'s to be reversed, the boolean
!       operation will fail to execute properly or at all.
!
!       A general 'rule-of-thumb' is to choose areas that are close
!       to a symmetric form around the centroid of area such that
!       the centroid lies within the line loop.
!
!   Input data necessary to run this macro:
!
!       A selected area
!
!       output from (in order):
!
!               LN_ARRAY.MAC
!               WALL_DIMN.MAC (if wall_thk is not specified)
!
!       p1 = origin keypoint of 1st c.s., which is on 1st line, ln1.
!       p2 = x axis keypoint, which establishes the extrude direction
!            which is on the 1st line, ln1. Therefore, p1 and p2 are
!            the endpoints of ln1.
!
!       wall_thk = desired wall thickness (constant)
!              If wall_thk is not specified, the user must
!              specify all wall%i%, the wall thickness at each
!              side of the pocket:
!
!           NOTE: The wall thickness dimension corresponds
!                 to the line numbers in order:
!
!               wall1 is the distance from ln1,
!               wall2 is the distance from ln2,
!               wall3 is the distance from ln3,
!                       .
!                       .
!                       .
!               walln is the distance from lnn,
!
!       dcut_n = depth of cut into volume (distance along a path
!            normal to the surface)
!
!       offset = boolean variable to choose either normal extrude
!            or skewed extrude. Valid arguments:
!
!               offset='normal'
!               offset='skew'
!
!   The following arguments are valid only when offset='skew'. If
!   offset='normal', they need not be specified:
!
!       dcut_s = depth of cut into volume (distance along the skew
!            path)
!
!            *NOTE: If dcut_s is left blank or 0, dcut_n will be
!                   used to calculate the skew path length.
!
!       phi_xz = skew angle as measured from the -z axis, in the
!            xz plane:
!
!               phixz < 0: skew toward - x axis direction
!               phixz > 0: skew toward + x axis direction
!
!       phi_elev = skew angle as measured from xz plane to a line
!              that connects the origin of p1cs to a point in
!              space (y coordinate of point is not 0):
!
!               phi_elev < 0: skew toward - y direction
!               phi_elev > 0: skew toward + y direction
!
!           The skew line direction is measured from a car-
!           tesian c.s. that is centered at point p1, whose x
!           axis is parrallel to the first selected line in
!           ln_array.mac. This is the active c.s. that is used
!           to measure phi_xz and phi_elev from. Therefore,
!           phi_xz is measured from the -z axis, and phi_elev
!           is measured from the xz plane of the newly formed c.s.
!           (Note that this c.s. has its origin located at the
!           minimum keypoint number of the new area profile to be
!           extruded.)
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                (1) (2)   (3)       (4)    (5)      (6)      (7)     (8)
! U_SPE_POC_CUT, p1, p2, wall_thk, offset, phi_xz, phi_elev, dcut_n, dcut_s
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

p1=arg1
p2=arg2
wall_thk=arg3
offset=arg4
phi_xz=arg5
phi_elev=arg6
dcut_n=arg7
dcut_s=arg8
!
!-------------------------------------------------------------------------
!- A. - Create Volume, Area, Line, and Keypoint Sets for Operations ------
!-------------------------------------------------------------------------
!
get_max_entity
!
a2bcut=am       ! area surface to be (2b) cut into (selected)
!
csys,0
!
asum,default
!
*get,pcx,area,,cent,x   ! x, y and z location of area centroid
*get,pcy,area,,cent,y
*get,pcz,area,,cent,z
!
k,,pcx,pcy,pcz      ! place keypoint at centroid
!
*get,pc,kp,,num,max ! assign parameter to centroid KP number
!
p1od=p1
p2od=p2
!
lsel,selv,line,,lnarset ! select line set 1 from ln_array command
!
ksll,selv
ksel,a,kp,,pc
cm,kset1,kp
!
vsla,selv,0     ! select volume associated with a2bcut
cm,vset1,volu
!
!----------------------------------------------------------------------
!-- B. --- Create Path Direction for Correct Extrude Direction ---------
!----------------------------------------------------------------------
!
init_entity_num
!
asel,selv,area,,a2bcut      ! select all entities of a2bcut
lsel,selv,line,,lnarset
ksel,selv,kp,,kset1
!
create_cs,1,'p1cs',0,p1od,p2od,pc
!
k,,0,0,-1           ! create dummy keypoint
*get,dkp,kp,,num,max
!
!----------------------------------------------------------------------
!-- C. ------------------- Create Keypoint C.S.'s ---------------------
!----------------------------------------------------------------------
!
init_entity_num
!
asel,selv,area,,a2bcut      ! select all entities of a2bcut
lsel,selv,line,,lnarset
ksel,selv,kp,,kset1
!
max_enty_dim,'l'        ! retrieve MAX line length
!
*do,ii,2,num_lns,1
    !
    lsel,selv,line,,ln(ii,1)
    ksll,selv
    !
    *get,k1,kp,,num,min
    *get,k2,kp,,num,max
    !
    ksel,a,kp,,pc
    ksel,a,kp,,dkp
    !
    create_cs,1,'p%ii%cs',0,k1,k2,pc
    !
    *if,kz(dkp),gt,0,then
        create_cs,1,'p%ii%cs',0,k2,k1,pc
    *endif
    !
    asel,selv,area,,a2bcut
    lsel,selv,line,,lnarset
    ksel,selv,kp,,kset1
*enddo
!
!----------------------------------------------------------------------
!-- D. --------------------- Create Area Profile ----------------------
!----------------------------------------------------------------------
!
*do,ii,1,num_lns,1
    !
    jj=ii+1
    mm=ii-1
    !
    csys,p%ii%cs
    !
    *if,wall_thk,eq,0,then
        k,,-3*max_leng,wall(ii,1),0
        k,,3*max_leng,wall(ii,1),0
    *else
        k,,-3*max_leng,wall_thk,0
        k,,3*max_leng,wall_thk,0
    *endif
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    *if,jj,le,num_lns,then
        !
        csys,p%jj%cs
        !
        *if,wall_thk,eq,0,then
            k,,-3*max_leng,wall(jj,1),0
            k,,3*max_leng,wall(jj,1),0
        *else
            k,,-3*max_leng,wall_thk,0
            k,,3*max_leng,wall_thk,0
        *endif
    *else
        csys,p1cs
        !
        *if,wall_thk,eq,0,then
            k,,-3*max_leng,wall(1,1),0
            k,,3*max_leng,wall(1,1),0
        *else
            k,,-3*max_leng,wall_thk,0
            k,,3*max_leng,wall_thk,0
        *endif
    *endif
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    init_entity_num
    !
    lsbl,lm-1,lm,,delete,delete
    !
    init_entity_num
    !
    p%ii%=km
    !
    ldele,lm-1,lm,1
    !
    init_entity_num
    !
    *if,ii,gt,1,then
        lstr,p%mm%,p%ii%
    *endif
    !
    *if,ii,eq,num_lns,then
        lstr,p1,p%ii%
    *endif
*enddo
!
pdrgl=p1        ! point of origin for the drag line
!
init_entity_num
!
lsel,selv,line,,lm-(num_lns-1),lm
ksll,selv
!
al,all
!
init_entity_num
!
!----------------------------------------------------------------------
!-- E. ------------------ Perform Boolean Operation -------------------
!----------------------------------------------------------------------
!
*if,offset,eq,'normal',then
    !
    voffst,am,-dcut_n
    !
    init_entity_num
    !
    vsbv,vset1,vm,,delete,delete
    !
    init_entity_num
    !
    lplot
    !
*elseif,offset,eq,'skew',then
    !
    *if,dcut_s,eq,0,then
        !
        x=dcut_n*tan(phi_xz*rconv)
        c=sqrt((dcut_n**2)+(x**2))
        y=c*tan(phi_elev*rconv)
        z=dcut_n
        !
        csys,p1cs
        !
        create_cs,0,,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *else
        y=dcut_s*sin(phi_elev*rconv)
        c=dcut_s*cos(phi_elev*rconv)
        x=c*sin(phi_xz*rconv)
        z=c*cos(phi_xz*rconv)
        !
        csys,p1cs
        !
        create_cs,0,,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *endif
*endif
!
kdele,dkp
!
init_entity_num
!
lplot
!
!----------------------------------------------------------------------
!-- E. ---------------------- Undefine Parameters ---------------------
!----------------------------------------------------------------------
!
kdele,pc
!
init_entity_num
!
*do,ii,1,num_lns,1
    csdele,p%ii%cs
    *set,p%ii%,
    *set,p%ii%cs,
*enddo
!
*if,wall_thk,eq,0,then
    *set,wall(1),
*endif
!
*set,ln(1),
*set,pc,
*set,pcx,
*set,pcy,
*set,pcz,
*set,wall_thk,
*set,offset,
*set,dcut_s,
*set,dcut_n,
*set,phi_xz,
*set,phi_elev,
*set,ovr_dir,
*set,pdrgl,
*set,p1od,
*set,p2od,
*set,p1,
*set,p2,
*set,num_lns,
*set,dkp,


w:\ansys\mac\tools\ar_plane_cut.mac.html

!   TITLE:  ar_plane_cut.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/30/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro cuts through a selected set of volumes at a plane coincident
!   with a specified area.
!
!
!   COMMAND SYNTAX:
!
!       AR_PLANE_CUT, area
!
!
!   ARGUMENTS:
!
!       area = the area whose plane is the volume cutting plane.
!
!
!   DESCRIPTION:
!
!   The selected area is used to create a volume cutting plane that is coplanar
!   with the area. The specified area must be a flat (cartesian planar surface.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

ar_=arg1
!
*get,acs1_,active,,csys
!
asel,s,area,,ar_
asum
lsla,s
ksll,s
get_max_entity
get_min_entity
*get,kcnt_,kp,k_min,nxth
!
*get,acx_,area,,cent,x
*get,acy_,area,,cent,y
*get,acz_,area,,cent,z
!
csys,0
k,,acx_,acy_,acz_
get_max_entity
xypt_=km
!
cskp,csn+5,0,kcnt_,k_min,xypt_
kdele,xypt_
!
norm_cut_pln_ct,'z',0
!
csdele,csn+5
csys,acs1_
!
lplot
!
*set,ar_,
*set,kcnt_,
*set,acs1_,
*set,xypt_,
*set,acx_,
*set,acy_,
*set,acz_,


w:\ansys\mac\tools\ang_cut_pln.mac.html

!   TITLE:  ang_cut_pln.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      03/21/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a volume cutting plane at a user specified angle
!   and distance from the active coordinate system origin.
!
!   COMMAND SYNTAX:
!
!                          (1)      (2)      (3)     (4)
!           ANG_CUT_PLN, ang_pln, dist_pln, x_dist, y_dist
!
!
!   ARGUMENTS:
!
!       (1) ang_pln = the angle of the cutting plane as measured from the
!                     C.S. +x axis.
!
!       (2) dist_pln = the normal distance of the plane surface from the
!                      the C.S. origin. X_DIST and Y_DIST are ignored.
!
!       (3) x_dist = the distance along the x (+ or -) axis the plane
!                    intersects. If this is specified, DO NOT specify Y_DIST
!                    and DIST_PLN.
!
!       (4) y_dist = the distance along the y (+ or -) axis the plane
!                    intersects. If this is specified, DO NOT specify X_DIST
!                    and DIST_PLN.
!
!
!   DESCRIPTION:
!
!   The cutting plane is created at a user specified angle, ANG_PLN, with
!   respect to the +x axis, and is an angle (in degrees) range of:
!
!                           0 < ang_pln < 180
!
!   The distance of the plane (DIST_LN) is the magnitude of a vector from the
!   origin oriented normal to the plane surface. Therefore, it is the perpen-
!   dicular distance of the plane from the origin. Also, the plane is aligned
!   parallel to the z axis of the active C.S.
!
!   The plane position may also be specified by the intercept with the X or
!   Y axis.  The active coordinate system may be any type.
!
!   See the argument descriptions to verify proper useage.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

ang_=arg1
dist_=arg2
xdist_=arg3
ydist_=arg4
!
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    create_cs,0,'acs_',0,0,0,0,0,0,0    ! create cartesian CS at same location.
*endif
!
cm,vset,volu
!
max_enty_dim,'l'
!
lpln_=10*max_leng
!
flag_=0
!
*if,dist_,eq,0,then
    *if,xdist_,ne,0,then
        flag_=1
        create_cs,0,,1,xdist_,0,0,0,0,0
    *else
        *if,ydist_,ne,0,then
            flag_=1
            create_cs,0,,1,0,ydist_,0,0,0,0
        *endif
    *endif
*endif
!
*if,dist_,lt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_-90)*rconv)
        y_=abs(dist_)*sin((ang_-90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_-90)*rconv)
        y_=-abs(dist_)*sin((ang_-90)*rconv)
    *endif
*elseif,dist_,gt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_+90)*rconv)
        y_=abs(dist_)*sin((ang_+90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_+90)*rconv)
        y_=-abs(dist_)*sin((ang_+90)*rconv)
    *endif
*else
    *if,flag_,ne,1,then
        xdist_=0
        ydist_=0
        x_=0
        y_=0
    *endif
*endif
!
*if,flag_,ne,1,then
    create_cs,0,,1,x_,y_,0,0,0,0
*endif
!
k,,lpln_,ang_,-lpln_
k,,lpln_,ang_,lpln_
k,,-lpln_,ang_,lpln_
k,,-lpln_,ang_,-lpln_
!
create_area
!
vsel,s,volu,,vset
!
vol_part_area,am
!
init_entity_num
!
csys,acs_
!
*set,x_,
*set,y_,
*set,ang_,
*set,dist_,
*set,xdist_,
*set,ydist_,
*set,lpln_,
*set,acs_,
*set,acstyp_,
*set,flag_,
cmdele,vset,


w:\ansys\mac\tools\ar_profile_cut.mac.html

!   TITLE:  ar_profile_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This command macro creates an area profile shape to cut selected volumes.
!
!
!   COMMAND SYNTAX:
!
!                         (1)    (2)    (3)
!        AR_PROFILE_CUT, area, dirovr, distf
!
!
!   ARGUMENTS:
!
!       (1) area = the area whose profile is to be extruded.
!
!       (2) dirovr = the extrusion direction over-ride parameter:
!
!                   0 (or blank) = calculate direction based on volume
!                                  centroid.
!
!                   1 = opposite direction from calculated centroid.
!
!       (3) distf = distance factor. Must be an integer number > 0.
!
!
!   DESCRIPTION:
!
!   The outer perimeter lines of the selected area(s) are extruded to form a
!   hollow closed surface. The surface is extruded through a selected volume,
!   or set of volumes, cutting the volume(s) into two separate regions: volume
!   segments interior to the surface profile, and volume segments exterior to
!   the surface profile.
!
!   If only 1 area, whose profile is used for cutting the volume, is desired,
!   then this area is specified in argment 1. If more than 1 area profile is
!   desired, then those areas must be selected prior to execution of this macro,
!   and argument 1 left blank. (Do not use 'isolate_areas' to select the areas,
!   use the 'asel' command)
!
!   The extrusion direction is calculated by the algorithm using the location
!   of the centroid of the selected volumes. If the automated direction choice
!   is not the desired direction, then simply placing a 1 in the second argument
!   will reverse the direction of extrude.  If the default extrusion distance is
!   not a sufficient distance, then the extrude distance may be increased by a
!   factor specified in argument 3. Otherwise, arguments 2 and 3 are unnecessary,
!   and are routinely left blank.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

ar_=arg1
dirovr_=arg2
distf_=arg3
!
*if,distf_,eq,0,then
    distf_=1
*else
    distf_=abs(nint(distf_))
*endif
!
*if,dirovr_,eq,0,then
    df_=distf_*10
*elseif,dirovr_,eq,1,then
    df_=-distf_*10
*endif
!
*get,acs1_,active,,csys
!
csys,0
!
cm,aset1_,area
cm,lset1_,line
cm,kset1_,kp
cm,vset1_,volu
!
vsum
*get,vcx_,volu,,cent,x
*get,vcy_,volu,,cent,y
*get,vcz_,volu,,cent,z
k,,vcx_,vcy_,vcz_
!
init_entity_num
kvcent_=km
!
init_entity_num
!
cmsel,s,aset1_
cmsel,s,lset1_
cmsel,s,kset1_
cmsel,s,vset1_
!
*if,ar_,eq,0,then
    entity_array,'a','arprof_','array'
    numars_=ecount
    !
    *do,abc_,1,numars_,1
        asel,s,area,,arprof_(abc_,1)
        lsla,s
        cm,proflns_,line
        *get,plcnt_,line,,count
        ksll,s
        !
        get_max_entity
        kstrt_=km
        get_min_entity
        *get,kcnt_,kp,k_min,nxth
        !
        cskp,csn+5,0,kcnt_,k_min,kstrt_
        !
        k,,kx(km),ky(km),df_*kz(kvcent_)
        get_max_entity
        !
        lstr,kstrt_,km
        get_max_entity
        pthln_=lm
        !
        adrag,proflns_,,,,,,pthln_
        ldele,pthln_,,,1
        init_entity_num
        !
        asel,s,area,,am-(plcnt_-1),am
        !
        *if,abc_,eq,1,then
            cm,newars_,area
        *else
            cmsel,a,newars_
            cm,newars_,area
        *endif
    *enddo
    !
    init_entity_num
    !
    vsba,vset1_,newars_,,delete,delete
    !
    init_entity_num
    !
    lplot
    !
    *set,numars_,
    *set,ecount,
    *set,arprof_(1),
*else
    asel,s,area,,ar_
    lsla,s
    cm,proflns_,line
    *get,plcnt_,line,,count
    ksll,s
    !
    get_max_entity
    kstrt_=km
    get_min_entity
    *get,kcnt_,kp,k_min,nxth
    !
    cskp,csn+5,0,kcnt_,k_min,kstrt_
    !
    k,,kx(km),ky(km),df_*kz(kvcent_)
    get_max_entity
    !
    lstr,kstrt_,km
    get_max_entity
    pthln_=lm
    !
    adrag,proflns_,,,,,,pthln_
    ldele,pthln_,,,1
    init_entity_num
    !
    asel,s,area,,am-(plcnt_-1),am
    cm,newars_,area
    !
    init_entity_num
    !
    vsba,vset1_,newars_,,delete,delete
    !
    init_entity_num
    !
    lplot
*endif
!
kdele,kvcent_
init_entity_num
!
csdele,csn+5
csys,acs1_
!
lplot
!
!
*set,ar_,
*set,dirovr_,
*set,kcnt_,
*set,kstrt_,
*set,df_,
*set,acs1_,
*set,proflns_,
*set,kvcent_,
*set,vcx_,
*set,vcy_,
*set,vcz_,
*set,plcnt_,
*set,pthln_,
*set,abc_,
cmdele,aset1_
cmdele,lset1_
cmdele,kset1_
cmdele,vset1_
cmdele,newars_


w:\ansys\mac\tools\norm_cut_pln_ct.mac.html

!   TITLE:  norm_cut_pln_ct.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   05/08/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro partitions a volume or set of volumes by creating a
!   cutting plane for partitioning volumes. The cutting plane must be
!   created in a CARTESIAN coordinate system. The orientation of the
!   cutting plane is normal to the specified coordinate direction. The
!   size of the cutting plane is determined by the maximum line length
!   in the the model.
!
!   The arguments necessary for the execution of this command:
!
!       * A selected set of volumes to be partitioned
!
!       cdir = coordinate direction that the cutting plane is perpen-
!              dicular to. This designates the orientation of the plane
!              a such that it is a speified distance from the origin of
!              the specified coordinate system. The coordinate direction
!              designations are 'x', 'y' and 'z' for cartesian; and 'x',
!              'y' and 'z' for r, theta and z coordinates in cylindrical
!              coordinates.
!
!       cd = The distance along the coordinate direction from the origin
!            of the coordinate system to the cutting plane surface,
!            measured along the coordinate direction as specified in
!            'cdir'.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! NORM_CUT_PLN_CT, cdir, cd
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_cdir=arg1
_cd=arg2
!
cm,_vset1,volu
!
init_entity_num
!
max_enty_dim,'l'
_lpln=10*max_leng       ! cutting plane length
!
*if,_lpln,ne,0,then
    *if,_cdir,eq,'x',then
        !
        k,,_cd,-_lpln,_lpln
        k,,_cd,-_lpln,-_lpln
        k,,_cd,_lpln,-_lpln
        k,,_cd,_lpln,_lpln
        !
        create_area
        !
    *elseif,_cdir,eq,'y',then
        !
        k,,_lpln,_cd,_lpln
        k,,_lpln,_cd,-_lpln
        k,,-_lpln,_cd,-_lpln
        k,,-_lpln,_cd,_lpln
        !
        create_area
        !
    *elseif,_cdir,eq,'z',then
        !
        k,,-_lpln,-_lpln,_cd
        k,,_lpln,-_lpln,_cd
        k,,_lpln,_lpln,_cd
        k,,-_lpln,_lpln,_cd
        !
        create_area
        !
    *endif
    !
    vsel,s,volu,,_vset1
    !
    vol_part_area,am
    !
    init_entity_num
    !
    cmdele,_vset1
*endif
!
*set,_lpln,
*set,_cd,
*set,_cdir,


w:\ansys\mac\tools\norm_cut_pln_cyl.mac.html

!   TITLE:  norm_cut_pln_cyl.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   05/08/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates a cutting plane for partitioning volumes.
!   The cutting plane must be created in a CYLINDRICAL coordinate system.
!   The orientation of the cutting plane is normal to the Z axis. The
!   size of the cutting plane is determined by the maximum line length
!   in the the model.
!
!       cd = The distance along the coordinate Z axis from the origin
!            of the coordinate system to the cutting plane surface.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! NORM_CUT_PLN_CYL, cd
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_cd=arg1
!
cm,_vset1,volu
!
max_enty_dim,'l'
!
_rpln=10*max_leng
!
*do,_angle,0,3*rtangle,rtangle
    k,,_rpln,_angle,_cd
*enddo
!
create_area,1
!
vsel,s,volu,,_vset1
!
vol_part_area,am
!
init_entity_num
!
*set,_rpln,
*set,_cd,
*set,_angle,
cmdele,_vset1


w:\ansys\mac\tools\profile_bore.mac.html

!   TITLE:  profile_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/19/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a circular bore with a particular
!   profile which is to be subtracted out, thereby creating a special
!   shaped cavity in the selected volume. This volume may be a combination
!   series of bores and chamfers at varying angle sections or at 90 degree
!   intervals if preferred.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume set
!
!       output from (in order):
!
!               ANG_ARRAY.MAC
!               RADIUS.MAC
!               DEPTH.MAC
!
!       opt = input options: 1,2 or 3
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for option 1. From this c.s., the local
!   coordinate system building this volume is placed. Option 2 allows
!   construction of the cut volume from a c.s. defined by 3 KP's. Lastly,
!   option 3 allows construction from a pre-existing c.s., acs1.  acs1
!   must be a cylindrical c.s.
!
!   The 3 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!
!       2.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!
!       3.  Use pre-existing c.s., input: acs1
!
!
!------------------------ COMMAND SYNTAX / OPTION 1 ------------------------
!
! PROFILE_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
!
!--------------------------------- OPTION 2 --------------------------------
!
! PROFILE_BORE,opt,p1,p2,p3
!
!--------------------------------- OPTION 3 --------------------------------
!
! PROFILE_BORE,opt,acs1
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

cm,v2bcut,volu      ! selected volume to be (2b) cut
!
opt=arg1
!
!------------------------ Create Input By Option ----------------------
!
*if,opt,eq,1,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
*endif
!
*if,opt,eq,2,then
    p1=arg2
    p2=arg3
    p3=arg4
*endif
!
*if,opt,eq,3,then
    acs1=arg2
*endif
!
!----------------------- Create Coordinate System ---------------------
!
*if,opt,eq,1,then
    create_cs,0,'circutcs',1,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    create_cs,1,'circutcs',1,p1,p2,p3
*endif
!
*if,opt,eq,3,then
    csys,acs1
*endif
!
!----------------------------- Create Volume --------------------------
!
num_lns=num_pnt
!
k,,0,0,0
!
*do,i,1,(num_pnt-1),1
    !
    k,,rad(i,1),ang(1,1),-z_(i,1)
*enddo
!
k,,0,0,-z_(num_pnt,1)
!
get_max_entity
!
*do,i,1,num_lns,1
    !
    lstr,km-(num_lns-(i-1)),km-(num_lns-i)
*enddo
!
lstr,km,km-(num_lns)
!
ap1=km-(num_lns)
ap2=km
!
get_max_entity
!
lsel,selv,line,,lm-(num_lns),lm
!
al,all
!
init_entity_num
!
asel,u,area,,all
!
asel,s,area,,am
!
*do,i,1,(num_ang),1
    !
    asel,r,loc,y,ang(i,1)
    !
    get_max_entity
    !
    *if,i,ne,num_ang,then
        ang_diff,ang(i,1),ang(i+1,1)
        vrotat,am,,,,,,ap1,ap2,d_angle,1
    *else
        ang_diff,ang(i,1),ang(1,1)
        vrotat,am,,,,,,ap1,ap2,d_angle,1
    *endif
*enddo
!
init_entity_num
!
vsel,s,volu,,vm-(num_ang-1),vm,1
!
vadd,all
!
init_entity_num
!
vsbv,v2bcut,vm,,delete,delete
!
init_entity_num
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,ang(1),
*set,d_angle,
*set,z_(1),
*set,rad(1),
*set,xx,
*set,delta,


w:\ansys\mac\tools\ln_profile_cut.mac.html

!   TITLE:  ln_profile_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/30/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This command macro creates an line profile shape to cut selected volumes.
!
!
!   COMMAND SYNTAX:
!
!                          (1)    (2)
!        LN_PROFILE_CUT, dirovr, distf
!
!
!   ARGUMENTS:
!
!       (1) dirovr = the extrusion direction over-ride parameter:
!
!                   0 (or blank) = calculate direction based on volume
!                                  centroid.
!
!                   1 = opposite direction from calculated centroid.
!
!       (2) distf = distance factor. Must be an integer number > 0.
!
!
!   DESCRIPTION:
!
!   The selected lines are extruded to form a hollow closed surface. The surface
!   is extruded through a selected volume, or set of volumes, cutting the volumes
!   into two separate regions: volume segments interior to(or on one side of) the
!   surface profile, and volume segments exterior to(or on the other side of) the
!   surface profile.
!
!   The extrusion direction is calculated by the algorithm using the location
!   of the centroid of the selected volumes. If the automated direction choice
!   is not the desired direction, then simply placing a 1 in the first argument
!   will reverse the direction of extrude.  If the default extrusion distance is
!   not a sufficient distance, then the extrude distance may be increased by a
!   factor specified in argument 2. Otherwise, arguments 1 and 2 are unnecessary,
!   and are routinely left blank.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
dirovr_=arg1
distf_=arg2
!
*if,distf_,eq,0,then
    distf_=1
*else
    distf_=abs(nint(distf_))
*endif
!
*if,dirovr_,eq,0,then
    df_=distf_*10
*elseif,dirovr_,eq,1,then
    df_=-distf_*10
*endif
!
*get,acs1_,active,,csys
!
csys,0
!
cm,proflns_,line
cm,vset1_,volu
!
vsum
*get,vcx_,volu,,cent,x
*get,vcy_,volu,,cent,y
*get,vcz_,volu,,cent,z
k,,vcx_,vcy_,vcz_
!
init_entity_num
kvcent_=km
!
init_entity_num
!
cmsel,s,vset1_
!
cmsel,s,proflns_
*get,plcnt_,line,,count
ksll,s
!
get_max_entity
kstrt_=km
get_min_entity
*get,kcnt_,kp,k_min,nxth
!
cskp,csn+5,0,kcnt_,k_min,kstrt_
!
k,,kx(km),ky(km),df_*kz(kvcent_)
get_max_entity
!
lstr,kstrt_,km
get_max_entity
pthln_=lm
!
adrag,proflns_,,,,,,pthln_
ldele,pthln_,,,1
init_entity_num
!
asel,s,area,,am-(plcnt_-1),am
!
cm,newars_,area
!
init_entity_num
!
vsba,vset1_,newars_,,delete,delete
!
init_entity_num
!
kdele,kvcent_
init_entity_num
!
csdele,csn+5
csys,acs1_
!
lplot
!
!
*set,dirovr_,
*set,distf_,
*set,kstrt_,
*set,df_,
*set,acs1_,
*set,kvcent_,
*set,vcx_,
*set,vcy_,
*set,vcz_,
*set,plcnt_,
*set,pthln_,
cmdele,proflns_,
cmdele,vset1_
cmdele,newars_


w:\ansys\mac\tools\rec_surf_cut.mac.html

!   TITLE:  rec_surf_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/05/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro partitions a selected volume, or set of volumes, into a
!   rectangular shaped interior region and the remaining volume(s) exterior
!   to the rectangle surface.
!
!
!   COMMAND SYNTAX:
!
!                         (1)   (2)   (3) (4)
!           REC_SURF_CUT, opt, actcs,  L,  H
!
!
!   ARGUMENTS:
!
!       (1) opt = input options:
!
!           0 (or blank) = position rectangle by center location.
!
!           1 = position rectangle by corner location. The corner
!               location is the origin of the active coordinate system
!               used in the construction of the rectangular profile, such
!               that the rectangle lies within the +X and +Y plane (1st
!               quadrant).
!
!       (2) actcs = active coordinate system to build rectangular profile
!                   relative to.
!
!       (3) L = length of rectangle parrallel to X axis of active C.S.
!
!       (4) H = height of rectangle parrallel to Y axis of active C.S.
!
!
!   DESCRIPTION:
!
!   This sub-macro creates a rectangular shaped surface that partitions a
!   selected volume or set of volumes into 2 distinct regions:
!
!               a.) a volume(s) within the rectangle surfaces
!               b.) a volume(s) exterior to the rectangle surfaces
!
!   The rectangle surfaces essentially act as a "cookie cutter" to the sel-
!   ected volumes, cutting out a volume of its shape within the selected
!   volume(s).
!
!   The rectangular profile is extruded in the -Z direction of the active
!   C.S., thereby creating the rectangular surface that penetrates the volume(s)
!   and 'cuts' (partitions) the volume(s) into the 2 regions.
!
!
!-----------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

opt=arg1
actcs1_=arg2
length_=arg3
height_=arg4
!
cm,vset100_,volu
aslv,s
lsla,s
ksll,s
cm,kset100_,kp
!
*if,opt,eq,0,then
    length_=length_/2
    height_=height_/2
*endif
!
csys,actcs1_
!
*get,acs1_,active,,csys                 ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs1_,attr,kcs            ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    create_cs,0,'acs1_',0,0,0,0,0,0,0   ! create cartesian CS at same location.
*endif
!
*if,opt,eq,0,then
    k,,-length_,-height_,0
    k,,length_,-height_,0
    k,,length_,height_,0
    k,,-length_,height_,0
*elseif,opt,eq,1,then
    k,,0,0,0
    k,,length_,0,0
    k,,length_,height_,0
    k,,0,height_,0
*endif
!
create_lines
!
cmsel,s,kset100_
!
max_kp_dist,acs1_,'r'
dcut_=2*max_dist
!
k,,kx(km),ky(km),-2*max_dist
!
init_entity_num
!
lstr,km-1,km
!
init_entity_num
l_drag=lm
!
adrag,lm-1,lm-2,lm-3,lm-4,,,lm
!
init_entity_num
!
isolate_areas
!
cm,aset100_,area
!
init_entity_num
!
vsba,vset100_,aset100_,,delete,delete
ldele,l_drag,,,1
!
init_entity_num
!
csys,actcs1_
!
lplot
!
*set,opt_,
*set,l_drag,
*set,length_,
*set,height_,
*set,actcs1_,
*set,acstyp_,
*set,acs1_,
*set,dcut_,
*set,max_dist,
cmdele,vset100_,
cmdele,aset100_,
cmdele,kset100_,


w:\ansys\mac\tools\rec_bore.mac.html

!   TITLE:  rec_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    03/31/2000  J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   04/14/2000  J. Rinaldi
!
!       Expanded macro to include CSKP and pre-existing c.s.;
!       and for explicit input for each KP coordinate.
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates a hexahedral shaped volume which is to be sub-
!   tracted out, thereby creating a rectangular shaped cavity either within
!   or on the surface of the selected volume. This volume may have right
!   angled corners (phibev = 0), or angled (0 < phibev < 90) corners.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume(s)
!
!       opt = input options: 1,2,3,4,5,6,7,8,9,10,11 or 12
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       dcut = the depth or thickness of the volume
!       phibev = angle of bevel as measured from the normal
!            to the rectangular surfaces (from volume cut
!            coordinate system z axis)
!       xwcut = width of cut/volume (along local c.s. x axis)
!       yhcut = height of cut/volume (along local c.s. y axis)
!       x23 = x coordinate value for KP's in quadrants 2 and 3
!       x14 = x coordinate value for KP's in quadrants 1 and 4
!       y12 = y coordinate value for KP's in quadrants 1 and 2
!       y34 = y coordinate value for KP's in quadrants 3 and 4
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for options 1,2,7 and 8 (See below). From
!   this c.s., the local coordinate system building this volume is placed.
!   Options 3,4,9 and 10 allow construction of the cut volume from a c.s.
!   defined by 3 KP's. Lastly, options 5,6,11 and 12 allow construction from
!   a pre-existing c.s.  Options 7 thru 12 correspond to the same input as
!   1 thru 6, except that these options are used when the dimensions of the
!   base rectangle are specified.
!
!
!   The 12 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       2.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       3.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       4.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       5.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       6.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       7.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       8.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       9.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       10. Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       11. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       12. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!
!----------------------- COMMAND SYNTAX / OPTION 1 & 7 -----------------------
!
!           (1)   (2)    (3)    (4)    (5)      (6)     (7)   (8)  (9)  (10)
! REC_BORE, opt, xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc, x23, x14, y12,
!
!           y34, dcut, phibev
!           (11)  (12)  (13)
!
!-------------------------------- OPTION 2 & 8 -------------------------------
!
!           (1)   (2)    (3)    (4)    (5)      (6)     (7)    (8)    (9)
! REC_BORE, opt, xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc, xwcut, yhcut,
!
!           dcut, phibev
!           (10)   (11)
!
!-------------------------------- OPTION 3 & 9 -------------------------------
!
!           (1)  (2) (3) (4) (5)  (6)  (7)  (8)  (9)    (10)
! REC_BORE, opt, p1, p2, p3, x23, x14, y12, y34, dcut, phibev
!
!-------------------------------- OPTION 4 & 10 ------------------------------
!
!           (1)  (2) (3) (4)  (5)    (6)   (7)    (8)
! REC_BORE, opt, p1, p2, p3, xwcut, yhcut, dcut, phibev
!
!-------------------------------- OPTION 5 & 11 ------------------------------
!
! REC_BORE, opt, acs1, x23, x14, y12, y34, dcut, phibev
!
!-------------------------------- OPTION 6 & 12 -------------------------------
!
! REC_BORE, opt, acs1, xwcut, yhcut, dcut, phibev
!
!-----------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

opt=arg1
!
*if,opt,eq,1,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    x23=arg8
    x14=arg9
    y12=ar10
    y34=ar11
    dcut=ar12
    phibev=ar13
*endif
!
*if,opt,eq,2,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    xwcut=arg8
    yhcut=arg9
    dcut=ar10
    phibev=ar11
*endif
!
*if,opt,eq,3,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    x23=arg5
    x14=arg6
    y12=arg7
    y34=arg8
    dcut=arg9
    phibev=ar10
*endif
!
*if,opt,eq,4,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    xwcut=arg5
    yhcut=arg6
    dcut=arg7
    phibev=arg8
*endif
!
*if,opt,eq,5,then
    acs1=arg2
    !
    x23=arg3
    x14=arg4
    y12=arg5
    y34=arg6
    dcut=arg7
    phibev=arg8
*endif
!
*if,opt,eq,6,then
    acs1=arg2
    !
    xwcut=arg3
    yhcut=arg4
    dcut=arg5
    phibev=arg6
*endif
!
*if,opt,eq,7,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    x23=arg8
    x14=arg9
    y12=ar10
    y34=ar11
    dcut=ar12
    phibev=ar13
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,8,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    xwcut=arg8
    yhcut=arg9
    dcut=ar10
    phibev=ar11
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,9,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    x23=arg5
    x14=arg6
    y12=arg7
    y34=arg8
    dcut=arg9
    phibev=ar10
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,10,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    xwcut=arg5
    yhcut=arg6
    dcut=arg7
    phibev=arg8
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,11,then
    acs1=arg2
    !
    x23=arg3
    x14=arg4
    y12=arg5
    y34=arg6
    dcut=arg7
    phibev=arg8
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,12,then
    acs1=arg2
    !
    xwcut=arg3
    yhcut=arg4
    dcut=arg5
    phibev=arg6
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
get_max_entity
!
cm,v2bcut,volu      ! selected volume to be (2b) cut
!
*if,opt,eq,1,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,3,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,4,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,5,then
    csys,acs1
*endif
!
*if,opt,eq,6,then
    csys,acs1
*endif
!
*if,opt,eq,7,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,8,then
    create_cs,0,'reccutcs',0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,9,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,10,then
    create_cs,1,'reccutcs',0,p1,p2,p3
*endif
!
*if,opt,eq,11,then
    csys,acs1
*endif
!
*if,opt,eq,12,then
    csys,acs1
*endif
!
*if,opt,eq,2,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,4,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,6,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,1,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,3,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,5,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,8,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,10,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,12,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,7,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,9,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,11,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
x=dcut*tan(phibev*rconv)
!
*if,opt,eq,2,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,4,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,6,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,1,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,3,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,5,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,8,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,10,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,12,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,7,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,9,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,11,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,x23,
*set,x14,
*set,y12,
*set,y34,
*set,phibev,
*set,dcut
*set,xwcut
*set,yhcut
*set,x,


w:\ansys\mac\tools\ara_part_line.mac.html

!   TITLE:  ara_part_line.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    01/08/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to partition a selected set of areas by using
!   a cutting line, LCUT.  It then restores the selected set to the full
!   model set that is currently under construction.
!
!   In the case that the cutting line LCUT is a component group of lines,
!   then simply place the component group name in single quotes in the
!   first argument.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! ARA_PART_LINE, lcut
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_lcut=arg1
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*do,_iii,_alow,_ahigh,1
    *if,_alow,eq,_ahigh,then
        _kdv='delete'
    *else
        *if,_iii,ne,_ahigh,then
            _kdv='keep'             ! keep/delete decision variable
        *else
            _kdv='delete'
        *endif
    *endif
    !
    *if,asel(_iii),eq,1,then
        asbl,_iii,_lcut,,delete,_kdv
    *endif
*enddo
!
*get,_ptyp,parm,_lcut,type
!
*if,_ptyp,eq,3,then
    ldele,_lcut,,,1
*endif
!
*if,_ptyp,ne,3,then
    *if,lsel(_lcut),ne,0,then
        ldele,_lcut,,,1
    *endif
*endif
!
init_entity_num
!
*set,_kdv,
*set,_alow,
*set,_ahigh,
*set,_lcut,
*set,_iii,
*set,_ptyp,


w:\ansys\mac\tools\ln_part_ln.mac.html

!   TITLE:  ln_part_ln.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    03/22/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   RELEASED    04/25/2000      J. Rinaldi
!
!       Added *set commands to undefine variables
!---------------------------------------------------------------------------
!       Rev B   RELEASED    12/04/2000      J. Rinaldi
!
!       Redesigned logic format.
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to partition a selected set of lines by using
!   a single cutting line, LCUT.  It then restores the selected set to the
!   full model set that is currently under construction. Input variables
!   are as follows:
!
!           A selected line set (including the cutting line(s))
!
!           lcut = line number used to partition line set
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! LN_PART_LN, lcut
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_lcut=arg1
!
*get,_lcnt,line,,count          ! Total count of lines.
*get,_l2bcut,line,,num,min      ! Retrieve minimum line number to begin
!                               ! iterations.
*if,_lcnt,eq,2,then
    _lcnt=_lcnt-1
*endif
!
*do,_ijk,1,_lcnt,1
    !
    *if,_ijk,ne,_lcnt,then
        _kdv='keep'             ! keep/delete decision variable
    *else
        _kdv='delete'
    *endif
    !
    *if,_l2bcut,ne,_lcut,then
        *if,lsel(_l2bcut),eq,1,then
            lsbl,_l2bcut,_lcut,,delete,_kdv
        *endif
    *endif
    !
    *if,_lcnt,eq,2,then
        *exit
    *endif
    !
    _lhold=_l2bcut
    *get,_l2bcut,line,_lhold,nxth
*enddo
!
init_entity_num
!
*set,_lcut,
*set,_l2bcut,
*set,_lcnt,
*set,_kdv,
*set,_lhold,
*set,_ijk,


w:\ansys\mac\tools\comb_areas.mac.html

!   TITLE:  comb_areas.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      10/17/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro combines all selected areas in a model.
!
!
!   COMMAND SYNTAX:
!
!        COMB_AREAS
!
!
!   DESCRIPTION:
!
!   All areas that are cartesian coplanar are combined into single areas
!   to keep the model clean by reducing the number of solid model entities
!   to a minimum.
!
!   1. Select an area from the full set and check to see if area is planar.
!
!   2. Select all areas in the same plane with an area that has been determined
!      to be planar.
!
!   3. Check to see that all of these areas are planar.
!
!   4. Of all areas determined to be planar, each area must share at least 1
!      line with another area, exclusively.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*get,actcs_,active,,csys
entity_array,'a','aset1_','array'
a1_=ecount
!
*do,abc_,1,a1_,1
    asel,s,area,,aset1_(abc_,1)
    asum
    lsla,s
    ksll,s
    get_min_entity
    *get,kcnt_,kp,k_min,nxth
    !
    *get,acx_,area,,cent,x
    *get,acy_,area,,cent,y
    *get,acz_,area,,cent,z
    !
    csys,0
    k,,acx_,acy_,acz_
    get_max_entity
    xypt_=km
    !
    cskp,csn+5,0,kcnt_,k_min,xypt_
    get_max_entity
    !
    *get,ksettyp_,parm,kset1_,type
    !
    *if,ksettyp_,eq,1,then
        *set,kset1_(1),
    *endif
    !
    entity_array,'k','kset1_','array'
    k1_=ecount
    !
    *do,xyz_,1,k1_,1
        csys,csn+5
        dist__=kz(kset1_(xyz_,1))
        prec_=4
        tol_=10**(-prec_-1)
        !
        *if,abs(dist__),lt,tol_,then
            dist__=0
        *else
            *if,abs(dist__),ge,(10*tol_),then
                round_num,dist__,prec_
            *else
                round_num,dist__,prec_+1
            *endif
            !
            dist__=num_
        *endif
        !
        *if,dist__,ne,0,then
            abrta_=1
            *exit
        *else
            abrta_=0
        *endif
    *enddo
    !
    *if,abrta_,eq,0,then
        init_entity_num
        csys,csn+5
        asel,s,loc,z,0
        !
        *get,acount,area,,count
        !
        *if,acount,gt,1,then
            *get,aset2tp_,parm,aset2_,type
            !
            *if,aset2tp_,eq,1,then
                *set,aset2_(1),
            *endif
            !
            entity_array,'a','aset2_','array'
            a2_=ecount
            !
            *do,ijkm_,1,a2_,1
                asel,s,area,,aset2_(ijkm_,1)
                asum
                lsla,s
                ksll,s
                get_min_entity
                *get,kcnt_,kp,k_min,nxth
                !
                *get,acx_,area,,cent,x
                *get,acy_,area,,cent,y
                *get,acz_,area,,cent,z
                !
                csys,0
                k,,acx_,acy_,acz_
                get_max_entity
                xypt_=km
                !
                cskp,csn+6,0,kcnt_,k_min,xypt_
                get_max_entity
                !
                *get,ksettyp_,parm,kset1_,type
                !
                *if,ksettyp_,eq,1,then
                    *set,kset1_(1),
                *endif
                !
                entity_array,'k','kset1_','array'
                k1_=ecount
                !
                *do,xyz_,1,k1_,1
                    csys,csn+6
                    dist__=kz(kset1_(xyz_,1))
                    prec_=4
                    tol_=10**(-prec_-1)
                    !
                    *if,abs(dist__),lt,tol_,then
                        dist__=0
                    *else
                        *if,abs(dist__),ge,(10*tol_),then
                            round_num,dist__,prec_
                        *else
                            round_num,dist__,prec_+1
                        *endif
                        !
                        dist__=num_
                    *endif
                    !
                    *if,dist__,ne,0,then
                        abrta2_=1
                        *exit
                    *else
                        abrta2_=0
                    *endif
                *enddo
                !
                *set,kset1_(1),
                !
                *if,abrta2_,eq,0,then
                    *if,ijkm_,eq,1,then
                        addindx_=0
                        addindx_=addindx_+1
                        !
                        !*get,addtyp_,parm,addset_,type
                        !
                        !*if,addtyp_,eq,1,then
                            !*set,addset_(1),
                            *dim,addset_,array,a2_,1
                        !*endif
                        !
                        addset_(addindx_,1)=aset2_(ijkm_,1)
                    *else
                        addindx_=addindx_+1
                        addset_(addindx_,1)=aset2_(ijkm_,1)
                    *endif
                *endif
            *enddo
            !
            *do,qrs_,1,a2_,1
                *if,qrs_,eq,1,then
                    *if,addset_(qrs_,1),ne,0,then
                        asel,s,area,,addset_(qrs_,1)
                    *endif
                *else
                    *if,addset_(qrs_,1),ne,0,then
                        asel,a,area,,addset_(qrs_,1)
                    *endif
                *endif
            *enddo
            !
            aadd,all
            !
            init_entity_num
            !
            aplot
        *endif
    *endif
    !
    *get,addtyp_,parm,addset_,type
    !
    *if,addtyp_,eq,1,then
        *set,addset_(1),
    *endif
*enddo
!
csdele,csn+5,csn+6,1
csys,actcs_
!
init_entity_num
!
aplot
!

*go,:skip

*set,a1_,
*set,ecount,
*set,xypt_,
*set,acx_,
*set,acy_,
*set,acz_,
*set,k1_,
*set,kcnt_,
*set,actcs_,
*set,dist__,
*set,abc_,
*set,xyz_,
*set,k_min,
*set,prec_,
*set,tol_,
*set,abrta_,
*set,num_,
*set,a2_,
*set,abrta2_,
*set,addindx_,
*set,qrs_,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,aset1_(1),
*set,kset1_(1),
*set,aset2_(1),
*set,addset_(1),

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

:skip


w:\ansys\mac\tools\comb_areas2.mac.html

!   TITLE:  comb_areas2.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      10/17/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro combines all selected areas in a model.
!
!
!   COMMAND SYNTAX:
!
!        COMB_AREAS
!
!
!   DESCRIPTION:
!
!   All areas that are cartesian coplanar are combined into single areas
!   to keep the model clean by reducing the number of solid model entities
!   to a minimum.
!
!   1. Select an area from the full set and check to see if area is planar.
!
!   2. Select all areas in the same plane with an area that has been determined
!      to be planar.
!
!   3. Check to see that all of these areas are planar.
!
!   4. Of all areas determined to be planar, each area must share at least 1
!      line with another area, exclusively.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

vol_=arg1
!
init_entity_num
*get,vcount_,volu,,count
!
*if,vol_,eq,0,then
    *if,vcount_,eq,1,then
        vol_=vm
    *endif
*endif
!
*get,actcs_,active,,csys
vsel,s,volu,,vol_
aslv,s
entity_array,'a','aset2_','array'
a2_=ecount
!
!----------------------- A.) SELECT ALL PLANAR AREAS -----------------------
!
*do,abc_,1,a2_,1
    asel,s,area,,aset2_(abc_,1)
    asum
    lsla,s
    ksll,s
    get_min_entity
    *get,kcnt_,kp,k_min,nxth
    !
    *get,acx_,area,,cent,x
    *get,acy_,area,,cent,y
    *get,acz_,area,,cent,z
    !
    csys,0
    k,,acx_,acy_,acz_
    get_max_entity
    xypt_=km
    !
    cskp,csn+5,0,kcnt_,k_min,xypt_
    !
    *get,ksettyp_,parm,kset2_,type
    !
    *if,ksettyp_,eq,1,then
        *set,kset2_(1),
    *endif
    !
    entity_array,'k','kset2_','array'
    k2_=ecount
    !
    *do,xyz_,1,k2_,1
        csys,csn+5
        dist__=kz(kset2_(xyz_,1))
        prec_=4
        tol_=10**(-prec_-1)
        !
        *if,abs(dist__),lt,tol_,then
            dist__=0
        *else
            *if,abs(dist__),ge,(10*tol_),then
                round_num,dist__,prec_
            *else
                round_num,dist__,prec_+1
            *endif
            !
            dist__=num_
        *endif
        !
        *if,dist__,ne,0,then
            *exit
        *else
            *if,xyz_,eq,k2_,then
                *get,aset1tp_,parm,aset1_,type
                !
                *if,aset1tp_,ne,1,then
                    *dim,aset1_,array,a2_,1
                *endif
                !
                aset1_(abc_,1)=aset2_(abc_,1)
            *endif
        *endif
    *enddo
*enddo
!
init_entity_num
!
elcnt_=0
!
*do,ijk_,1,a2_,1
    *if,aset1_(ijk_,1),ne,0,then
        elcnt_=elcnt_+1
    *endif
*enddo
!
*dim,plnra_,array,elcnt_,1
elcnt_=0
!
*do,ijk_,1,a2_,1
    *if,aset1_(ijk_,1),ne,0,then
        elcnt_=elcnt_+1
        plnra_(elcnt_,1)=aset1_(ijk_,1)
    *endif
*enddo
!
*set,kset2_(1),
*set,aset1_(1),
*set,aset2_(1),
!
!--------------------- B.) GROUP ALL COMMON PLANAR AREAS -------------------
!
*get,acnt_,parm,plnra_,dim,x
!
*do,ijkm_,1,acnt_,1
    *if,plnra_(ijkm_,1),ne,0,then
        asel,s,area,,plnra_(ijkm_,1)
        asum
        lsla,s
        ksll,s
        get_min_entity
        *get,kcnt_,kp,k_min,nxth
        !
        *get,acx_,area,,cent,x
        *get,acy_,area,,cent,y
        *get,acz_,area,,cent,z
        !
        csys,0
        k,,acx_,acy_,acz_
        get_max_entity
        xypt_=km
        !
        cskp,csn+5,0,kcnt_,k_min,xypt_
        !
        *do,abc_,1,acnt_,1
            *if,abc_,eq,1,then
                *if,plnra_(abc_,1),ne,0,then
                    asel,s,area,,plnra_(abc_,1)
                    frstset_=0
                *else
                    frstset_=1
                *endif
            *else
                *if,plnra_(abc_,1),ne,0,then
                    *if,frstset_,eq,0,then
                        asel,a,area,,plnra_(abc_,1)
                    *else
                        asel,s,area,,plnra_(abc_,1)
                        frstset_=0
                    *endif
                *endif
            *endif
        *enddo
        !
        asel,r,loc,z,0
        *get,acount_,area,,count
        !
        *if,acount_,gt,1,then
            entity_array,'a','aset%ijkm_%','array'
        *elseif,acount_,eq,1,then
            ecount=acount_
        *endif
        !
        *do,def_,1,ecount,1
            *if,acount_,gt,1,then
                arry_search,'plnra_',aset%ijkm_%(def_,1)
            *elseif,acount_,eq,1,then
                get_max_entity
                arry_search,'plnra_',am
            *endif
            !
            rplnra_=hit(1,1,1)
            cplnra_=hit(1,2,1)
            !
            plnra_(rplnra_,cplnra_)=0
        *enddo
    *endif
*enddo
!

*go,:skip

!------------------ C.) ALL AREAS ATTACHED TO SAME VOLUME ------------------
!
*get,acnt_,parm,plnra_,dim,x
!
*do,abc_,1,acnt_,1
    *get,aacnt_,parm,aset%abc_%,dim,x
    !
    *if,aacnt_,gt,0,then
        *do,xyz_,1,aacnt_,1
            asel,s,area,,aset%abc_%(xyz_,1)
            vsla,s
            *get,vcount_,volu,,count
            !
            *if,vcount_,gt,1,then
                keepa_=0
            *elseif,vcount_,eq,1,then
                keepa_=1
            *endif
            !
            *if,keepa_,eq,0,then
                aset%abc_%(xyz_,1)=0
            *endif
        *enddo
    *endif
*enddo

!------------------- D.) ADD ALL CONGLOMERATE PLANAR AREAS -----------------
!
*get,acnt_,parm,plnra_,dim,x

*go,:skip

!arr_='plnra_'
arr_='aset164'

*get,acnt_,parm,%arr_%,dim,x
!
*do,i,1,acnt_,1
    *if,i,eq,1,then
        asel,s,area,,%arr_%(i,1)
    *else
        asel,a,area,,%arr_%(i,1)
    *endif
*enddo

*get,acnt_,parm,plnra_,dim,x
!
*do,i,1,acnt_,1
    *get,asettyp_,parm,aset%i%,type
    !
    *if,asettyp_,eq,1,then
        *set,aset%i%,
    *endif
*enddo

*set,a1_,
*set,ecount,
*set,xypt_,
*set,acx_,
*set,acy_,
*set,acz_,
*set,k1_,
*set,kcnt_,
*set,actcs_,
*set,dist__,
*set,abc_,
*set,xyz_,
*set,k_min,
*set,prec_,
*set,tol_,
*set,abrta_,
*set,num_,
*set,a2_,
*set,abrta2_,
*set,addindx_,
*set,qrs_,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,
*set,aset1_(1),
*set,kset1_(1),
*set,aset2_(1),
*set,addset_(1),

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

:skip


w:\ansys\mac\tools\ln_seg.mac.html

!   TITLE:  ln_seg.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    09/15/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro combines all colinear pairs of line segments, in a selected
!   set of lines, into single lines.
!
!
!   COMMAND SYNTAX:
!
!           LN_SEG
!
!
!   DESCRIPTION:
!
!   The lines must be colinear such that the angle between any line pair must
!   be 180 degrees. The intersetion keypoint common to both lines must not
!   be attached to any other lines other than the colinear line pair in order
!   for the algorithm to combine them into a single line.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

prec_=3
tol_=10**(-prec_-1)
!
ksll,s
entity_array,'k','kset1_','array'
numkps_=ecount
!
*do,jklm_,1,numkps_,1
    ksel,s,kp,,kset1_(jklm_,1)
    get_max_entity
    kcnt_=km
    !
    lslk,s,0
    *get,numcl_,line,,count
    !
    *if,numcl_,eq,2,then
        get_min_entity
        ln1_=l_min
        get_max_entity
        ln2_=lm
        !
        *get,kp11_,line,ln1_,kp,1
        *get,kp12_,line,ln1_,kp,2
        !
        *get,kp21_,line,ln2_,kp,1
        *get,kp22_,line,ln2_,kp,2
        !
        *if,kp11_,eq,kcnt_,then
            kp1_=kp12_
        *else
            kp1_=kp11_
        *endif
        !
        *if,kp21_,eq,kcnt_,then
            kp2_=kp22_
        *else
            kp2_=kp21_
        *endif
        !
        kpang_=anglek(kcnt_,kp1_,kp2_)*dconv
        dang_=180-kpang_
        !
        *if,abs(dang_),le,(10*tol_),then
            lcomb,ln1_,ln2_
        *endif
    *endif
*enddo
!
init_entity_num
!
lplot
!
*set,numkps_,
*set,numcl_,
*set,ecount,
*set,kp11_,
*set,kp12_,
*set,kp21_,
*set,kp22_,
*set,kp1_,
*set,kp2_,
*set,ln1_,
*set,ln2_,
*set,kpang_,
*set,dang_,
*set,kcnt_,
*set,kset1_(1),
*set,jklm_,
*set,tol_,
*set,prec_,


w:\ansys\mac\tools\select_part.mac.html

!   TITLE:  select_part.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/12/2000    J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     02/13/2001    J. Judd
!
!       Added error check and warning for input parameter = scalar.
!       Changed internal variables to end in underscore (e.g. _).
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro selects all solid and FE model entities associated
!   with the named part volume.  The only input necessary is the model
!   name for the part.
!
!   COMMAND SYNTAX:
!
!       SELECT_PART, pnam
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

pnam_=arg1
!
*get,ptyp_,parm,pnam_,type
!
*if,ptyp_,eq,3,then
    allsel,all
    !
    *get,vcount_,volu,,count
    !
    *if,vcount_,gt,0,then
        vsel,s,volu,,pnam_
        !
        aslv,selv
        lsla,selv
        ksll,selv
        eslv,selv
        nsle,selv,all
        !
    *else
        asel,s,area,,pnam_
        !
        lsla,selv
        ksll,selv
        eslv,selv
        nsle,selv,all
        !
    *endif
*endif
!
lplot
!
*set,pnam_,
*set,ptyp_,


w:\ansys\mac\tools\vsle.mac.html

!   TITLE:  vsle.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro selects a volume associated with a selected element, or
!   set of elements.
!
!   COMMAND SYNTAX:
!
!               (1)
!        VSLE, stype
!
!   ARGUMENTS:
!
!       (1) stype = label outlining the selection type
!
!                   'u' = unselect
!                   's' = select
!                   'r' = reselect
!                   'a' = additionally select
!
!
!   DESCRIPTION:
!
!   A selected element, or set of elements, is/are used to unselect from the
!   current set (u), select from the full set (s), reselect from the current
!   set (r), or additionally select to the current selected set (a), volume(s)
!   containing these elements.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

styp_=arg1
!
*if,styp_,eq,'s',then
    vsel,all
*elseif,styp_,eq,'a',then
    vsel,all
*else
    cm,selvset_,volu
*endif
!
entity_array,'v','vset10_','array'      ! create array of selected volumes
cm,eset10_,elem
!
*do,jkl_,1,ecount,1
    !
    vsel,s,volu,,vset10_(jkl_,1)
    eslv,s
    cmsel,r,eset10_
    get_max_entity
    *get,elcnt_,elem,,count
    !
    *if,elcnt_,ne,0,then
        *if,jkl_,eq,1,then
            cm,vset2_,volu
        *else
            *get,x_,comp,vset2_,type
            !
            *if,x_,eq,9,then
                cmsel,s,vset2_
                vsel,a,volu,,vm
                cm,vset2_,volu
            *else
                vsel,s,volu,,vm
                cm,vset2_,volu
            *endif
        *endif
    *else
        *if,jkl_,eq,ecount,then
            *get,x_,comp,vset2_,type
            *if,x_,ne,9,then
                vsel,u,volu,,vset10_(jkl_,1)
                cm,vset2_,volu
            *endif
        *endif
    *endif
*enddo
!
*if,styp_,eq,'s',then           ! selection routine
    cmsel,s,vset2_
*elseif,styp_,eq,'u',then
    cmsel,s,selvset_
    cmsel,u,vset2_
*elseif,styp_,eq,'r',then
    cmsel,s,selvset_
    cmsel,r,vset2_
*elseif,styp_,eq,'a',then
    cmsel,s,selvset_
    cmsel,a,vset2_
*endif
!
*set,jkl_,
*set,styp_,
*set,ecount,
*set,elcnt_,
*set,vset10_(1),
*set,x_,
cmdele,selvset_,
cmdele,vset2_,
cmdele,eset10_,


w:\ansys\mac\tools\vcylsel.mac.html

!   TITLE:  vcylsel.mac (MANAGEMENT)
!
!--------------------------------------------------------------------
!       Rev -   03/21/2001  J. Judd
!-------------------------------------------------------------------

!   Selects Cylindrical Volumes from radius, angle, and z input in one command.
!    - radial selection uses ksel in addition to vsel to better select 'donuts'
!    - angle and z selection uses vsel
!

!-------------------------- COMMAND SYNTAX ---------------------------------
!   vcylsel,seltype,radi,rado,theta1,theta2,z1,z2,tol
!---------------------------------------------------------------------------
*get,prkey_,active,0,prkey
/nopr

seltype_=ARG1    !selection type:  's','r', or selv (selv=variable from mod_assemb_prep)
                 !'a','u', TBD
radi_=ARG2       !radius inner
rado_=ARG3       !radius outer
theta1_=ARG4     !beginning angle
theta2_=ARG5     !ending angle
z1_=ARG6         !beginning Z dimension
z2_=ARG7         !ending Z dimension
tol_=ARG8        !+ or - tolerance on all dimensions in linear units (will convert internally for angle)
                 !tolerance is needed because sometimes just don't select even if have exact input.
!---------------------------------------------------------------------------
!
!-------------------------- IMPROVEMENTS TBD  ------------------------------
!   - Add additional selection types such as 'a', 'u'.  Have to determine what is selected
!     so that select and reselect in proper order.
!   - Check if in cylindrical CS.  If not then save current CS, change to cyl CS,
!     then change back at end. Add warning message if current csys is not cylindrical?
!   - add tolerance

!--------------------------------- EXAMPLES -------------------------------
!
!---------------------------------------------------------------------------

numsel_=0

*IF,radi_,NE,rado_,THEN
   vsel,seltype_,loc,x,0,rado_
   numsel_=numsel_+1
*ENDIF

*IF,theta1_,NE,theta2_,THEN
   *IF,numsel_,GT,0,THEN
      vsel,r,loc,y,theta1_,theta2_
      numsel_=numsel_+1
   *ELSE
      vsel,seltype_,loc,y,theta1_,theta2_
      numsel_=numsel_+1
   *ENDIF
*ENDIF

*IF,Z1_,NE,Z2_,THEN
   *IF,numsel_,GT,0,THEN
      vsel,r,loc,z,Z1_,Z2_
      numsel_=numsel_+1
   *ELSE
      vsel,seltype_,loc,z,Z1_,Z2_
      numsel_=numsel_+1
   *ENDIF
*ENDIF

aslv  $lsla  $ksll

*IF,radi_,NE,rado_,THEN
   ksel,r,loc,x,radi_,rado_
   lslk,s,1  $asll,s,1  $vsla,s,1
!   numsel_=numsel_+1
*ENDIF

!**** RESET (eliminate) INTERNAL VARIABLES
*set,seltype_
*set,radi_
*set,rado_
*set,theta1_
*set,theta2_
*set,z1_
*set,z2_
*set,tol_
*set,numsel_


w:\ansys\mac\tools\radial_vsel.mac.html

!   TITLE:  radial_vsel.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/19/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro selects a volume, or set of volumes, by radial position.
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)   (4)    (5)   (6)    (7)   (8)
!        RADIAL_VSEL, stype, acs, rlow, rhigh, alow, ahigh, zlow, zhigh
!
!
!   ARGUMENTS:
!
!       (1) stype = label outlining the selection type
!
!                   'u' = unselect
!                   's' = select
!                   'r' = reselect
!
!       (2) acs = active cylindrical C.S. in which selection process occurs
!
!       (3) rlow = lower limit radius of envelope
!
!       (4) rhigh = upper limit radius of envelope
!
!       (5) alow = lower limit angle of envelope
!
!       (6) ahigh = upper limit angle of envelope
!
!       (7) zlow = lower limit axial position of envelope
!
!       (8) zhigh = upper limit axial position of envelope
!
!
!   DESCRIPTION:
!
!   This macro allows a user to specify radial and angular position limits
!   of a volume(s) without knowledge of the volume centroid.  It is useful for
!   arc-shaped volumess where the centoid is not located within the volume
!   boundaries.
!
!   This macro uses the keypoint positions and their attached lines to select,
!   reselect and unselect the area(s), and therefore the volumes in question.
!   Therefore, the envelope containing the volume boundary keypoints is used
!   to either select, unselect or reselect the desired volumes(s).
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

cm,kset2_,kp
cm,lset2_,line
cm,aset2_,area
!
cm,vset1_,volu
!
typ_=arg1
acs_=arg2
rlow_=arg3
rhigh_=arg4
alow_=arg5
ahigh_=arg6
zlow_=arg7
zhigh_=arg8
!
!
*get,actcs_,active,,csys
!
csys,acs_
!
ksel,s,loc,x,rlow_,rhigh_
ksel,r,loc,y,alow_,ahigh_
ksel,r,loc,z,zlow_,zhigh_
!
lslk,s,1
!
*if,typ_,eq,'r',then
    asll,r,1
    vsla,r,1
*else
    asll,s,1
    vsla,s,1
*endif
!
*get,vcount_,volu,,count
!
*if,vcount_,eq,0,then
    *if,typ_,eq,'r',then
        asll,r,0
        vsla,r,0
    *else
        asll,s,0
        vsla,s,0
    *endif
*endif
!
*if,typ_,eq,'u',then
    cm,vset2_,volu
    cmsel,s,vset1_
    cmsel,u,vset2_
*endif
!
cmsel,s,kset2_
cmsel,s,lset2_
cmsel,s,aset2_
!
csys,actcs_
!
*set,typ_,
*set,vcount_,
*set,actcs_,
*set,acs_,
*set,rlow_,
*set,rhigh_,
*set,alow_,
*set,ahigh_,
*set,zlow_,
*set,zhigh_,
cmdele,vset1_
cmdele,vset2_
cmdele,kset2_
cmdele,lset2_
cmdele,aset2_


l:\ansys\mac\tools\acylsel.mac.html

!   TITLE:  acylsel.mac (SELECTION)
!
!--------------------------------------------------------------------
!   Rev -   03/04/2002  J. Judd
!-------------------------------------------------------------------
!
! OBJECTIVE:
!
!   Select areas by 'body within' not geometric center.
!
! COMMAND SYNTAX:
!
!             (1)   (2)  (3)   (4)     (5)   (6)    (7)   (8)   (9)
!   acylsel,'seltype',radi,rado,theta1,theta2,z1,z2,entinc_,angz_,tol_
!
!   Note: arguments in single quotes are strings and must be entered in ' '.
!
! ARGUMENTS:
!
!  seltype_= selection type
!            - selected from the full set (s)
!            - reselect from the current set (r)
!            - additionally select to the current selected set (a),
!            - unselect from the current set (u)
!    radi_ = radius inner
!    rado_ = radius outer
!   theta1_= beginning angle
!   theta2_= ending angle
!       z1_= beginning Z dimension
!       z2_= ending Z dimension
!   entinc_= 1 = select associated kp,line,area,node,elements;
!            0 = do not select (default) of final area set.
!     angz_= angle and z selected per area centroid;
!            0 = per 'body within' (default)
!      tol_= + or - tolerance on radius and Z dimensions (angle TBD)
!        - Example: (1-tol_)*radi_ and (1+tol_)*rado_
!        - Important to put Z in correct order of low to high if using
!          tolerance.
!        - tolerance is needed because sometimes off by 1e-7 inexplicably.
!
! DESCRIPTION:
!
!   Select areas by 'body within' not geometric center.
!
!   Area(s) whose keypoints, not geometric center, are located within
!   the specified region will be selected.  See arguments for additional
!   options.  The current coordinate system does not have to be cylindrical.
!
!   In comparison, the ANSYS command (ASEL) is based upon the area centroid
!   and can only specify one direction per command.
!
! WARNING:
!
!   - Coordinate system (CS) 11 may be overwritten due to create_cs if do not
!     track CS number (CSn)
!   - Important to put Z in correct order of low to high if using tolerance
!
! EXAMPLES:
!
!   TBD
!
! TO BE DONE:
!
!   - Add tolerance capability for radius.
!     Re-examine tolerance related to line selection.
!---------------------------------------------------------------------------

*get,prkey_,active,,prkey
/nopr

seltype_=ARG1
radi_=ARG2
rado_=ARG3
theta1_=ARG4
theta2_=ARG5
z1_=ARG6
z2_=ARG7
entinc_=ARG8
angz_=ARG9
tol_=AR10

!- Change to cylindrical CS if not already.
*GET,initCS_,ACTIVE,,CSYS
*GET,cstyp_,CDSY,initCS_,ATTR,KCS
*IF,cstyp_,NE,1,THEN  !not cylindrical CS
    *IF,CSn,EQ,0,THEN  !in case not tracking CSn, will work but may overwrite
       CSn=10
    *ENDIF
    create_cs,0,,1,0,0,0,0,0,0  !Change to cylindrical CS but do not name
*ENDIF

! Save initial area set to be used based upon selection type
cm,aset1_,area

! For 's' and 'a' select from full set.
*IF,seltype_,EQ,'s',THEN
   asel,all
*ELSEIF,seltype_,EQ,'a',THEN
   asel,all
*ENDIF

!-----------------------------------------------------------------------------------
!-- Obtain Area set for select operation based upon angz_.
!   1st) Using ASEL, selects areas whose centers are within specified boundaries
!   2nd) Using KSEL, reselects areas whose keypoints are within specified radius
!-----------------------------------------------------------------------------------
!- 1st)
*IF,angz_,EQ,1,THEN
    *IF,radi_,NE,rado_,THEN
        asel,r,loc,x,0,(1+tol_)*rado_
    *ENDIF

    *IF,theta1_,NE,theta2_,THEN
        asel,r,loc,y,theta1_,theta2_
    *ENDIF

    *IF,Z1_,NE,Z2_,THEN
        asel,r,loc,z,(1-tol_)*z1_,(1+tol_)*z2_
    *ENDIF
*ENDIF

!- 2nd)
lsla  $ksll

*IF,radi_,NE,rado_,THEN
   ksel,r,loc,x,(1-tol_)*radi_,(1+tol_)*rado_
*ENDIF

*IF,angz_,NE,1,THEN
    *IF,theta1_,NE,theta2_,THEN
       cm,ktmp,KP       !do not want to lose keypoints along axis
       ksel,r,loc,x,0
       cm,ktmpcnt,KP
       cmsel,s,ktmp
       ksel,r,loc,y,theta1_,theta2_  !select within angle not including along axis
       cmsel,a,ktmpcnt   !add back keypoints along axis
    *ENDIF

    *IF,Z1_,NE,Z2_,THEN
       ksel,r,loc,z,(1-tol_)*z1_,(1+tol_)*z2_
    *ENDIF
*ENDIF

lslk,s,1  $asll,s,1
cm,aset2_,area

!------------------------------------------------------------------------
!  selection routine
!------------------------------------------------------------------------
*if,seltype_,eq,'s',then
    cmsel,s,aset2_
*elseif,seltype_,eq,'u',then
    cmsel,s,aset1_
    cmsel,u,aset2_
*elseif,seltype_,eq,'r',then
    cmsel,s,aset1_
    cmsel,r,aset2_
*elseif,seltype_,eq,'a',then
    cmsel,s,aset1_
    cmsel,a,aset2_
*endif

*IF,entinc_,EQ,1,THEN
   lsla
   ksll
   esla
   nsle
   aplo  !areas can be viewed w/o lines and keypoints unlike volumes to areas.
*ENDIF

! Reset CS to initial CS
csys,initCS_

!**** RESET (eliminate) INTERNAL VARIABLES
*set,seltype_
*set,radi_
*set,rado_
*set,theta1_
*set,theta2_
*set,z1_
*set,z2_
*set,entinc_
*set,angz_
*set,tol_
*set,initCS_
*set,cstyp_

!*** delete component groups
cmdele,aset1_
cmdele,aset2_
cmdele,ktmp
cmdele,ktmpcnt

*if,prkey_,eq,1,then
  /gopr


w:\ansys\mac\tools\radial_asel.mac.html

!   TITLE:  radial_asel.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      03/25/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro selects an area, or set of areas, by radial position.
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)   (4)    (5)   (6)    (7)   (8)
!        RADIAL_ASEL, stype, acs, rlow, rhigh, alow, ahigh, zlow, zhigh
!
!
!   ARGUMENTS:
!
!       (1) stype = label outlining the selection type
!
!                   'u' = unselect
!                   's' = select
!                   'r' = reselect
!
!       (2) acs = active cylindrical C.S. in which selection process occurs
!
!       (3) rlow = lower limit radius of envelope
!
!       (4) rhigh = upper limit radius of envelope
!
!       (5) alow = lower limit angle of envelope
!
!       (6) ahigh = upper limit angle of envelope
!
!       (7) zlow = lower limit axial position of envelope
!
!       (8) zhigh = upper limit axial position of envelope
!
!
!   DESCRIPTION:
!
!   This macro allows a user to specify radial and angular position limits
!   of an area(s) without knowledge of the area centroid.  It is useful for
!   arc-shaped areas where the centoid is off of the area.
!
!   This macro uses the keypoint positions and their attached lines to select,
!   reselect and unselect the area(s) in question. Therefore, the envelope
!   containing the area boundary keypoints is used to either select, unselect
!   or reselect the desired area(s).
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

cm,kset2_,kp
cm,lset2_,line
!
cm,aset1_,area
!
typ_=arg1
acs_=arg2
rlow_=arg3
rhigh_=arg4
alow_=arg5
ahigh_=arg6
zlow_=arg7
zhigh_=arg8
!
!
*get,actcs_,active,,csys
!
csys,acs_
!
ksel,s,loc,x,rlow_,rhigh_
ksel,r,loc,y,alow_,ahigh_
ksel,r,loc,z,zlow_,zhigh_
!
lslk,s,1
!
*if,typ_,eq,'r',then
    asll,r,1
*else
    asll,s,1
*endif
!
*get,acount_,area,,count
!
*if,acount_,eq,0,then
    *if,typ_,eq,'r',then
        asll,r,0
    *else
        asll,s,0
    *endif
*endif
!
*if,typ_,eq,'u',then
    cm,aset2_,area
    cmsel,s,aset1_
    cmsel,u,aset2_
*endif
!
cmsel,s,kset2_
cmsel,s,lset2_
!
csys,actcs_
!
*set,acount_,
*set,actcs_,
*set,acs_,
*set,rlow_,
*set,rhigh_,
*set,alow_,
*set,ahigh_,
*set,zlow_,
*set,zhigh_,
cmdele,aset1_
cmdele,aset2_
cmdele,kset2_
cmdele,lset2_


w:\ansys\mac\tools\aslc.mac.html

!   TITLE:  aslc.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/02/2001      D. Edwards
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   Area Select by Coordinate
!
!   COMMAND SYNTAX:
!
!               (1) (2) (3) (4)
!        ASLC, Type, X,  Y,  Z
!
!
!   ARGUMENTS:
!
!       (1) Type = label identifying the type of area to select:
!
!                   's' = Select a new set (default).
!                   'r' = Reselect a set from the current set.
!                   'a' = Additionally select a set and extend the current set.
!                   'u' = Unselect a set from the current set.
!
!       (2) X = First coordinate in the active coordinate system
!
!       (3) Y = Second coordinate in the active coordinate system
!
!       (4) Z = Third coordinate in the active coordinate system
!
!
!   DESCRIPTION:
!
!   Selects those areas containing the keypoint at the specified coordinate.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

! Store away current line and kp selection
cm,cur_kp_,kp
cm,cur_l_,line

kp_num_=kp(arg2,arg3,arg4)

ksel,s,kp,,kp_num_

lslk,s,0
asll,arg1,0

! Restore the kp and line selection
ksel,s,kp,,cur_kp_
lsel,s,line,,cur_l_

*set,cur_kp_
*set,cur_l_
*set,kp_num_


w:\ansys\mac\tools\ln_sel_end.mac.html

!   TITLE:  ln_sel_end.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/01/2001      D. Edwards
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro returns the line number of the ith line attached to the
!   keypoint nearest to the given x, y, z coordinates.
!
!   COMMAND SYNTAX:
!
!                     (1)   (2)(3)(4)(5)
!        ln_sel_end, 'parm', x, y, z, i
!
!
!   ARGUMENTS:
!
!           parm  = The resulting line number is assigned to the
!                   parameter name given by the quoted string given
!                   in the first argument.
!
!          x,y,z  = Coordinates relative to the active CS of a keypoint
!                   attached to the line of whose number it is desired.
!
!              i  = Starting from the lowest number line, return the number
!                   of the ith line attached to the keypoint nearest (x,y,z).
!                   Default = 1
!
!
!   DESCRIPTION:
!
!   Ocassionaly it is difficult to obtain a line number by its midpoint
!   location, and the location of an end point is more readily known and
!   parameterized.  This macro allows a line number to be obtained
!   based one of its keypoints.
!
!   If more than one line number is attached to the keypoint, the "i"
!   parameter allows the ith line number to be obtained.  The ith line
!   is based on line number magnitudes.  For example, say lines 20, 24
!   and 38 are attached to the keypoint, then for i = 2, line 24 would be
!   returned.
!
!   This macro is intended to be used when lines outside of a current macro
!   block need to be referenced.  The lm-xx method is not portable becasue
!   moving macro blocks around alters the lines numbers.  This method avoids
!   that pitfal and allows line selection to be done without depending on a
!   previous state of line numbering.  The only time this method will fail is
!   when the ordering of the lines connected to the keypoint is changed.
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

parm_=arg1
x_=arg2
y_=arg3
z_=arg4
i_=arg5

cm,kpset_,kp
cm,lset_,line

ksel,s,kp,,kp(x_,y_,z_)
lslk,s,0

%parm_%=0

*do,ii_,1,i_
    %parm_%=lsnext(%parm_%)
*enddo

ksel,s,kp,,kpset_
lsel,s,line,,lset_

*set,parm_
*set,x_
*set,y_
*set,x_
*set,i_
*set,ii_


l:\ansys\mac\tools\as3d.mac.html

! TITLE:  as3d.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!   Rev -     03/04/02    J. Judd
!---------------------------------------------------------------------------
!
! OBJECTIVE:
!
!  Select area(s) by coordinate centroid location in one command
!
! COMMAND SYNTAX:
!
!          (1)     (2)(3)(4)(5)(6)(7)
!   as3d,'seltype_',x1,x2,y1,y2,z1,z2
!
!   Note: arguments in single quotes are strings and must be entered in ' '.
!
! ARGUMENTS:
!
!  seltype_ = selection type:
!              - selected from the full set (s)
!              - reselect from the current set (r)
!              - additionally select to the current selected set (a),
!              - unselect from the current set (u)
!  x1 = First x location in the active coordinate system.
!  x2 = Second x location in the active coordinate system.
!  y1,y2,z1,z2 = same as above except for y and z locations
!
! DESCRIPTION:
!
!  Selects area(s) by their coordinate centroid location using one command.
!
!---------------------------------------------------------------------------
*GET,AR67,ACTIVE,,PRKEY
/NOPR

*GET,AR99,PARM,ARG1,Type
*IF,AR99,EQ,3,THEN
   cm,AR19,AREA  !currently selected

   asel,s,loc,x,ARG2,ARG3   !select by location
   asel,r,loc,y,ARG4,ARG5
   asel,r,loc,z,ARG6,ARG7
   cm,AR20,AREA

   cmsel,s,AR19
   cmsel,ARG1,AR20
*ELSE
   *MSG,WARN
   The first argument must be a character scalar variable or %/&
   be enclosed in singe quotes ('s', 'r', 'a', 'u').
*ENDIF

*IF,AR67,EQ,1,THEN
  /GOPR


w:\ansys\mac\tools\isolate_areas.mac.html

!   TITLE:  isolate_areas.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  04/07/2000    J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A             01/10/2001    J. Judd
!
!           Added *IF statements to reduce warnings for when a component
!           does not exist.  e.g. [ksel,u,,kp,,kset] ,etc.
!---------------------------------------------------------------------------
!
!   This sub-macro is used to isolate (select out) a set of areas (and
!   associated lines and keypoints) that are to be used in the creation
!   of a new volume (e.g., using the 'VA' command). These lines are
!   unattached to any volumes that may already exist. The remaining solid
!   model entities are maintained unselected and therefore do not inter-
!   fere with these areas to be operated on to create new volumes.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*if,kp_pssof,gt,0,then      ! unselects all previous model entities
    ksel,u,kp,,_kset_
*endif
!
*if,ln_pssof,gt,0,then
    lsel,u,line,,_lset_
*endif
!
*if,ar_pssof,gt,0,then
    asel,u,area,,_aset_
*endif
!
*if,vl_pssof,gt,0,then
    vsel,u,volu,,_vset_
*endif
!
*if,el_pssof,gt,0,then
    esel,u,elem,,_eset_
*endif
!
*if,nd_pssof,gt,0,then
    nsel,u,node,,_ndset_
*endif
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then              ! decision: 'There exists new volumes?'
    !
    cm,vset_100,volu            ! store new volumes in a group
    !
    aslv,selv                   ! store all existing entities associated with
        cm,aset_100,area        ! all existing new volumes in groups
    lsla,selv
        cm,lset_100,line
    ksll,selv
        cm,kset_100,kp
    !
    allsel,all                  ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    vsel,u,volu,,vset_100       ! unselects all existing solid model entities
    asel,u,area,,aset_100       ! associated with new volumes
    lsel,u,line,,lset_100
    ksel,u,kp,,kset_100
*endif
!
*get,am,area,,num,max           ! store maximum area # in 'am'
*get,lm,line,,num,max           ! store maximum line # in 'lm'
*get,km,kp,,num,max             ! store maximum keypoint # in 'km'
!
*if,am,ne,0,then
    aplot
*else
    lplot
*endif
!
cmdele,vset_100
cmdele,aset_100
cmdele,lset_100
cmdele,kset_100


w:\ansys\mac\tools\isolate_lines.mac.html

!   TITLE:  isolate_lines.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/12/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   01/10/2001      J. Judd
!
!           Added *IF statements to reduce warnings for when a component
!           does not exist.  e.g. [ksel,u,,kp,,kset] ,etc.
!---------------------------------------------------------------------------
!
!   This sub-macro is used to isolate (select out) a set of lines (and
!   associated keypoints) that are to be used in the creation of a new
!   area and/or volume (e.g., using the 'AL' command). These lines are
!   unattached to any areas or volumes that may already exist. The remain-
!   ing solid model entities are maintained unselected and therefore do
!   not interfere with these lines to be operated on to create new areas
!   and/or volumes.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*if,kp_pssof,gt,0,then      ! unselects all previous model entities
    ksel,u,kp,,_kset_
*endif
!
*if,ln_pssof,gt,0,then
    lsel,u,line,,_lset_
*endif
!
*if,ar_pssof,gt,0,then
    asel,u,area,,_aset_
*endif
!
*if,vl_pssof,gt,0,then
    vsel,u,volu,,_vset_
*endif
!
*if,el_pssof,gt,0,then
    esel,u,elem,,_eset_
*endif
!
*if,nd_pssof,gt,0,then
    nsel,u,node,,_ndset_
*endif
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then          ! decision: 'There exists new volumes?'
    !
    cm,vset_10,volu         ! store new volumes in a group
    !
    aslv,selv               ! store all existing entities associated with
        cm,aset_10,area     ! all existing new volumes in groups
    lsla,selv
        cm,lset_10,line
    ksll,selv
        cm,kset_10,kp
        !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*get,am,area,,num,max
!
*if,am,ne,amu,then          ! decision: 'There exists new areas?'
    !
    cm,aset_20,area         ! store new volumes in a group
    !
    lsla,r                  ! store all existing entities associated
        cm,lset_20,line     ! with all existing new areas in groups
    ksll,r
        cm,kset_20,kp
        !
    asel,u,area,,aset_20
    lsel,u,line,,lset_20    ! unselects all existing solid model
    ksel,u,kp,,kset_20      ! entities associated with new areas
    !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
*endif
!
*if,vm,ne,vmu,then
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*if,am,ne,amu,then
    asel,u,area,,aset_20        ! unselects all existing solid model
    lsel,u,line,,lset_20        ! entities associated with new areas
    ksel,u,kp,,kset_20
*endif
!
*get,lm,line,,num,max       ! store maximum line # in 'lm'
*get,km,kp,,num,max         ! store maximum keypoint # in 'km'
!
*if,lm,ne,0,then            ! If new lines unattached to all
    lplot                   ! unselected entities exist, then
*else                       ! PLOT them.  If not, then plot new
    kplot                   ! keypoints.
*endif
!
cmdele,vset_10
cmdele,aset_10
cmdele,lset_10
cmdele,kset_10
!
cmdele,aset_20
cmdele,lset_20
cmdele,kset_20


w:\ansys\mac\tools\isolate_kp.mac.html

!   TITLE:  isolate_kp.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    05/24/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to isolate (select out) a set of keypoints (KP)
!   that are unattached to any lines, areas or volumes that may already
!   exist. The remaining solid model entities are maintained unselected
!   and therefore do not interfere with these KP's.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*if,kp_pssof,gt,0,then      ! unselects all previous model entities
    ksel,u,kp,,_kset_
*endif
!
*if,ln_pssof,gt,0,then
    lsel,u,line,,_lset_
*endif
!
*if,ar_pssof,gt,0,then
    asel,u,area,,_aset_
*endif
!
*if,vl_pssof,gt,0,then
    vsel,u,volu,,_vset_
*endif
!
*if,el_pssof,gt,0,then
    esel,u,elem,,_eset_
*endif
!
*if,nd_pssof,gt,0,then
    nsel,u,node,,_ndset_
*endif
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then          ! decision: 'There exists new volumes?'
    !
    cm,vset_10,volu         ! store new volumes in a group
    !
    aslv,selv               ! store all existing entities associated with
        cm,aset_10,area     ! all existing new volumes in groups
    lsla,selv
        cm,lset_10,line
    ksll,selv
        cm,kset_10,kp
        !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*get,am,area,,num,max
!
*if,am,ne,amu,then          ! decision: 'There exists new areas?'
    !
    cm,aset_20,area         ! store new volumes in a group
    !
    lsla,r                  ! store all existing entities associated
        cm,lset_20,line     ! with all existing new areas in groups
    ksll,r
        cm,kset_20,kp
        !
    asel,u,area,,aset_20
    lsel,u,line,,lset_20    ! unselects all existing solid model
    ksel,u,kp,,kset_20      ! entities associated with new areas
    !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    asel,u,area,,aset_20        ! unselects all existing solid model
    lsel,u,line,,lset_20        ! entities associated with new areas
    ksel,u,kp,,kset_20
    !
    *if,vm,ne,vmu,then
        vsel,u,volu,,vset_10        ! unselects all existing solid model entities
        asel,u,area,,aset_10        ! associated with new volumes
        lsel,u,line,,lset_10
        ksel,u,kp,,kset_10
    *endif
*endif
!
*get,lm,line,,num,max
!
*if,lm,ne,lmu,then          ! decision: 'There exists new areas?'
    !
    cm,lset_30,line         ! store new volumes in a group
    !
    ksll,r                  ! store all existing entities associated
        cm,kset_30,kp       ! with all existing new areas in groups
        !
    lsel,u,line,,lset_30    ! unselects all existing solid model
    ksel,u,kp,,kset_30      ! entities associated with new areas
    !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    lsel,u,line,,lset_30        ! entities associated with new areas
    ksel,u,kp,,kset_30
    !
    *if,am,ne,amu,then
        asel,u,area,,aset_20        ! unselects all existing solid model
        lsel,u,line,,lset_20        ! entities associated with new areas
        ksel,u,kp,,kset_20
    *endif
    !
    *if,vm,ne,vmu,then
        vsel,u,volu,,vset_10        ! unselects all existing solid model entities
        asel,u,area,,aset_10        ! associated with new volumes
        lsel,u,line,,lset_10
        ksel,u,kp,,kset_10
    *endif
*endif
!
*get,km,kp,,num,max                 ! store maximum keypoint # in 'km'
!
kplot
!
cmdele,vset_10
cmdele,aset_10
cmdele,lset_10
cmdele,kset_10
!
cmdele,aset_20
cmdele,lset_20
cmdele,kset_20
!
cmdele,lset_30
cmdele,kset_30


w:\ansys\mac\tools\tstart.mac.html

!
!   TITLE:  tstart.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  12/07/2000  D. Edwards
!---------------------------------------------------------------------------
!
! This macro is used to measure the time duration it takes ANSYS to do
! a block of commands.
!
! The tstart/tstop pair of macro commands work just like a stopwatch.
! At the start of a block of code call "tstart" and then at the end call
! tstop.  The elapsed time since tstart was called is then displayed.
!
! The output gives the actual time the CPU spent on running ANSYS code and
! the elapsed wall clock time.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! tstart
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

*get,_start_w,active,0,time,wall
*get,_start_c,active,0,time,cpu

/out,tstart,out
*vwrite,_start_w
('*SET,_start_w,',E20.8)

*vwrite,_start_c
('*SET,_start_c,',E20.8)
/out


w:\ansys\mac\tools\tstop.mac.html

!
!   TITLE:  tstop.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   12/07/2000  D. Edwards
!---------------------------------------------------------------------------
!
!       Rev A   03/08/2001  D. Edwards
!
!       Display time duration in H:M:S format instead of just decimal
!       minutes.
!
!---------------------------------------------------------------------------
!
! This macro is used to measure the time duration it takes ANSYS to do
! a block of commands.
!
! The tstart/tstop pair of macro commands work just like a stopwatch.
! At the start of a block of code call "tstart" and then at the end call
! "tstop".  The elapsed time since tstart was called is then displayed.
!
! The output gives the actual time the CPU spent on running ANSYS code and
! the elapsed wall clock time.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! tstop
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

parres,change,tstart,out

*get,_stop_w,active,0,time,wall
*get,_stop_c,active,0,time,cpu

hr_w_=_stop_w-_start_w
hr_c_=(_stop_c-_start_c)/3600

*if,hr_w_,gt,24,then

da_w_=hr_w_/24-mod(hr_w_/24,1)
da_c_=hr_c_/24-mod(hr_c_/24,1)

hr_w_=hr_w_-da_w_*24
hr_c_=hr_c_-da_c_*24

min_w_=mod(hr_w_,60)
min_c_=mod(hr_c_,60)

hr_w_=hr_w_-mod(hr_w_,1)
hr_c_=hr_c_-mod(hr_c_,1)

*msg,ui,da_w_,hr_w_,min_w_,da_c_,hr_c_,min_c_
Wall Clock Duration: %I days, %I hours, %I minutes %/ &
CPU  Clock Duration: %I days, %I hours, %I minutes

*else

min_w_=60*mod(hr_w_,1)
min_c_=60*mod(hr_c_,1)

hr_w_=hr_w_-mod(hr_w_,1)
hr_c_=hr_c_-mod(hr_c_,1)

sec_w_=60*mod(min_w_,1)
sec_c_=60*mod(min_c_,1)

min_w_=min_w_-mod(min_w_,1)
min_c_=min_c_-mod(min_c_,1)

msec_w_=1000*mod(1e-6+sec_w_,1)
msec_c_=1000*mod(1e-6+sec_c_,1)

sec_w_=sec_w_-mod(sec_w_,1)
sec_c_=sec_c_-mod(sec_c_,1)

*msg,ui,hr_w_,min_w_,sec_w_,hr_c_,min_c_,sec_c_
Wall Clock Duration: %I hr, %I min, %I sec %/ &
CPU Clock Duration: %I hr, %I min, %I sec

! Milisecond version
!*msg,ui,hr_w_,min_w_,sec_w_,msec_w_,hr_c_,min_c_,sec_c_,msec_c_
!Wall Clock Duration: %I hr, %I min, %I sec, %I msec %/ &
!CPU Clock Duration: %I hr, %I min, %I sec, %I msec

*endif

*set,_stop_w
*set,_stop_c
*set,da_w_
*set,da_c_
*set,hr_w_
*set,hr_c_
*set,min_w_
*set,min_c_
*set,sec_w_
*set,sec_c_
*set,msec_w_
*set,msec_c_


l:\ansys\mac\tools\ifany.mac.html

! TITLE:  ifany.mac (MANAGEMENT)
!
!-----------------------------------------------------------------------------
!   Rev -    03/04/2002     J. Judd
!------------------------------------------------------------------------------
!   Rev A    03/08/2002     J. Judd
!   - Add error checking
!   - Add message report of result, last arg to match, # to match, and if
!     any bad matches.  Slows down for stats because doesn't exit once find
!     first comparison.
!------------------------------------------------------------------------------
!
! OBJECTIVE:
!
!   Compares string or number with list via logic symbol
!   Compares ARG1 to ARG3 thru ARG9 and if any compare per ARG2 logic then
!   the variable ifany = 1 otherwise ifany = 0.
!
! COMMAND SYNTAX:
!
!   ifany,ARG1,ARG2,ARG3,....
!
! ARGUMENTS:
!
!   ARG1 is normally a number or string variable.
!   ARG3 thru ARG? can be either a number or string.  Strings must be in single
!   quotes and are limited to 8 characters with the usual ANSYS string restrictions.
!
!   ARG2 can be any of the following logical abbreviations
!      'EQ' = equal
!      'NE' = not equal
!      'LT' = less than
!      'GT' = greater than
!      'LE' = less than or equal
!      'GE' = greater than or equal
!      'ABLT' = absolute values less than (numbers only)
!      'ABGT' = absolute values greater (numbers only)
!
! DESCRIPTION:
!
!   Compares ARG1 to ARG3 thru ARG9 and if any compare per ARG2 logic then
!   the variable ifany = 1 otherwise ifany = 0.
!
! WARNING:
!
!   - The command line must be less than 64? characters long or it will be cut off.
!
! EXAMPLES:
!
!   see below
!
! TO BE DONE:
!
!  - Warn if cut off because command line too long.
!  - Create another similar macro to search arrrays.  Items in list can be scalars or arrays.
!    If an array name is the same as a character scalar, the argument will be assumed to refer
!    to the array and not the scalar?
!---------------------------------------------------------------------------
!
*GET,AR91,CMD,0,NARGS      !Field number of last non-blank field on the previous command.
!                          !for macros includes macroname as field
!
!--------------------------------- EXAMPLES -------------------------------
*GET,AR67,ACTIVE,,PRKEY
/NOPR

skip=1
*IF,skip,EQ,0,THEN
   ifany,'zebra','EQ','cat','dog','elephant','hippopatomous','zebra'
   ! will set ifany = 1 because 'zebra' is equal to at least one of the ARG3 thru ARG9 inputs.

   animal='hippo'
   ifany,animal,'EQ','cat','dog','hippopatomous'
   ! will set ifany = 0 because 'hippo' is not equal to at any of the ARG3 thru ARG9 inputs.

   animal='hippo' $match=animal
   ifany,animal,'EQ','cat','dog','hippo',match
   ! will set ifany = 1 because 'hippo'='hippo' and match='hippo'

   ifany,'zebra','EQ',1,'dog','elephant','hippopatomous','zebra'
   ! will set ifany = 1 but will report a bad match due to ARG3 = scalar

*ENDIF
*set,skip
!-------------------------- MAIN CODE ----------------------------------------
ifany=0

!- ARG1 parameter type
*GET,AR80,PARM,ARG1,TYPE
!  Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,
!                  4=character array, -1=undefined Parameter

!- Check if comparison argument valid and if not abort
*IF,ARG2,EQ,'EQ',OR,ARG2,EQ,'NE',THEN
*ELSEIF,ARG2,EQ,'LT',OR,ARG2,EQ,'GT',THEN
*ELSEIF,ARG2,EQ,'LE',OR,ARG2,EQ,'GE',THEN
*ELSEIF,ARG2,EQ,'ABLT',OR,ARG2,EQ,'ABGT',THEN
   *IF,AR80,EQ,0,THEN
   *ELSE
      AR99=1   !'abort'
      *MSG,WARN,ARG2
      Argument 1 is not a scalar, therefore cannot use %C.
   *ENDIF
*ELSE
   AR99=1      !'abort'
   *MSG,WARN
   The logical operator provided in argument 2 is not valid. %/&
   Hint: must put single quotes around operator abbreviation. %/&
   (e.g. 'EQ','NE','LT','GT','LE','GE','ABLT','ABGT')
*ENDIF

*IF,AR99,NE,1,THEN    !don't abort
   !- Compare ARG1 to ARG3 thru ...
   !- Check each argument before compare to make sure that it is a valid comparison
   !    (e.g. character to character, scalar to scalar)
   *DO,AR50,3,AR91-1
     *IF,AR50,GE,10,THEN
        *GET,AR81,PARM,AR%AR50%,TYPE
        *IF,AR81,EQ,AR80,THEN
           *IF,ARG1,%ARG2%,AR%AR50%,THEN
               ifany=1
               AR97=AR50  !an argument # which matched
               AR96=AR96+1  !count of how many matched
               !*EXIT       !removed at Rev A
           *ENDIF
        *ELSE
           AR98=AR98+1   !'badmatch'
           *MSG,WARN,AR50
           The parameter type of argument %I does not match the %/&
           the parameter type of argument 1.  These arguments were %/&
           not compared.  Please review and correct.
        *ENDIF
     *ELSEIF,AR50,LT,10,THEN
        *GET,AR81,PARM,ARG%AR50%,TYPE
        *IF,AR81,EQ,AR80,THEN
           *IF,ARG1,%ARG2%,ARG%AR50%,THEN
               ifany=1
               AR97=AR50      !an argument # which matched
               AR96=AR96+1    !count of how many matched
               !*EXIT       !removed at Rev A
           *ENDIF
        *ELSE
           AR98=AR98+1    !'badmatch'
           *MSG,WARN,AR50
           The parameter type of argument %I does not match the %/&
           the parameter type of argument 1.  These arguments were %/&
           not compared.  Please review and correct.
        *ENDIF
     *ENDIF
   *ENDDO
   !- Report findings and whether any badmatches
   *IF,AR98,GE,1,THEN
      *IF,ifany,EQ,1,THEN
         *MSG,NOTE,ifany,AR96,AR97,AR98
         ifany = %I. %/&
         There was %I match(es) with the last match being argument %I.%/&
         There was %I argument(s) whose parameter type did not match ARG1%/&
         See Warnings above.
      *ELSE
         *MSG,NOTE,ifany,AR96,AR97,AR98
         ifany = %I. %/&
         There were no matches. %/&
         There was %I argument(s) whose parameter type did not match ARG1%/&
         See Warnings above.
      *ENDIF
   *ELSE
      *IF,ifany,EQ,1,THEN
         *MSG,NOTE,ifany,AR96,AR97
         ifany = %I. %/&
         There was %I match(es) with the last match being argument %I.
      *ELSE
         *MSG,NOTE,ifany,AR96,AR97
         ifany = %I. %/&
         There were no matches.
      *ENDIF
   *ENDIF
*ENDIF  !(AR99=abort)

*IF,AR67,EQ,1,THEN
  /GOPR


w:\ansys\mac\tools\ar_dist_pt_calc.mac.html

!   TITLE:  ar_dist_pt_calc.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/23/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   01/24/2002      J. Rinaldi
!
!           Implemented graphical picking option.
!---------------------------------------------------------------------------
!
!   TOOLBAR MACRO
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distance between a planar
!   area and a keypoint.
!
!
!   ARGUMENTS:
!
!           1 prompt:   Area & Keypoint numbers to measure distance
!                       between:
!
!                                   AR# and KP#
!
!                       Decimal precision of output
!
!                                   PREC
!
!           NOTE: If the input boxes for the area & keypoint numbers are left
!                 to their default values of 0, then graphical picking is enabled.
!                 In this case, the user must select exactly 1 area and 1 keypoint
!                 only.
!
!
!   DESCRIPTION:
!
!   This macro calculates the perpendicular (minimum) distance between an area
!   and a keypoint. This distance is only valid if the input area is cartesian
!   planar.
!
!   The output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
cm,kset1__,kp
cm,aset1__,area
cm,lset1__,line
!
*get,acs1_,active,,csys
!
grphpic_=0
!
multipro,'start',3
    *cset,1,3,ar_,'Enter Area #',0
    *cset,4,6,kpt_,'Enter KP #',0
    *cset,7,9,prec_,'Enter Decimal Precision',4
    *cset,61,62,'Calculates the normal dist','ance between an area and'
    *cset,63,64,'a keypoint. Enter the area',' and KP numbers.'
multipro,'end'
!
*if,ar_,eq,0,then
    *if,kpt_,eq,0,then
        /ui,asel
        /ui,ksel
        get_max_entity
        !
        *get,acount_,area,,count
        *get,kcount_,kp,,count
        !
        ar_=am
        kpt_=km
        !
        grphpic_=1
    *endif
*endif
!
*if,grphpic_,eq,0,then
    ar1_=asel(ar_)
    kp1_=ksel(kpt_)
    !
    *if,ar1_,eq,1,then
        *if,kp1_,eq,1,then
            acount_=1
            kcount_=1
        *else
            acount_=1
            kcount_=0
        *endif
    *else
        *if,kp1_,eq,1,then
            acount_=0
            kcount_=1
        *else
            acount_=0
            kcount_=0
        *endif
    *endif
*endif
!
*if,acount_,eq,1,then
    *if,kcount_,eq,1,then
        *if,prec_,le,0,then
            prec_=4
        *endif
        !
        tol_=10**(-prec_-1)
        !
        asel,s,area,,ar_
        asum
        lsla,s
        ksll,s
        get_min_entity
        *get,kcnt_,kp,k_min,nxth
        !
        *get,acx_,area,,cent,x
        *get,acy_,area,,cent,y
        *get,acz_,area,,cent,z
        !
        csys,0
        k,,acx_,acy_,acz_
        get_max_entity
        xypt_=km
        !
        cskp,csn+5,0,kcnt_,k_min,xypt_
        kdele,xypt_
        get_max_entity
        !
        ksel,a,kp,,kpt_
        dist__=abs(kz(kpt_))
        !
        *if,abs(dist__),lt,tol_,then
            dist__=0
        *else
            *if,abs(dist__),ge,(10*tol_),then
                round_num,dist__,prec_
            *else
                round_num,dist__,prec_+1
            *endif
            !
            dist__=num_
        *endif
        !
!--------------------------------------
*msg,ui,%ar_%,%kpt_%,%dist__%
Distance Between ( A %i , KP %i ) = %g
!--------------------------------------
        !
        csdele,csn+5
        csys,acs1_
        !
        *set,dist__,
        *set,k_min,
        *set,kcnt_,
        *set,acs1_,
        *set,tol_,
        *set,xypt_,
    *endif
*endif
!
*if,acount_,gt,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Areas and KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Areas, Insufficient KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,eq,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Areas Picked. Must Select 1 Only.
!---------------------------------------------------------------
    *endif
*elseif,acount_,lt,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Areas and Too Many KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Areas and KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,eq,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Areas Picked. Must Select 1 Only.
!---------------------------------------------------------------
    *endif
*elseif,acount_,eq,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *endif
*endif
!
init_entity_num
!
cmsel,s,kset1__
cmsel,s,aset1__
cmsel,s,lset1__
/replot
!
*set,ar_,
*set,kpt_,
*set,prec_,
*set,ar1_,
*set,kp1_,
*set,acount_,
*set,kcount_,
*set,grphpic_,
cmdele,kset1__
cmdele,aset1__
cmdele,lset1__
!
/gopr


w:\ansys\mac\tools\cs_dist_pt_calc.mac.html

!   TITLE:  cs_dist_pt_calc.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/15/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   01/24/2002      J. Rinaldi
!
!           Implemented graphical picking option.
!---------------------------------------------------------------------------
!
!   TOOLBAR MACRO
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distances of a keypoint
!   relative to a coordinate system (C.S.).
!
!
!   ARGUMENTS:
!
!           1 prompt:   C.S. number & Keypoint number to measure distances
!                       between:
!
!                                   CS# and KP#
!
!           NOTE: If the input box for the keypoint number in the dialogue box
!                 is left to the default value of 0, then graphical picking is
!                 enabled. In this case, the user must select exactly 1 keypoint
!                 only.
!
!
!   DESCRIPTION:
!
!   This macro calculates the X, Y, Z and linear (absolute) distance between
!   a C.S. center and a keypoint, if the C.S. is cartesian. If the C.S. is not
!   cartesian, then the X,Y and Z coordinates are given, but not the distance.
!   The distances are the coordinates of the keypoint relative to that system.
!   Therefore, a cartesian system has coordinates X,Y and Z; a cylinindrical
!   system has coordinates R, Theta and Z; etc.
!
!   If the active C.S. is the desired C.S., then the first dialogue box may
!   be left unchanged (default), and the keypoint box only specified.
!
!   The output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
tol_=0.0001
prec_=4
!
cm,kset1__,kp
!
*get,acs1__,active,,csys
!
grphpic_=0
!
multipro,'start',2
    *cset,1,3,csnum__,'Enter C.S. #',acs1__
    *cset,4,6,kpt__,'Enter KP #',0
    *cset,7,9,prec_,'Enter Decimal Precision',4
    *cset,61,62,'Calculates the coordinate dist','ances of a keypoint relative'
    *cset,63,64,'to a specified C.S. Enter',' the C.S. and KP numbers.'
multipro,'end'
!
*if,kpt__,eq,0,then
    /ui,ksel
    get_max_entity
    !
    *get,kcount_,kp,,count
    !
    kpt__=km
    !
    grphpic_=1
*endif
!
*if,grphpic_,eq,0,then
    kp1_=ksel(kpt__)
    !
    *if,kp1_,eq,1,then
        kcount_=1
    *else
        kcount_=0
    *endif
*endif
!
*if,kcount_,eq,1,then
    *if,prec_,le,0,then
        prec_=4
    *endif
    !
    tol_=10**(-prec_-1)
    !
    csys,csnum__
    !
    dx__=kx(kpt__)
    !
    *if,abs(dx__),lt,tol_,then
        dx__=0
    *else
        *if,abs(dx__),ge,(10*tol_),then
            round_num,dx__,prec_
        *else
            round_num,dx__,prec_+1
        *endif
        !
        dx__=num_
    *endif
    !
    dy__=ky(kpt__)
    !
    *if,abs(dy__),lt,tol_,then
        dy__=0
    *else
        *if,abs(dy__),ge,(10*tol_),then
            round_num,dy__,prec_
        *else
            round_num,dy__,prec_+1
        *endif
        !
        dy__=num_
    *endif
    !
    dz__=kz(kpt__)
    !
    *if,abs(dz__),lt,tol_,then
        dz__=0
    *else
        *if,abs(dz__),ge,(10*tol_),then
            round_num,dz__,prec_
        *else
            round_num,dz__,prec_+1
        *endif
        !
        dz__=num_
    *endif
    !
    *get,csnumtyp,cdsy,csnum__,attr,kcs
    !
    *if,csnumtyp,eq,0,then
        dabs__=sqrt(((dx__**2))+((dy__**2))+((dz__**2)))
        !
        *if,abs(dabs__),lt,tol_,then
            dabs__=0
        *else
            *if,abs(dabs__),ge,(10*tol_),then
                round_num,dabs__,prec_
            *else
                round_num,dabs__,prec_+1
            *endif
            !
            dabs__=num_
        *endif
        !
!--------------------------------------------------------------------------
*msg,ui,%csnum__%,%kpt__%,%dx__%,%dy__%,%dz__%,%dabs__%
Coordinates ( CS %i , KP %i ) : %/&
%/&
X = %g %/&
Y = %g %/&
Z = %g %/&
%/&
D = %g
!--------------------------------------------------------------------------
        !
        *set,dabs__,
    *else
        *if,csnumtyp,eq,1,then
!--------------------------------------------------------------------
*msg,ui,%csnum__%,%kpt__%,%dx__%,%dy__%,%dz__%
Coordinates ( CS %i , KP %i ) : %/&
%/&
R = %g %/&
THETA = %g %/&
Z = %g %/&

!--------------------------------------------------------------------
        *elseif,csnumtyp,eq,2,then
!---------------------------------------------------------------------
*msg,ui,%csnum__%,%kpt__%,%dx__%,%dy__%,%dz__%
Coordinates ( CS %i , KP %i ) : %/&
%/&
R = %g %/&
THETA = %g %/&
PHI = %g %/&

!---------------------------------------------------------------------
        *else
!---------------------------------------------------------------
*msg,ui,%csnum__%,%kpt__%,%dx__%,%dy__%,%dz__%
Coordinates ( CS %i , KP %i ) : %/&
%/&
X = %g %/&
Y = %g %/&
Z = %g %/&

!---------------------------------------------------------------
        *endif
    *endif
*elseif,kcount_,gt,1,then
!--------------------------------------------
*msg,warn
Too Many KP's Picked. Must Select 1 KP Only.
!--------------------------------------------
*elseif,kcount_,lt,1,then
!--------------------------------------------
*msg,warn
No KP Selected. Must Select 1 KP Only.
!--------------------------------------------
*endif
!
init_entity_num
!
csys,acs1__
cmsel,s,kset1__
/replot
!
*set,csnum__,
*set,kpt__,
*set,dx__,
*set,dy__,
*set,dz__,
*set,csnumtyp,
*set,acs1__,
*set,tol_,
*set,prec_,
*set,kp1_,
*set,kcount_,
*set,grphpic_,
cmdele,kset1__
!
/gopr


w:\ansys\mac\tools\ct_dist_calcs.mac.html

!   TITLE:  ct_dist_calcs.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/27/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   01/23/2002      J. Rinaldi
!
!           Implemented grphical picking option.
!---------------------------------------------------------------------------
!
!   TOOLBAR MACRO
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distances between 2 keypoints.
!
!
!   ARGUMENTS:
!
!           1st prompt:     acs = active coordinate system to measure axial
!                                 distance in.
!
!                           Keypoint numbers to measure distance between:
!
!                                   KP1 and KP2
!
!           NOTE: If the input boxes for keypoint numbers in the dialogue box
!                 are left to their default values of 0, then graphical picking
!                 is enabled. In this case, the user must select exactly 2 key-
!                 points only.
!
!   DESCRIPTION:
!
!   This macro calculates the linear (cartesian) distances between 2 keypoints.
!   These distances are measured in all 3 axial directions: Dx, Dy and Dz, and the
!   absolute linear distance between them, Dabs. The distances are calculated rel-
!   ative to a desired user-specified coordinate system.
!
!   If the specified coordinate system is not cartesian, then the distance calcu-
!   lations are measured along the oriented axial directions of that coordinate
!   system as if it were cartesian. Therefore, a cartesian coordinate system need
!   not be created or specified as long as the axial directions of the specified
!   coordinate system are oriented as desired.
!
!   If the desired coordinate system is the current active coordinate system, then
!   simply pressing the ENTER key will suffice, since the default coordinate
!   system value activated by the user prompt is the current active coordinate
!   system. If the specified coordinate system is different from the current active
!   coordinate system, the calculations will be performed and the current active
!   coordinate system will be restored.
!
!   All output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
cm,kset1__,kp
!
*get,acs1_,active,,csys
!
grphpic_=0
!
multipro,'start',4
    *cset,1,3,csnum_,'COORDINATE SYSTEM #',acs1_
    *cset,4,6,prec_,'Decimal Precision of Output',4
    *cset,7,9,kp_1st,'Enter 1st Keypoint',0
    *cset,10,12,kp_2nd,'Enter 2nd Keypoint',0
    *cset,61,62,'Calculates the X,Y,Z and abs','olute (linear) distance'
    *cset,63,64,'between 2 keypoints. Enter',' the keypoint numbers.'
multipro,'end'
!
*if,kp_1st,eq,0,then
    *if,kp_2nd,eq,0,then
        /ui,ksel
        get_min_entity
        get_max_entity
        !
        *get,kcount_,kp,,count
        !
        kp_1st=k_min
        kp_2nd=km
        !
        grphpic_=1
    *endif
*endif
!
*if,grphpic_,eq,0,then
    kp1_=ksel(kp_1st)
    kp2_=ksel(kp_2nd)
    !
    *if,kp1_,eq,1,then
        *if,kp2_,eq,1,then
            kcount_=2
        *else
            kcount_=1
        *endif
    *else
        *if,kp2_,eq,1,then
            kcount_=1
        *else
            kcount_=0
        *endif
    *endif
*endif
!
*if,kcount_,eq,2,then
    csys,csnum_
    !
    *get,csnumtyp,cdsy,csnum_,attr,kcs
    !
    *if,csnumtyp,ne,0,then
        clocal,csn+1,0,0,0,0,0,0,0
        csnum_=csn+1
    *endif
    !
    *if,kp_1st,ne,0,then
        *if,kp_2nd,ne,0,then
            *if,prec_,le,0,then
                prec_=4
            *endif
            !
            tol_=10**(-prec_-1)
            !
            dx__=abs(kx(kp_1st)-kx(kp_2nd))
            !
            *if,abs(dx__),lt,tol_,then
                dx__=0
            *else
                *if,abs(dx__),ge,(10*tol_),then
                    round_num,dx__,prec_
                *else
                    round_num,dx__,prec_+1
                *endif
                !
                dx__=num_
            *endif
            !
            dy__=abs(ky(kp_1st)-ky(kp_2nd))
            !
            *if,abs(dy__),lt,tol_,then
                dy__=0
            *else
                *if,abs(dy__),ge,(10*tol_),then
                    round_num,dy__,prec_
                *else
                    round_num,dy__,prec_+1
                *endif
                !
                dy__=num_
            *endif
            !
            dz__=abs(kz(kp_1st)-kz(kp_2nd))
            !
            *if,abs(dz__),lt,tol_,then
                dz__=0
            *else
                *if,abs(dz__),ge,(10*tol_),then
                    round_num,dz__,prec_
                *else
                    round_num,dz__,prec_+1
                *endif
                !
                dz__=num_
            *endif
            !
            dabs__=distkp(kp_1st,kp_2nd)
            !
            *if,abs(dabs__),lt,tol_,then
                dabs__=0
            *else
                *if,abs(dabs__),ge,(10*tol_),then
                    round_num,dabs__,prec_
                *else
                    round_num,dabs__,prec_+1
                *endif
                !
                dabs__=num_
            *endif
            !
!--------------------------------------------------------------------------------------
*msg,ui,%kp_1st%,%kp_2nd%,%dx__%,%dy__%,%dz__%,%dabs__%
Distance Between KP #'s ( %i , %i ) : %/&
%/&
Dx = %g %/&
Dy = %g %/&
Dz = %g %/&
%/&
Dabs = %g
!--------------------------------------------------------------------------------------
            !
            *if,csnumtyp,ne,0,then
                csdele,csnum_
            *endif
            !
            csys,acs1_
            !
            *set,acs1_,
            *set,csnum_,
            *set,csnumtyp,
            *set,dx__,
            *set,dy__,
            *set,dz__,
            *set,dabs__,
            *set,tol_,
        *endif
    *endif
*elseif,kcount_,gt,2,then
!------------------------------------------------
*msg,warn
Too Many KP's Picked. Must Select 2 KP's Only.
!------------------------------------------------
*elseif,kcount_,lt,2,then
!------------------------------------------------
*msg,warn
Not Enough KP's Picked. Must Select 2 KP's Only.
!------------------------------------------------
*endif
!
init_entity_num
!
cmsel,s,kset1__
/replot
!
*set,grphpic_,
*set,kp1_,
*set,kp2_,
*set,kp_1st,
*set,kp_2nd,
*set,prec_,
*set,kcount_,
cmdele,kset1__
!
/gopr


w:\ansys\mac\tools\kp_path_ln.mac.html

!   TITLE:  kp_path_ln.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/19/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distance between a keypoint
!   and a line along the path of the crossing line. (The crossing path line
!   is attached to the keypoint)
!
!
!   COMMAND SYNTAX:
!
!                    (1)  (2)    (3)    (4)  (5)
!        KP_PATH_LN, kp, line, path_ln, tol, prec
!
!
!   ARGUMENTS:
!
!           (1) kp = keypoint to measure distance from line.
!
!           (2) line = line to measure distance from.
!
!           (3) path_ln = the line along whose path the distance to the point
!                         of crossing is to be measured.
!
!           (4) tol = zero tolerance value.  If the calculated distance is
!                     less than this threshold value, the distance is assumed
!                     to be 0. (Default value is 0.0001)
!
!           (5) prec = the decimal precision of 'dpath_'. This value is an
!                      integer value between 3 and 8, and is the number of
!                      decimal places of precision to output the value of
!                      'dpath_'. (Default value is 4)
!
!
!   DESCRIPTION:
!
!   This macro calculates the linear distance between a keypoint and a line
!   along a line attached to the keypoint, and crossing the specified line.
!   This distance is to the point where the 2 lines cross (intersect), but
!   do not share a keypoint at the point of intersection. Therefore, this
!   macro is valid only for lines that cross/overlap each other, but are not
!   attached; and the input lines are straight. This allows the user to calc-
!   ulate the distance of any of the 4 endpoints of the 2 crossing lines from
!   the point of crossing of the lines.
!
!   If the specified keypoint is attached to more than 1 line, then the par-
!   ticular line whose path crosses the line specified in the 2nd argument must
!   be specified in 3rd prompt.
!
!   The distance is output to the parameter:    dpath_
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

kpt_=arg1
ln_=arg2
tol_=arg4
prec_=arg5
!
*if,tol_,eq,0,then
    tol_=0.0001
*endif
!
*if,prec_,eq,0,then
    prec_=4
*endif
!
cm,kset_,kp
cm,lset_,line
!
ksel,s,kp,,kpt_
lslk,s,0
*get,numlns_,line,,count
!
*if,numlns_,gt,1,then
    pthln_=arg3
*elseif,numlns_,eq,1,then
    get_max_entity
    pthln_=lm
*endif
!
cmsel,s,kset_
cmsel,s,lset_
!
*if,pthln_,ne,0,then
    *get,kppath1_,line,pthln_,kp,1
    *get,kppath2_,line,pthln_,kp,2
    !
    *if,kppath1_,eq,kpt_,then
        endkp_=kppath2_
    *else
        endkp_=kppath1_
    *endif
    !
    *get,kpLn1_,line,ln_,kp,1
    *get,kpLn2_,line,ln_,kp,2
    !
    alpha_=anglek(kpt_,endkp_,kpLn1_)
    beta_=anglek(kpLn1_,kpLn2_,kpt_)
    gamma_=(180-((alpha_*dconv)+(beta_*dconv)))*rconv
    !
    s_=distkp(kpt_,kpLn1_)
    !
    dpath_=s_*(sin(beta_))/(sin(gamma_))
    !
    *if,abs(dpath_),lt,tol_,then
        dpath_=0
    *else
        round_num,dpath_,prec_
        dpath_=num_
    *endif
*endif
!
init_entity_num
cmsel,s,kset_
cmsel,s,lset_
!
lplot
!
*set,tol_,
*set,prec_,
*set,ln_,
*set,kpt_,
*set,kpLn1_,
*set,kpLn2_,
*set,pthln_,
*set,s_,
*set,alpha_,
*set,beta_,
*set,gamma_,
*set,kppath1_,
*set,kppath2_,
*set,num_,
*set,endkp_,
*set,numlns_,
cmdele,kset_,
cmdele,lset_,


w:\ansys\mac\tools\adia.mac.html

!
!   TITLE:  adia.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  12/23/00    D. Edwards
!---------------------------------------------------------------------------
!
! Calculate the area of a circle given its diameter
!
!     A = pi/4 * d^2
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! adia,ParResult,dia
!
!   where "dia" is the diameter of the circle.
!         "ParResult" is the parameter name the result is assigned to.
!
! Example:  adia,'foo',1.5
!
!   The parameter "foo" is a assigned the area of a 1.5 diameter circle.
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

pi=acos(-1)
%arg1%=pi*arg2**2/4


w:\ansys\mac\tools\ang_diff.mac.html

!   TITLE:  ang_diff.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  04/18/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro calculates the difference between 2 angular dimensions.
!
!   COMMAND SYNTAX:
!
!           ANG_DIFF, angle#1, angle#2
!
!
!   DESCRIPTION:
!
!   The convention used here is:
!
!           d_angle = angle#1 - angle#2
!
!   The command syntax is shown below.
!
!   The difference between the two angles may then be used to aid in
!   a loop of VROTAT functions. In this case, the angle inputs may be from
!   the storage array ANG_ARRAY.MAC. It may be used for stand-alone command
!   entries as well. The angle difference is the angle subtended FROM
!   angle#1 TO angle#2 in a CLOCKWISE direction.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

ang1_=arg1
ang2_=arg2
!
delta_=ang2_-ang1_
!
*if,delta_,lt,0,then
    d_angle=abs(delta_)
*else
    d_angle=360-delta_
*endif
!
*set,ang1_,
*set,ang2_,
*set,delta_,


w:\ansys\mac\tools\c_s_position.mac.html

!   TITLE:  c_s_position.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  06/14/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro calculates the coordinate position stack-up for
!   all of the model coordinate systems in the database assembly. It
!   returns the current c.s. stack-up, XSTACK, YSTACK, ZSTACK; and
!   the previous model stack-up, XSTACK_P, YSTACK_P, ZSTACK_P, from
!   the previous model construction session. In order to track the
!   positional stack-up of an assembly, or subassembly, the parameter
!   'FRST_MDL' must be initialized to 1. At the beginning of all assemblies,
!   FRST_MDL is initialized by default. From this point on, the stack-up will
!   be tracked, until the next time that FRST_MDL is manually initialized.
!
!
*get,prkey_,active,0,prkey
/nopr

*if,frst_mdl,ne,1,then
    xstack_p=xstack             ! previous position stack-up
    ystack_p=ystack
    zstack_p=zstack
    !
    xstack=xstack+xc_mcs        ! present position stack-up
    ystack=ystack+yc_mcs
    zstack=zstack+zc_mcs
*else
    *set,frst_mdl,


w:\ansys\mac\tools\cc.mac.html

!
!   TITLE:  cc.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  12/23/2000  D. Edwards
!---------------------------------------------------------------------------
!
! Calculate the area between two concentric circles.
!
!   A = pi/4 * (OD^2 - ID^2)
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! cc,ParResult,OD,ID
!
!   where "OD" is the inside diameter
!         "ID" is the outside diameter
!         "ParResult" is the parameter name to assign the result to.
!
! Example:  cc,'foo',2,1
!
!   "foo" is a assigned the area between concentric circles with an
!   outer diameter of 2 and an inner diameter of 1.
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

pi=acos(-1)
%arg1%=pi/4*(arg2**2 - arg3**2)


w:\ansys\mac\tools\ln_dist_ln.mac.html

!   TITLE:  ln_dist_ln.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      01/28/02      D. Edwards
!       Rev A                   02/25/02      D. Edwards
!               Changed flag "isect_kp" to "del_kp" and modified logic
!               to keep the intersection KP by default.  Added calc
!               for distance between parallel lines.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   Compute the distance minimum between two 3 dimensional lines.  If
!   lines cross, compute the coordinates of the intersection point
!   relative to the active coordinate system.
!
!   COMMAND SYNTAX:
!
!                     (1)  (2)  (3)  (4)
!         ln_dist_ln, KP1, KP2, KP3, KP4
!
!       or
!
!         ln_dist_ln, L1,  L2
!
!   ARGUMENTS:
!
!       (1) KP1 = Keypoint number for line 1,
!                 or the line number for line 1
!
!       (2) KP2 = Other keypoint number for line 1,
!                 or the line number for line 2
!
!       (3) KP3 = Keypoint number for line 2
!
!       (4) KP4 = Other keypoint number for line 2
!
!   FLAGS:
!
!       del_kp =    If this parameter has a numeric value of 1 prior to
!                   calling this macro, a keypoint will not be created
!                   at the intersection of the two lines.
!                   This parameter is unset at the end of this macro.
!                   If a KP is created, its number is assigned to "kpi_".
!
!   DESCRIPTION:
!
!   Computes the minimum (or perpendicular) distance between two lines.
!
!   The distance result is returned in the parameter "dist_".
!
!   If the distance is zero, the lines are intersecting and the location
!   of the intersection is returned in parameters "xi_", "yi_" and "zi_"
!   The coordinates will be cartesian, polar or spherical depending on
!   active coordinate system type.
!
!   If 4 arguments are supplied, they are assumed to be key points,
!   otherwise line number input is assumed.
!
!   The parameter "err_" is set according to the following error
!   table:
!
!       0 = Lines are parallel
!       1 = Lines intersect
!       2 = Lines are skew
!
!---------------------------------------------------------------------------
!
*get,count_,cmd,0,nargs     ! count_ = # of args + 1

*get,prkey_,active,0,prkey
/nopr

*if,count_,eq,5,then

    kp1_=arg1
    kp2_=arg2
    kp3_=arg3
    kp4_=arg4

*else

    l1_=arg1
    l2_=arg2

    *get,kp1_,line,l1_,kp,1
    *get,kp2_,line,l1_,kp,2
    *get,kp3_,line,l2_,kp,1
    *get,kp4_,line,l2_,kp,2

*endif

*get,csys_,active,0,csys            ! Store the current CS #

csys,0                              ! Perform calcs in cart. GCS

! Write the input file for ln_dist_ln.c
*cfopen,ln_dist_ln,out

*do,i_,1,4

*vwrite,kx(kp%i_%_),ky(kp%i_%_),kz(kp%i_%_)
(3E30.18)

*enddo

*cfclos

/gopr

/sys,ln_dist_ln

/nopr

parres,change,ln_dist_ln,in

*if,err_,eq,1,then

    ! --- LINES INTERSECT --------------------------------------------

    *get,kpi_,kp,0,num,max
    kpi_=kpi_+1

    k,kpi_,xi_,yi_,zi_

    csys,csys_

    xi_=kx(kpi_)
    yi_=ky(kpi_)
    zi_=kz(kpi_)

!---------------------------------------------------------------------
*msg,info,csys_
Active CS = %g

*msg,info,err_,dist_,xi_,yi_,zi_
ERR_ = %g,  DIST_ = %g%/&
XI_  = %g%/&
YI_  = %g%/&
ZI_  = %g

*msg,info,kpi_
KPI_ = %g
!---------------------------------------------------------------------

    *if,del_kp,eq,1,then

        kdel,kpi_
        *set,kpi_
        *set,del_kp
    *else
        init_entity_num
    *endif

*elseif,err_,eq,2,then

    ! --- SKEW LINES -------------------------------------------------

!---------------------------------------------------------------------
*msg,info,csys_
Active CS = %g

*msg,info,err_,dist_
ERR_ = %g,  DIST_ = %g
!---------------------------------------------------------------------

*else

    ! --- PARALLEL LINES ---------------------------------------------

    cskp,csn+11,0,kp1_,kp2_,kp3_

    dist_=ky(kp3_)

    csdele,csn+11

!---------------------------------------------------------------------
*msg,info,csys_
Active CS = %g

*msg,info,err_,dist_
ERR_ = %g,  DIST_ = %g
!---------------------------------------------------------------------

*endif

!
!---------------------------------------------------------------------
!

csys,csys_

*set,count_
*set,i_
*set,kp1_
*set,kp2_
*set,kp3_
*set,kp4_
*set,l1_
*set,l2_
*set,csys_


w:\ansys\mac\tools\ln_dist_ln.c.html

/*----------------------------------------------------------------------*/
/*  ln_dist_ln.c                                                        */
/*                                                                      */
/*  Compute the distance between two lines or the intersection point    */
/*  if the lines cross.                                                 */
/*                                                                      */
/*  See ln_dist_ln.mac for more details                                 */
/*                                                                      */
/*  David Edwards <edwards@dee-engineering.com>                         */
/*  Tue Jan 29 15:28:53  2002                                           */
/*                                                                      */
/*  Compile cygwin:  gcc -O3 -o ln_dist_ln ln_dist_ln.c                 */
/*  Compile UNIX:    gcc -O3 -o ln_dist_ln ln_dist_ln.c -lm             */
/*----------------------------------------------------------------------*/

// TO DO: Move fprintf lines into conditionals instead of all at end
// to keep xi_, etc, from getting assigned 1E315 type numbers.

#include <stdio.h>
#include <math.h>

// Read this file for input points (Ansys output)
#define FINPUT "ln_dist_ln.out"

// Write the results to this file (Gets input back into Ansys)
#define FOUTPUT "ln_dist_ln.in"

#define TRUE 1
#define FALSE 0
#define EPS 1.0e-9
#define ABS fabs
#define MAXLINE 95                  // Depends on *vwrite settings

typedef struct {
   double x,y,z;
} XYZ;

/*
  Written by Paul Bourke      April 1998
  http://astronomy.swin.edu.au/pbourke/geometry/lineline3d/

   Calculate the line segment PaPb that is the shortest route between
   two lines P1P2 and P3P4. Calculate also the values of mua and mub where
      Pa = P1 + mua (P2 - P1)
      Pb = P3 + mub (P4 - P3)
   Return FALSE if no solution exists, otherwise return the coordinates
   of Pa and Pb.
*/
int ln_dist_ln (
   XYZ p1,XYZ p2,XYZ p3,XYZ p4,XYZ *pa,XYZ *pb,
   double *mua, double *mub)
{
   XYZ p13,p43,p21;
   double d1343,d4321,d1321,d4343,d2121;
   double numer,denom;

   p13.x = p1.x - p3.x;
   p13.y = p1.y - p3.y;
   p13.z = p1.z - p3.z;
   p43.x = p4.x - p3.x;
   p43.y = p4.y - p3.y;
   p43.z = p4.z - p3.z;
   if (fabs(p43.x)  < EPS && fabs(p43.y)  < EPS && fabs(p43.z)  < EPS)
      return(FALSE);
   p21.x = p2.x - p1.x;
   p21.y = p2.y - p1.y;
   p21.z = p2.z - p1.z;
   if (ABS(p21.x)  < EPS && ABS(p21.y)  < EPS && ABS(p21.z)  < EPS)
      return(FALSE);

   d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z;
   d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z;
   d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z;
   d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z;
   d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z;

   denom = d2121 * d4343 - d4321 * d4321;
   if (ABS(denom) < EPS)
      return(FALSE);
   numer = d1343 * d4321 - d1321 * d4343;

   *mua = numer / denom;
   *mub = (d1343 + d4321 * (*mua)) / d4343;

   pa->x = p1.x + *mua * p21.x;
   pa->y = p1.y + *mua * p21.y;
   pa->z = p1.z + *mua * p21.z;
   pb->x = p3.x + *mub * p43.x;
   pb->y = p3.y + *mub * p43.y;
   pb->z = p3.z + *mub * p43.z;

   return(TRUE);
}

double sq(double x)
{
    return x*x;
}

int main(int argc, char *argv[])
{
    int i, okay;
    double err, dist=0.0, mua, mub;
    XYZ P[4], PA, PB;

    FILE *fin, *fout;
    char str[MAXLINE];

    if ((fin=fopen(FINPUT,"r")) == NULL) {
        printf("\n ln_dist_ln.c:  Error opening file: %s\n", FINPUT);
        return 1;
    }

    for (i=0; i < 4; i++) {

        if (NULL == (fgets(str, MAXLINE, fin))) {
            printf("\n ln_dist_ln.c:  Bad input file: %s\n", FINPUT);
            fclose(fin);
            return 1;
        }

        sscanf(str, " %le %le %le", &P[i].x, &P[i].y, &P[i].z);

    }

    fclose(fin);

    okay = ln_dist_ln(P[0],P[1],P[2],P[3],&PA,&PB,&mua,&mub);

    if (okay) {

        // Compute the distance between lines
        dist = sqrt(sq(PA.x - PB.x) + sq(PA.y - PB.y) + sq(PA.z - PB.z));

        if (dist <= EPS) {

            err=1.0;            // Lines intersect
            printf("Lines intersect at (%.4f, %.4f, %.4f) in global CS\n",
                    PA.x,PA.y,PA.z);
            printf("Results written to parameters XI_, YI_, ZI_ and ERR_\n\n");

        } else {

            err=2.0;            // Lines are skew
            printf("Minimum distance between skew lines %.4f\n",dist);
            printf("Results written to parameters DIST_ and ERR_\n\n");
        }

    } else {

        err=0.0;                // Lines are parallel
        printf("Lines are parallel\n");
        printf("Results written to parameter ERR_\n\n");
    }

    //
    // Write the results to a file for Ansys to pick up
    //
    if ((fout=fopen(FOUTPUT,"w")) == NULL) {
        printf("\n ln_dist_ln.c:  Error opening file: %s\n", FINPUT);
        return 1;
    }

    fprintf(fout, "/nopr\n");
    fprintf(fout, "*set,ERR_\t, %30.18E\n", err);
    fprintf(fout, "*set,DIST_\t, %30.18E\n", dist);
    fprintf(fout, "*set,XI_\t, %30.18E\n", PA.x);
    fprintf(fout, "*set,YI_\t, %30.18E\n", PA.y);
    fprintf(fout, "*set,ZI_\t, %30.18E\n", PA.z);
    fprintf(fout, "/go\n");

    close(fout);

}


w:\ansys\mac\tools\ln_dist_pt_calc.mac.html

!   TITLE:  ln_dist_pt_calc.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   01/24/2002      J. Rinaldi
!
!           Implemented graphical picking option.
!---------------------------------------------------------------------------
!
!   TOOLBAR MACRO
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distance between a straight
!   line and a keypoint.
!
!
!   ARGUMENTS:
!
!           1 prompt:   Line & Keypoint numbers to measure distance
!                       between:
!
!                                   LN# and KP#
!
!                       Decimal precision of output
!
!                                   PREC
!
!           NOTE: If the input boxes for the line & keypoint numbers are left
!                 to their default values of 0, then graphical picking is enabled.
!                 In this case, the user must select exactly 1 line and 1 keypoint
!                 only.
!
!
!   DESCRIPTION:
!
!   This macro calculates the perpendicular (minimum) distance between a line
!   and a keypoint. This distance is only valid if the input line is straight.
!
!   The output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
cm,kset1__,kp
cm,lset1__,line
!
*get,acs1_,active,,csys
!
grphpic_=0
!
multipro,'start',3
    *cset,1,3,ln_1st,'Enter Line #',0
    *cset,4,6,pt_2nd,'Enter KP #',0
    *cset,7,9,prec_,'Enter Decimal Precision',4
    *cset,61,62,'Calculates the normal dist','ance between a line and'
    *cset,63,64,'a keypoint. Enter the line',' and KP numbers.'
multipro,'end'
!
*if,ln_1st,eq,0,then
    *if,pt_2nd,eq,0,then
        /ui,lsel
        /ui,ksel
        get_max_entity
        !
        *get,lcount_,line,,count
        *get,kcount_,kp,,count
        !
        ln_1st=lm
        pt_2nd=km
        !
        grphpic_=1
    *endif
*endif
!
*if,grphpic_,eq,0,then
    ln1_=lsel(ln_1st)
    kp1_=ksel(pt_2nd)
    !
    *if,ln1_,eq,1,then
        *if,kp1_,eq,1,then
            lcount_=1
            kcount_=1
        *else
            lcount_=1
            kcount_=0
        *endif
    *else
        *if,kp1_,eq,1,then
            lcount_=0
            kcount_=1
        *else
            lcount_=0
            kcount_=0
        *endif
    *endif
*endif
!
*if,lcount_,eq,1,then
    *if,kcount_,eq,1,then
        *if,prec_,le,0,then
            prec_=4
        *endif
        !
        tol_=10**(-prec_-1)
        !
        *get,kp11_,line,ln_1st,kp,1
        *get,kp12_,line,ln_1st,kp,2
        !
        *if,grphpic_,eq,1,then
            ksel,a,kp,,kp11_
            ksel,a,kp,,kp12_
        *endif
        !
        cskp,csn+5,0,kp11_,kp12_,pt_2nd
        !
        dy__=abs(ky(pt_2nd))
        !
        *if,abs(dy__),lt,tol_,then
            dy__=0
        *else
            *if,abs(dy__),ge,(10*tol_),then
                round_num,dy__,prec_
            *else
                round_num,dy__,prec_+1
            *endif
            !
            dy__=num_
        *endif
        !
!--------------------------------------
*msg,ui,%ln_1st%,%pt_2nd%,%dy__%
Distance Between ( L %i , KP %i ) = %g
!--------------------------------------
        !
        csdele,csn+5
        csys,acs1_
        !
        *set,dy__,
        *set,kp11_,
        *set,kp12_,
        *set,acs1_,
        *set,tol_,
    *endif
*endif
!
*if,lcount_,gt,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Lines and KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Lines, Insufficient KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,eq,1,then
!---------------------------------------------------------------
*msg,warn
Too Many Lines Picked. Must Select 1 Only.
!---------------------------------------------------------------
    *endif
*elseif,lcount_,lt,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Lines and Too Many KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Lines and KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,eq,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient Lines Picked. Must Select 1 Only.
!---------------------------------------------------------------
    *endif
*elseif,lcount_,eq,1,then
    *if,kcount_,gt,1,then
!---------------------------------------------------------------
*msg,warn
Too Many KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *elseif,kcount_,lt,1,then
!---------------------------------------------------------------
*msg,warn
Insufficient KP's Picked. Must Select 1 each.
!---------------------------------------------------------------
    *endif
*endif
!
init_entity_num
!
cmsel,s,kset1__
cmsel,s,lset1__
/replot
!
*set,ln_1st,
*set,pt_2nd,
*set,prec_,
*set,ln1_,
*set,kp1_,
*set,grphpic_,
*set,lcount_,
*set,kcount_,
cmdele,kset1__
cmdele,lset1__
!
/gopr


w:\ansys\mac\tools\mark_cg.mac.html

!   TITLE:  mark_cg.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    09/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a keypoint at, and marks the position of, the center
!   of gravity (CG) of a volume or set of volumes and outputs the coordinates
!   and total volume to a dialogue box, and a set of parameters.
!
!
!   COMMAND SYNTAX:
!
!                      (1)   (2)   (3)
!           MARK_CG, c_or_d, rcs, prec
!
!
!   ARGUMENTS:
!
!       (1) c_or_d = create or delete CG marker/keypoint parameter:
!
!               0 (or blank) = create CG marker/keypoint
!
!               1 = delete CG marker/keypoint
!
!       (2) rcs = relative coordinate system
!
!       (3) prec = decimal precision of CG coordinates
!
!
!   DESCRIPTION:
!
!   The selected volume(s) CG is visually marked with a set of axes. A keypoint
!   is placed at the CG location for information/measurement query. The key-
!   point number parameter is called 'cgkp_'.
!
!       OUTPUT @ DIALOGUE BOX:
!
!           C.S.= ... --- X_cg = ... , Y_cg = ... , Z_cg = ... --- V = ...
!
!       OUTPUT PARAMETERS:
!
!               XCG%RCS% = X (or R) coordinate of CG
!               YCG%RCS% = Y (or THETA) coordinate of CG
!               ZCG%RCS% = Z (or PHI) coordinate of CG
!               VCG = total volume of selected (CG) volumes
!
!           where %RCS% is simply the integer number of the relative C.S.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

cord_=arg1
rcs_=arg2
prec_=arg3
!
cm,vset1_,volu
!
init_entity_num
cmsel,s,vset1_
!
*get,acs1_,active,,csys
!
*if,cord_,eq,0,then
    *get,cgkptyp_,parm,cgkp_,type
    !
    *if,cgkptyp_,ne,-1,then
        ksel,s,kp,,cgkp_
        lslk,s,0
        ldele,all,,,1
        kdele,cgkp_
        !
        get_max_entity
        !
        *set,cgkp_,
    *endif
    !
    *if,prec_,le,0,then
        prec_=4
    *endif
    !
    tol_=10**(-prec_-1)
    !
    csys,0
    vsum
    !
    *get,v_,volu,,volu
    !
    *get,vcgx_,volu,,cent,x
    *get,vcgy_,volu,,cent,y
    *get,vcgz_,volu,,cent,z
    !
    k,,vcgx_,vcgy_,vcgz_
    !
    get_max_entity
    !
    cgkp_=km
    !
    csys,rcs_
    !
    *get,racs_,active,,csys
    *get,racstyp_,cdsy,racs_,attr,kcs
    !
    *if,racstyp_,ne,0,then
        clocal,csn+5,0,0,0,0,0,0,0
    *endif
    !
    k,,kx(cgkp_)+1,ky(cgkp_),kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_),kz(cgkp_)-1
    k,,kx(cgkp_)-1,ky(cgkp_),kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_),kz(cgkp_)+1
    k,,kx(cgkp_),ky(cgkp_)+1,kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_)-1,kz(cgkp_)
    !
    get_max_entity
    !
    *do,yz_,1,6,1
        lstr,cgkp_,km-(6-yz_)
    *enddo
    !
    get_max_entity
    !
    csys,rcs_
    !
    xcg%rcs_%=kx(cgkp_)
    ycg%rcs_%=ky(cgkp_)
    zcg%rcs_%=kz(cgkp_)
    !
    x_=kx(cgkp_)
    !
    *if,abs(x_),lt,tol_,then
        x_=0
    *else
        *if,abs(x_),ge,(10*tol_),then
            round_num,x_,prec_
        *else
            round_num,x_,prec_+1
        *endif
        !
        x_=num_
    *endif
    !
    y_=ky(cgkp_)
    !
    *if,abs(y_),lt,tol_,then
        y_=0
    *else
        *if,abs(y_),ge,(10*tol_),then
            round_num,y_,prec_
        *else
            round_num,y_,prec_+1
        *endif
        !
        y_=num_
    *endif
    !
    z_=kz(cgkp_)
    !
    *if,abs(z_),lt,tol_,then
        z_=0
    *else
        *if,abs(z_),ge,(10*tol_),then
            round_num,z_,prec_
        *else
            round_num,z_,prec_+1
        *endif
        !
        z_=num_
    *endif
    !
    *if,v_,lt,tol_,then
        v_=0
    *else
        *if,v_,ge,(10*tol_),then
            round_num,v_,prec_
        *else
            round_num,v_,prec_+1
        *endif
        !
        v_=num_
        vcg=num_
    *endif
    !
    *if,racstyp_,eq,0,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- X_cg = %g , Y_cg = %g , Z_cg = %g --- V = %g
!--------------------------------------------------------------
    *else
        *if,racstyp_,eq,1,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- R_cg = %g , THETA_cg = %g , Z_cg = %g --- V = %g
!--------------------------------------------------------------
        *elseif,racstyp_,eq,2,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- R_cg = %g , THETA_cg = %g , PHI_cg = %g --- V = %g
!--------------------------------------------------------------
        *endif
    *endif
    !
    *if,racstyp_,ne,0,then
        csdele,csn+5
    *endif
    !
    *set,x_,
    *set,y_,
    *set,z_,
    *set,tol_,
    *set,num_,
    *set,racs_,
    *set,racstyp_,
    *set,yz_,
    *set,vcgx_,
    *set,vcgy_,
    *set,vcgz_,
    *set,cgkptyp_,
    *set,v_,
*elseif,cord_,eq,1,then
    ksel,s,kp,,cgkp_
    lslk,s,0
    ldele,all,,,1
    kdele,cgkp_
    !
    *set,cgkp_,
*endif
!
csys,acs1_
init_entity_num
isolate_lines
cmsel,s,vset1_
aslv,s
lsla,a
!
lplot
!
*set,cord_,
*set,rcs_,
*set,acs1_,
*set,prec_,
cmdele,vset1_


w:\ansys\mac\tools\max_kp_dist.mac.html

!   TITLE:  max_kp_dist.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      05/25/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro determines the keypoint with the maximum distance from a
!   selected coordinate system.
!
!   COMMAND SYNTAX:
!
!                     (1)     (2)
!        MAX_KP_DIST, acs, comp_dir
!
!   ARGUMENTS:
!
!           acs = the active C.S. This coordinate system need not be cartesian.
!                 However, this algorithm will calculate the distances to key-
!                 points along the axis directions of this coordinate system.
!
!           comp_dir = the component direction to measure the distance.
!                      Valid arguments are:
!
!               Positive axis directions:
!
!                   '+x' = component distance in +x direction
!
!                   '+y' = component distance in +y direction
!
!                   '+z' = component distance in +z direction
!
!               Negative axis directions:
!
!                   '-x' = component distance in -x direction
!
!                   '-y' = component distance in -y direction
!
!                   '-z' = component distance in -z direction
!
!               Absolute magnitude in axis directions:
!
!                   'x' = component distance in x (+ or -) direction
!
!                   'y' = component distance in y (+ or -) direction
!
!                   'z' = component distance in z (+ or -) direction
!
!               Absolute magnitude (all directions):
!
!                   'r' (or blank) = maximum distance
!
!
!   DESCRIPTION:
!
!   This macro determines the maximum distance of any model entity from a
!   user specified coordinate system. If the model coordinate system is
!   specified, then the maximum distance of the model's entities is deter-
!   mined from it. The pertinent output from this macro are:
!
!       1.) totkpd_ = the array containing all selected KP's of a model
!                     and their absolute distance. This array is output
!                     when COMP_DIR is blank or 'r'.
!
!                                   --- OR ---
!
!           kpd_ =  the array containing the KP's of a model and their distance
!                   as measured in the user defined coordinate direction.  This
!                   array is output when COMP_DIR is a specified coordinate
!                   direction ( i.e., +x, +y, +z, -x, -y, -z, x, y or z ).
!
!           These arrays have dimension Nkp x 2, where Nkp is the number of KP
!           entities, and 2 is the number of columns. The 1st column is the KP
!           numbers, and the 2nd column is the distance of that KP in its
!           respective user defined coordinate direction.
!
!       2.) max_dist = maximum value of distances found in column 2 of arrays
!
!       3.) kp_maxd = the KP number at the maximum distance
!
!       4.) max_indx = the row index containing 'kp_maxd' and 'max_dist'
!                      within the arrays.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
acs_=arg1
compdir_=arg2
!
cm,kpset_,kp                        ! store KP's in component group
!
!
!----------------------- Remove Existing Arrays ---------------------
!
!
*get,arr1typ_,parm,totkpd_,type
*get,arr2typ_,parm,kpd_,type
!
*if,arr1typ_,eq,1,then
    *set,totkpd_(1),
*endif
!
*if,arr2typ_,eq,1,then
    *set,kpd_(1),
*endif
!
!
!--------------------- Configure Input Parameters -------------------
!
!
*get,comptyp_,parm,compdir_,type
!
*if,comptyp_,ne,3,then
    compdir_='r'
*endif
!
!
!-------------------- Configure Coordinate System -------------------
!
!
*get,actcs_,active,,csys
!
csys,acs_                       ! initiate relative coordinate system
!
*get,acstyp_,cdsy,acs_,attr,kcs
!
*if,acstyp_,ne,0,then
    create_cs,0,,0,0,0,0,0,0,0
*endif
!
!
!------------------ Create KP Array of Total KP Set -----------------
!
!
entity_array,'k','totkpd_','array',1,,2,1   ! create KP/distance array
kpcnt_=ecount                               ! of all KP's
!
*do,ijk_,1,kpcnt_,1                     ! store KP distances in array
    kx_=kx(totkpd_(ijk_,1))
    ky_=ky(totkpd_(ijk_,1))
    kz_=kz(totkpd_(ijk_,1))
    !
    kdmax_=sqrt((kx_**2)+(ky_**2)+(kz_**2))
    !
    totkpd_(ijk_,2)=kdmax_
*enddo
!
max_value,'totkpd_',kpcnt_,2,1,1,1,2,1
max_dist=max_val
kp_maxd=totkpd_(max_indx,1)             ! KP number @ maximum distance
!
!
!---------------- Create KP Array for Specific Cases ----------------
!
!
*if,compdir_,eq,'+x',then
    cmsel,s,kpset_
    ksel,r,loc,x,0,1.1*max_dist
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1  ! create KP/distance array
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=kx(kpd_(ijk_,1))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'+y',then
    cmsel,s,kpset_
    ksel,r,loc,y,0,1.1*max_dist
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=ky(kpd_(ijk_,1))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'+z',then
    cmsel,s,kpset_
    ksel,r,loc,z,0,1.1*max_dist
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=kz(kpd_(ijk_,1))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'-x',then
    cmsel,s,kpset_
    ksel,r,loc,x,-1.1*max_dist,0
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(kx(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'-y',then
    cmsel,s,kpset_
    ksel,r,loc,y,-1.1*max_dist,0
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(ky(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'-z',then
    cmsel,s,kpset_
    ksel,r,loc,z,-1.1*max_dist,0
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(kz(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'x',then
    cmsel,s,kpset_
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(kx(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'y',then
    cmsel,s,kpset_
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(ky(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*elseif,compdir_,eq,'z',then
    cmsel,s,kpset_
    *get,kpcnt_,kp,,count
    !
    *if,kpcnt_,ge,1,then
        entity_array,'k','kpd_','array',1,,2,1
        kpcnt_=ecount
        !
        *do,ijk_,1,kpcnt_,1
            kdmax_=abs(kz(kpd_(ijk_,1)))
            kpd_(ijk_,2)=kdmax_
        *enddo
    *endif
*endif
!
*if,compdir_,ne,'r',then
    *if,kpcnt_,ge,1,then
        *set,totkpd_(1),
        !
        max_value,'kpd_',kpcnt_,2,1,1,1,2,1
        max_dist=max_val
        kp_maxd=kpd_(max_indx,1)
    *else
        max_dist=0
        kp_maxd=0
    *endif
*endif
!
!
!--------------------------------------------------------------------
!
!
cmsel,s,kpset_      ! restore the original selected set
csys,actcs_         ! restore original C.S.
!
*set,acs_,
*set,actcs_,
*set,compdir_,
*set,ecount,
*set,max_val,
*set,arr1typ_,
*set,arr2typ_,
*set,kdmax_,
*set,kpcnt_,
*set,kx_,
*set,ky_,
*set,kz_,
cmdele,kpset_


w:\ansys\mac\tools\nd_dist_calcs.mac.html

!   TITLE:  nd_dist_calcs.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    01/23/2002      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR MACRO
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distances between 2 nodes.
!
!
!   ARGUMENTS:
!
!           1st prompt:     acs = active coordinate system to measure axial
!                                 distance in.
!
!                           Node numbers to measure distance between:
!
!                                   ND1 and ND2
!
!           NOTE: If the input boxes for node numbers in the dialogue box are
!                 left to their default values of 0, then graphical picking is
!                 enabled. In this case, the user must select exactly 2 nodes
!                 only.
!
!   DESCRIPTION:
!
!   This macro calculates the linear (cartesian) distances between 2 nodes.
!   These distances are measured in all 3 axial directions: Dx, Dy and Dz, and the
!   absolute linear distance between them, Dabs. The distances are calculated rel-
!   ative to a desired user-specified coordinate system.
!
!   If the specified coordinate system is not cartesian, then the distance calcu-
!   lations are measured along the oriented axial directions of that coordinate
!   system as if it were cartesian. Therefore, a cartesian coordinate system need
!   not be created or specified as long as the axial directions of the specified
!   coordinate system are oriented as desired.
!
!   If the desired coordinate system is the current active coordinate system, then
!   simply pressing the ENTER key will suffice, since the default coordinate
!   system value activated by the user prompt is the current active coordinate
!   system. If the specified coordinate system is different from the current active
!   coordinate system, the calculations will be performed and the current active
!   coordinate system will be restored.
!
!   All output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
/nopr
!
cm,ndset1__,node
!
*get,acs1_,active,,csys
!
grphpic_=0
!
multipro,'start',4
    *cset,1,3,csnum_,'COORDINATE SYSTEM #',acs1_
    *cset,4,6,prec_,'Decimal Precision of Output',4
    *cset,7,9,nd_1st,'Enter 1st Node',0
    *cset,10,12,nd_2nd,'Enter 2nd Node',0
    *cset,61,62,'Calculates the X,Y,Z and abs','olute (linear) distance'
    *cset,63,64,'between 2 nodes. Enter',' the node numbers.'
multipro,'end'
!
*if,nd_1st,eq,0,then
    *if,nd_2nd,eq,0,then
        /ui,nsel
        get_min_entity
        get_max_entity
        !
        *get,ncount_,node,,count
        !
        nd_1st=n_min
        nd_2nd=nm
        !
        grphpic_=1
    *endif
*endif
!
*if,grphpic_,eq,0,then
    nd1_=nsel(nd_1st)
    nd2_=nsel(nd_2nd)
    !
    *if,nd1_,eq,1,then
        *if,nd2_,eq,1,then
            ncount_=2
        *else
            ncount_=1
        *endif
    *else
        *if,nd2_,eq,1,then
            ncount_=1
        *else
            ncount_=0
        *endif
    *endif
*endif
!
*if,ncount_,eq,2,then
    csys,csnum_
    !
    *get,csnumtyp,cdsy,csnum_,attr,kcs
    !
    *if,csnumtyp,ne,0,then
        clocal,csn+1,0,0,0,0,0,0,0
        csnum_=csn+1
    *endif
    !
    *if,nd_1st,ne,0,then
        *if,nd_2nd,ne,0,then
            *if,prec_,le,0,then
                prec_=4
            *endif
            !
            tol_=10**(-prec_-1)
            !
            dx__=abs(nx(nd_1st)-nx(nd_2nd))
            !
            *if,abs(dx__),lt,tol_,then
                dx__=0
            *else
                *if,abs(dx__),ge,(10*tol_),then
                    round_num,dx__,prec_
                *else
                    round_num,dx__,prec_+1
                *endif
                !
                dx__=num_
            *endif
            !
            dy__=abs(ny(nd_1st)-ny(nd_2nd))
            !
            *if,abs(dy__),lt,tol_,then
                dy__=0
            *else
                *if,abs(dy__),ge,(10*tol_),then
                    round_num,dy__,prec_
                *else
                    round_num,dy__,prec_+1
                *endif
                !
                dy__=num_
            *endif
            !
            dz__=abs(nz(nd_1st)-nz(nd_2nd))
            !
            *if,abs(dz__),lt,tol_,then
                dz__=0
            *else
                *if,abs(dz__),ge,(10*tol_),then
                    round_num,dz__,prec_
                *else
                    round_num,dz__,prec_+1
                *endif
                !
                dz__=num_
            *endif
            !
            dabs__=distnd(nd_1st,nd_2nd)
            !
            *if,abs(dabs__),lt,tol_,then
                dabs__=0
            *else
                *if,abs(dabs__),ge,(10*tol_),then
                    round_num,dabs__,prec_
                *else
                    round_num,dabs__,prec_+1
                *endif
                !
                dabs__=num_
            *endif
            !
!--------------------------------------------------------------------------------------
*msg,ui,%nd_1st%,%nd_2nd%,%dx__%,%dy__%,%dz__%,%dabs__%
Distance Between Node #'s ( %i , %i ) : %/&
%/&
Dx = %g %/&
Dy = %g %/&
Dz = %g %/&
%/&
Dabs = %g
!--------------------------------------------------------------------------------------
            !
            *if,csnumtyp,ne,0,then
                csdele,csnum_
            *endif
            !
            csys,acs1_
            !
            *set,acs1_,
            *set,csnum_,
            *set,csnumtyp,
            *set,dx__,
            *set,dy__,
            *set,dz__,
            *set,dabs__,
            *set,tol_,
        *endif
    *endif
*elseif,ncount_,gt,2,then
!------------------------------------------------
*msg,warn
Too Many Nodes Picked. Must Select 2 Nodes Only.
!------------------------------------------------
*elseif,ncount_,lt,2,then
!------------------------------------------------
*msg,warn
Not Enough Nodes Picked. Must Select 2 Nodes Only.
!------------------------------------------------
*endif
!
cmsel,s,ndset1__
/replot
!
*set,grphpic_,
*set,nd1_,
*set,nd2_,
*set,nd_1st,
*set,nd_2nd,
*set,prec_,
*set,ncount_,
cmdele,kset1__
!
/gopr


w:\ansys\mac\tools\parm_calcs.mac.html

!   TITLE:  parm_calcs.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/31/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A    08/21/2001     J. Rinaldi
!
!           Change output format for clarity.
!---------------------------------------------------------------------------
!
!
!   This sub-macro calculates the difference between an entity number (key-
!   point, line, area, volume, node and element) and the current maximum value
!   retrieved and stored  in the database by INIT_ENTITY_NUM or GET_MAX_ENTITY
!   (km, lm, am, vm, nm and em). The difference is output to a dialogue box.
!   The maximum number of entities that can be input is 4.  If less than 4
!   entities are input, the remaining user prompts are assumed 0 by default,
!   and just hitting the enter key will suffice.
!
!   The purpose of this calculation(s) is to rapidly find the entity offset
!   numbers when writing macro code.
!
!
!       EXAMPLE:    If km=55, and the keypoint entity number in question
!                   is kp=26, then that entity may be specified in a macro
!                   by 'km-29'. The output from the dialogue box will
!                   appear as follows:
!
!                               KP 26 : km+( -29 )
!
!                   Therefore, your parameter call-out in the macro is 'km-29'.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! PARM_CALCS, entity, prm1, prm2, prm3
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
multipro,'start',5
    *cset,1,3,entity,'Type of Solid Model Entity',1
    *cset,4,6,prm_1,'Enter Solid Model Entity #1',0
    *cset,7,9,prm_2,'Enter Solid Model Entity #2',0
    *cset,10,12,prm_3,'Enter Solid Model Entity #3',0
    *cset,13,15,prm_4,'Enter Solid Model Entity #4',0
    *cset,61,62,'Calculate the entity offset par','ameter values. Enter entity type'
    *cset,63,64,'(k=1, l=2, a=3, v=4, n=5 or e=6',') and numbers.'
multipro,'end'
!
*if,entity,eq,1,then
    err_=0
    entity='k'
*elseif,entity,eq,2,then
    err_=0
    entity='l'
*elseif,entity,eq,3,then
    err_=0
    entity='a'
*elseif,entity,eq,4,then
    err_=0
    entity='v'
*elseif,entity,eq,5,then
    err_=0
    entity='n'
*elseif,entity,eq,6,then
    err_=0
    entity='e'
*else
    err_=1
!---------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%
Invalid entry for 1st argument. Must be parameter type values 1 thru 6. READ MENU!
!---------------------------------------------------------------------------------
    *set,entity,
    *set,prm_1,
    *set,prm_2,
    *set,prm_3,
    *set,prm_4,
*endif
!
*if,err_,eq,0,then
    *do,i,1,4,1
        diff%i%=prm_%i%-%entity%m
    *enddo
    !
    *if,entity,eq,'k',then
!----------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
KP %i : km+( %i ) ----- KP %i : km+( %i ) ----- KP %i : km+( %i ) ----- KP %i : km+( %i )
!----------------------------------------------------------------------------------------
    *elseif,entity,eq,'l',then
!------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
L %i : lm+( %i ) ----- L %i : lm+( %i ) ----- L %i : lm+( %i ) ----- L %i : lm+( %i )
!------------------------------------------------------------------------------------
    *elseif,entity,eq,'a',then
!------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
A %i : am+( %i ) ----- A %i : am+( %i ) ----- A %i : am+( %i ) ----- A %i : am+( %i )
!------------------------------------------------------------------------------------
    *elseif,entity,eq,'v',then
!------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
V %i : vm+( %i ) ----- V %i : vm+( %i ) ----- V %i : vm+( %i ) ----- V %i : vm+( %i )
!------------------------------------------------------------------------------------
    *elseif,entity,eq,'n',then
!------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
N %i : nm+( %i ) ----- N %i : nm+( %i ) ----- N %i : nm+( %i ) ----- N %i : nm+( %i )
!------------------------------------------------------------------------------------
    *elseif,entity,eq,'e',then
!------------------------------------------------------------------------------------
*msg,ui,%prm_1%,%diff1%,%prm_2%,%diff2%,%prm_3%,%diff3%,%prm_4%,%diff4%
E %i : em+( %i ) ----- E %i : em+( %i ) ----- E %i : em+( %i ) ----- E %i : em+( %i )
!------------------------------------------------------------------------------------
    *endif
*endif
!
*set,entity,
*set,prm_1,
*set,prm_2,
*set,prm_3,
*set,prm_4,
*set,err_,
*set,diff1,
*set,diff2,
*set,diff3,
*set,diff4,


w:\ansys\mac\tools\entity_max.mac.html

!   TITLE:  entity_max.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -       08/31/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro displays the current solid model entity maximums in a
!   dialogue box.
!
!---------------------------------------------------------------------------
*get,prkey_,active,0,prkey
/nopr

!
*ask,decision,Solid Model(0) Node/Element(1),0
!
*if,decision,eq,0,then
    *msg,ui,'KM',%km%,'LM',%lm%,'AM',%am%,'VM',%vm%
    %c = %i&
    %c = %i&
    %c = %i&
    %c = %i
*endif
!
*if,decision,eq,1,then
    *msg,ui,'NM',%nm%,'EM',%em%
    %c = %i&
    %c = %i
*endif
!
*set,decision,


w:\ansys\mac\tools\get_max_entity.mac.html

!   TITLE:  get_max_entity.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  03/30/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to store the maximum values of the solid and FE
!   model entities. It is used ONLY for retrieving the maximum values of a
!   SELECTED set of entities. It stores the maximum numerical value for
!   all solid model entity types (i.e., keypoints, lines, areas and volumes)
!   for a selected set of entities so that that only those selected
!   entities may be operated on.
!
!
*get,prkey_,active,0,prkey
/nopr

*get,km,kp,,num,max         ! get maximum keypoint number
!
*get,lm,line,,num,max       ! get maximum line number
!
*get,am,area,,num,max       ! get maximum area number
!
*get,vm,volu,,num,max       ! get maximum volume number
!
*get,em,elem,,num,max       ! get maximum element number
!
*get,nm,node,,num,max       ! get maximum node number


w:\ansys\mac\tools\get_min_entity.mac.html

!   TITLE:  get_min_entity.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  08/17/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to store the minimum values of the solid and FE
!   model entities. It is used ONLY for retrieving the minimum values of a
!   SELECTED set of entities. It stores the minimum numerical value for
!   all solid model entity types (i.e., keypoints, lines, areas and volumes)
!   for a selected set of entities so that that only those selected
!   entities may be operated on.
!
!
*get,prkey_,active,0,prkey
/nopr

*get,k_min,kp,,num,min          ! get minimum keypoint number
!
*get,l_min,line,,num,min        ! get minimum line number
!
*get,a_min,area,,num,min        ! get minimum area number
!
*get,v_min,volu,,num,min        ! get minimum volume number
!
*get,e_min,elem,,num,min        ! get minimum element number
!
*get,n_min,node,,num,min        ! get minimum node number


w:\ansys\mac\tools\max_e_dim_array.mac.html

!   TITLE:  max_e_dim_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    05/18/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the maximum value, within a selected
!   set, of the dimension of a specified entity:
!
!           ENTITY      DIMENSION
!          --------    -----------
!
!           line         length
!           area         area
!           volume       volume
!
!   These entity numbers and their dimension (characteristic) are stored in
!   arrays of the user specified names, 'anam' and 'anam'c (c is for character-
!   istic), respectively. (e.g., if anam='lnset', then the arrays created are
!   'lnset' and 'lnsetc')
!
!   Input data necessary to run this macro:
!
!       A selected set of specified entities
!
!       entity = 'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!
!       anam = character name for array (must be 7 characters or less)
!
!       typ = array type
!
!           'array' = normal (default) array
!           'table' = table array
!
!   The output of this macro are:
!
!       1.) ecount = the number of entities in the array
!
!       2.) max_leng
!           max_area
!           max_vol  = the maximum value of the specified
!                      entity characteristic (i.e., length,
!                      area or volume, respectively)
!
!       3.) max_lnum
!           max_anum
!           max_vnum = the entity number that has the maximum
!                      dimension
!
!       4.) max_indx = the index in the array of the maximum
!                      dimension
!
!       5.) The 2 arrays with the name as specified in 'anam'
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MAX_E_DIM_ARRAY, entity, anam, typ
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

entity=arg1
anam=arg2
typ=arg3
!
*if,entity,eq,'l',then        ! assignment of entity variable, 'ev'
    ev='line'
*elseif,entity,eq,'a',then
    ev='area'
    asum
*elseif,entity,eq,'v',then
    ev='volu'
    vsum
*else
    ev='z'                    ! If entity is not an 'l','a' or 'v',
*endif                        ! then assign ev to a dummy variable 'z'.
!
*if,ev,ne,'z',then            ! If ev is assigned 'z', then abort
    !
    *get,emax,ev,,num,max     ! retrieve MIN and MAX entity numbers
    *get,emin,ev,,num,min
    !
    *get,ecount,ev,,count     ! number of specified entities in the
    !                         ! selected entity set
    !
    *dim,%anam%,typ,ecount    ! Initialize entity array
    !
    !------------------- Store Entities in an Array -----------------
    !
    *do,ii,1,ecount,1
        *if,ii,eq,1,then
            %anam%(ii,1)=emin
        *else
            jj=ii-1
            *get,xx,ev,%anam%(jj,1),nxth
            %anam%(ii,1)=xx
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    *dim,%anam%c,typ,ecount   ! Initialize entity characteristic array
    !
    !
    !------------ Store Entity Characteristics in Array -------------
    !
    *do,ii,1,ecount,1
        !
        *if,entity,eq,'l',then
            *get,%anam%c(ii,1),line,%anam%(ii,1),leng
        *elseif,entity,eq,'a',then
            *get,%anam%c(ii,1),area,%anam%(ii,1),area
        *elseif,entity,eq,'v',then
            *get,%anam%c(ii,1),volu,%anam%(ii,1),volu
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    !
    !------------ Store Maximum Entity & Characteristic -------------
    !
    *do,ii,1,ecount,1
        !
        *if,ii,eq,1,then
            xx=%anam%c(ii,1)
            yy=%anam%(ii,1)
        *else
            *if,xx,gt,%anam%c(ii,1),then
                xx=xx
                yy=yy
            *else
                xx=%anam%c(ii,1)
                yy=%anam%(ii,1)
            *endif
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    !
    !-------- Store Index of Maximum Entity & Characteristic --------
    !
    *do,ii,1,ecount,1
        *if,%anam%c(ii,1),eq,xx,then
            max_indx=ii
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    *if,entity,eq,'l',then
        max_leng=xx
        max_lnum=yy
    *elseif,entity,eq,'a',then
        max_area=xx
        max_anum=yy
    *elseif,entity,eq,'v',then
        max_vol=xx
        max_vnum=yy
    *endif
*endif
!
*set,xx,
*set,yy,
*set,ev,
*set,entity,
*set,emax,
*set,emin,
*set,anam,
*set,typ,


w:\ansys\mac\tools\max_enty_dim.mac.html

!   TITLE:  max_enty_dim.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   04/19/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the maximum value, within a selected
!   set, of the dimension of a specified entity:
!
!           ENTITY      DIMENSION
!          --------    -----------
!           line         length
!           area         area
!           volume       volume
!
!   Input data necessary to run this macro:
!
!       A selected set of specified entities
!
!       entity = 'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MAX_ENTY_DIM, entity
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
entity=arg1
!
*if,entity,eq,'l',then          ! assignment of entity variable, 'ev'
    ev='line'
*elseif,entity,eq,'a',then
    ev='area'
    asum
*elseif,entity,eq,'v',then
    ev='volu'
    vsum
*else
    ev='z'
*endif
!
*if,ev,ne,'z',then              ! If ev is assigned 'z', then abort
    !
    *get,emax,ev,,num,max       ! retrieve MIN and MAX entity numbers
    *get,emin,ev,,num,min
    !
    *get,ecount,ev,,count       ! number of specified entities in the
    !                           ! selected entity set
    *do,jkl_,1,ecount,1
        *if,jkl_,eq,1,then
            e%jkl_%=emin
        *else
            jj_=jkl_-1
            *get,xx,ev,e%jj_%,nxth
            e%jkl_%=xx
        *endif
    *enddo
*endif
!
*do,ii_,1,ecount,1
    !
    *if,entity,eq,'l',then
        *get,ec%ii_%,line,e%ii_%,leng
    *elseif,entity,eq,'a',then
        *get,ec%ii_%,area,e%ii_%,area
    *elseif,entity,eq,'v',then
        *get,ec%ii_%,volu,e%ii_%,volu
    *endif
*enddo
!
*do,ii_,1,ecount,1
    !
    *if,ii_,eq,1,then
        xx=ec1
        yy=e1
    *else
        *if,xx,gt,ec%ii_%,then
            xx=xx
            yy=yy
        *else
            xx=ec%ii_%
            yy=e%ii_%
        *endif
    *endif
*enddo
!
*if,entity,eq,'l',then
    max_leng=xx
    max_lnum=yy
*elseif,entity,eq,'a',then
    max_area=xx
    max_anum=yy
*elseif,entity,eq,'v',then
    max_vol=xx
    max_vnum=yy
*endif
!
*do,ijk_,1,ecount,1
    *set,e%ijk_%,
    *set,ec%ijk_%
    *set,xx,
    *set,yy,
    *set,ev,
    *set,entity,
    *set,emax,
    *set,emin,
*enddo
!
*set,ijk_,
*set,ii_,
*set,jj_,
*set,jkl_,


w:\ansys\mac\tools\min_e_dim_array.mac.html

!   TITLE:  min_e_dim_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    05/18/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the minimum value, within a selected
!   set, of the dimension of a specified entity:
!
!           ENTITY      DIMENSION
!          --------    -----------
!
!           line         length
!           area         area
!           volume       volume
!
!   These entity numbers and their dimension (characteristic) are stored in
!   arrays of the user specified names, 'anam' and 'anam'c (c is for character-
!   istic), respectively. (e.g., if anam='lnset', then the arrays created are
!   'lnset' and 'lnsetc')
!
!   Input data necessary to run this macro:
!
!       A selected set of specified entities
!
!       entity = 'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!
!       anam = character name for array (must be 7 characters or less)
!
!       typ = array type
!
!           'array' = normal (default) array
!           'table' = table array
!
!   The output of this macro are:
!
!       1.) ecount = the number of entities in the array
!
!       2.) min_leng
!           min_area
!           min_vol  = the minimum value of the specified
!                      entity characteristic (i.e., length,
!                      area or volume, respectively)
!
!       3.) min_lnum
!           min_anum
!           min_vnum = the entity number that has the minimum
!                      dimension
!
!       4.) min_indx = the index in the array of the minimum
!                      dimension
!
!       5.) The 2 arrays with the name as specified in 'anam'
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MIN_E_DIM_ARRAY, entity, anam, typ
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

entity=arg1
anam=arg2
typ=arg3
!
*if,entity,eq,'l',then        ! assignment of entity variable, 'ev'
    ev='line'
*elseif,entity,eq,'a',then
    ev='area'
    asum
*elseif,entity,eq,'v',then
    ev='volu'
    vsum
*else
    ev='z'                    ! If entity is not an 'l','a' or 'v',
*endif                        ! then assign ev to a dummy variable 'z'.
!
*if,ev,ne,'z',then            ! If ev is assigned 'z', then abort
    !
    *get,emax,ev,,num,max     ! retrieve MIN and MAX entity numbers
    *get,emin,ev,,num,min
    !
    *get,ecount,ev,,count     ! number of specified entities in the
    !                         ! selected entity set
    !
    *dim,%anam%,typ,ecount    ! Initialize entity array
    !
    !------------------- Store Entities in an Array -----------------
    !
    *do,ii,1,ecount,1
        *if,ii,eq,1,then
            %anam%(ii,1)=emin
        *else
            jj=ii-1
            *get,xx,ev,%anam%(jj,1),nxth
            %anam%(ii,1)=xx
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    *dim,%anam%c,typ,ecount   ! Initialize entity characteristic array
    !
    !
    !------------ Store Entity Characteristics in Array -------------
    !
    *do,ii,1,ecount,1
        !
        *if,entity,eq,'l',then
            *get,%anam%c(ii,1),line,%anam%(ii,1),leng
        *elseif,entity,eq,'a',then
            *get,%anam%c(ii,1),area,%anam%(ii,1),area
        *elseif,entity,eq,'v',then
            *get,%anam%c(ii,1),volu,%anam%(ii,1),volu
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    !
    !------------ Store Minimum Entity & Characteristic -------------
    !
    *do,ii,1,ecount,1
            !
            *if,ii,eq,1,then
                xx=%anam%c(ii,1)
                yy=%anam%(ii,1)
            *else
                *if,xx,lt,%anam%c(ii,1),then
                    xx=xx
                    yy=yy
                *else
                    xx=%anam%c(ii,1)
                    yy=%anam%(ii,1)
                *endif
            *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    !
    !
    !-------- Store Index of Minimum Entity & Characteristic --------
    !
    *do,ii,1,ecount,1
        *if,%anam%c(ii,1),eq,xx,then
            min_indx=ii
        *endif
    *enddo
    !
    !----------------------------------------------------------------
    !
    *if,entity,eq,'l',then
        min_leng=xx
        min_lnum=yy
    *elseif,entity,eq,'a',then
        min_area=xx
        min_anum=yy
    *elseif,entity,eq,'v',then
        min_vol=xx
        min_vnum=yy
    *endif
*endif
!
*set,xx,
*set,yy,
*set,ev,
*set,entity,
*set,emax,
*set,emin,
*set,anam,
*set,typ,


w:\ansys\mac\tools\min_enty_dim.mac.html

!   TITLE:  min_enty_dim.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   04/19/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the minimum value, within a selected
!   set, of the dimension of a specified entity:
!
!           ENTITY      DIMENSION
!          --------    -----------
!
!           line         length
!           area         area
!           volume       volume
!
!   Input data necessary to run this macro:
!
!       A selected set of specified entities
!
!       entity = 'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MIN_ENTY_DIM, entity
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

entity=arg1
!
*if,entity,eq,'l',then      ! assignment of entity variable, 'ev'
    ev='line'
*elseif,entity,eq,'a',then
    ev='area'
    asum
*elseif,entity,eq,'v',then
    ev='volu'
    vsum
*endif
!
*if,entity,ne,'l',then      ! If entity is not an 'l','a' or 'v',
   *if,entity,ne,'a',then       ! then assign ev to a dummy variable 'z'.
      *if,entity,ne,'v',then
         ev='z'
      *endif
   *endif
*endif
!
*if,ev,ne,'z',then        ! If ev is assigned 'z', then abort
    !
    *get,emax,ev,,num,max     ! retrieve MIN and MAX keypoint numbers
    *get,emin,ev,,num,min
    !
    *get,ecount,ev,,count     ! number of specified entities in the
    !             ! selected entity set
    *do,xyz_,1,ecount,1
        *if,xyz_,eq,1,then
            e%xyz_%=emin
        *else
            jkl_=%xyz_%-1
            *get,x,ev,e%jkl_%,nxth
            e%xyz_%=x
        *endif
    *enddo
*endif
!
*do,ikl_,1,ecount,1
    !
    *if,entity,eq,'l',then
        *get,ec%ikl_%,line,e%ikl_%,leng
    *elseif,entity,eq,'a',then
        *get,ec%ikl_%,area,e%ikl_%,area
    *elseif,entity,eq,'v',then
        *get,ec%ikl_%,volu,e%ikl_%,volu
    *endif
*enddo
!
*do,iii_,1,ecount,1
    !
    *if,i,eq,1,then
        x=ec1
        y=e1
    *else
        *if,x,lt,ec%iii_%,then
            x=x
            y=y
        *else
            x=ec%iii_%
            y=e%iii_%
        *endif
    *endif
*enddo
!
*if,entity,eq,'l',then
    min_leng=x
    min_lnum=y
*elseif,entity,eq,'a',then
    min_area=x
    min_anum=y
*elseif,entity,eq,'v',then
    min_vol=x
    min_vnum=y
*endif
!
*do,ijk_,1,ecount,1
    *set,e%ijk_%,
    *set,ec%ijk_%
    *set,x,
    *set,y,
    *set,ev,
    *set,entity,
    *set,ecount,
    *set,emax,
    *set,emin,
*enddo
!
*set,xyz_,
*set,jkl_,
*set,ijk_,
*set,iii_,
*set,ikl_,


w:\ansys\mac\tools\constants.mac.html

!   TITLE:  constants.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  05/09/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a standard set of numerical constants. These
!   constants are used for standard modeling purposes, and are used as
!   compact short-hand notations that are easy to remember.
!
!
pi=acos(-1)                 ! the constant 'pi'
!
rconv=pi/180                ! radian conversion constant (degrees to radians)
!
dconv=180/pi                ! degree conversion constant (radians to degrees)
!
rtangle=(pi/2)*dconv        ! right angle (90)
!
mtr=0.010                   ! machine tool radius
!
g_si=9.807                  ! g (m/sec^2)
!
g_bin=386.089               ! g (in/sec^2)


w:\ansys\mac\tools\round_num.mac.html

!   TITLE:  round_num.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/09/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro takes a real (decimal) number and rounds it to a user
!   specified number of decimal placesafter the decimal point.
!
!
!   COMMAND SYNTAX:
!
!                   (1)    (2)
!        ROUND_NUM, num, d_places
!
!
!   ARGUMENTS:
!
!           num = the number to be rounded.
!
!           d_places = the number of decimal after the decimal point
!                      to round to.
!
!
!   DESCRIPTION:
!
!   Input the decimal number, in its full precision form, in the 1st argument
!   and the the number of desired decimal places to round-off to in the 2nd
!   argument.
!
!   The rounded number is returned in the parameter:    num_
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_=arg1
dplac_=arg2
!
wholnum_=num_-mod(num_,1)
!
decnum_=num_-wholnum_
!
factor_=10**dplac_
!
decnum_=(nint(decnum_*factor_))/factor_
!
num_=wholnum_+decnum_
!
*set,decnum_,
*set,dplac_,
*set,wholnum_,
*set,factor_,


w:\ansys\mac\tools\place_value.mac.html

! TITLE:  place_value.mac (MANAGEMENT)

!---------------------------------------------------------------------------
!   Rev -     03/07/2001    J. Judd
!---------------------------------------------------------------------------
!
! PURPOSE: returns the number in the specified place from the decimal point
!          + place is in front of the decimal point
!          - place is in back of the decimal point

!--------------------------- COMMAND SYNTAX -------------------------
! place_value, Number, PlaceOfInterest
!   Number = number for evaluation
!   PlaceOfInterest = position from decimal point of number of interest
!---------------------------------------------------------------------------

! EXAMPLE: place_value,123.456,3   returns PlaceVal=1
!      place_value,123.456,-2  returns PlaceVal=5
!          place_value,-123.456,-2 returns PlaceVal=-5

! VARIABLES-Internal:
!   None

! VARIABLES-Global:  (not reset at end)
!   PlaceVal

! VARIABLES-Global Persist:  (always available, e.g. not stored in model file)
!   none

! VARIABLES-Assumed: (must or should be defined prior to invoking this macro)

! OTHER CODE CALLED:  (code internally used that must be available)
!   place_value.pl

! WARNING:
!   'Number' must have no more than 9 total digits otherwise ANSYS
!    might round or converts to scientific notation.

! TO BE DONE (TBD):  (Items planned for functional expansion or correction)
!   - overcome number size limit if necessary. maybe make into string in ANSYS first?

! NOTES:

*get,prkey_,active,0,prkey
/nopr

/syp,place_value.pl,arg1,arg2
/input,sys_,out


w:\ansys\mac\tools\place_value.pl.html

#!/usr/local/bin/perl
#

# TITLE:  place_value.pl (MANAGEMENT)

# place_value, Number, PlaceOfInterest  -- Returns number at specified place

#---------------------------------------------------------------------------
#   Rev -     03/07/2001    D. Edwards for J. Judd
#---------------------------------------------------------------------------
#
# PURPOSE: returns the number in the specified place from the decimal point
#          + place is in front of the decimal point
#          - place is in back of the decimal point

#--------------------------- COMMAND SYNTAX -------------------------
# place_value, Number, PlaceOfInterest
#   Number = number for evaluation
#   PlaceOfInterest = position from decimal point of number of interest
#---------------------------------------------------------------------------

# EXAMPLE: place_value,123.456,3   returns PlaceVal=1
#      place_value,123.456,-2  returns PlaceVal=5
#          place_value,-123.456,-2 returns PlaceVal=-5

# VARIABLES-Internal:
#   None

# VARIABLES-Global:  (not reset at end)
#   PlaceVal

# VARIABLES-Global Persist:  (always available, e.g. not stored in model file)
#   none

# VARIABLES-Assumed: (must or should be defined prior to invoking this macro)

# WARNING:
#

# TO BE DONE (TBD):  (Items planned for functional expansion or correction)
#   - overcome number size limit if necessary. maybe make into string in ANSYS first?

# NOTES:

$number=$ARGV[0];
$index=$ARGV[1];

# Store away the sign of the number
if ($number < 0) {
    $sign = -1;
    $number = -$number;
} else {
    $sign = 1;
}

# Make sure the number has a decimal point
if (! $number =~ /\./) {
    $number = "$number" . ".";
}

# Extract the place value based on the index
if ( $index < 0 ) {

    # Negative index
    # Get the decimal portion
    $rem = $number;
    $rem =~ s/.*\.//;   # Delete everything before the decimal point

    $PlaceVal = substr($rem,-1-$index,1);
} else {

    # Positive index
    # Get the integer portion
    $int = $number;
    $int =~ s/\..*//;   # Delete everything after a decimal point if there is one

    $PlaceVal = substr(reverse($int),$index-1,1);
}

$PlaceVal *= $sign;

#
# Create input file for Ansys to read results back in.
#
open(OUT,">sys_.out") || die "Unable to create sys_.out: $!";

print OUT "PlaceVal=$PlaceVal\n";

close(OUT);


w:\ansys\mac\tools\ang_convert.mac.html

!   TITLE:  ang_convert.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro converts an angle value, or an angle value contained by
!   a parameter, from its absolute positive value to its negative-valued
!   equivalent; or vice-versa.
!
!   COMMAND SYNTAX:
!
!                      (1)     (2)       (3)
!        ANG_CONVERT, angle, cnvr_typ, new_parm
!
!   ARGUMENTS:
!
!       (1) angle = the angle dimension value or angle parameter
!                   character name. If the parameter name is used,
!                   the parameters character name must be input in
!                   single quotes.
!
!       (2) cnvr_typ = conversion type:
!
!                   0 (or blank) = converts a negative valued angle to
!                                  its positive-valued equivalent.
!
!                   1 = converts a positive valued angle to it negative
!                       -valued equivalent.
!
!       (3) new_parm = the new parameter name to assign the converted
!                      value. (input in single quotes)
!
!
!   DESCRIPTION:
!
!   An angle value, or parameter that is an angle value, is converted and
!   returned through the parameter, ANG; the input parameter name or a new
!   parameter name (argument 3).
!
!   If the 1st argument is a scalar numerical value (not a parameter), and
!   argument 3 is not specified, the parameter ANG returns the converted
!   angle value.  If the 1st argument is the character name of a parameter,
!   and again argument 3 is not specified, then the value (angle) of that
!   parameter is converted and is returned to that parameter. The character
!   name must be input in single quotes.
!
!   If argument 3, the new parameter character name, is specified, then the
!   converted value of argument 1 is returned in this new parameter.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

ang1_=arg1                  ! angle parameter/value to be converted
dir_conv=arg2               ! direction of conversion
newprm_=arg3                ! new parameter name
!
*get,ptyp1_,parm,ang1_,type             ! angle parameter type
*get,ptyp2_,parm,newprm_,type           ! new angle parameter type
!
*if,ptyp1_,eq,3,then
    a1_=%ang1_%
*endif
!
*if,ptyp1_,eq,3,then
    !
    *if,dir_conv,eq,0,then
        *if,a1_,lt,0,then
            ang=a1_+360
        *else
            ang=a1_
        *endif
    *else
        *if,a1_,gt,0,then
            ang=-(360-a1_)
        *else
            ang=a1_
        *endif
    *endif
    !
    *if,ptyp2_,ne,3,then
        %ang1_%=ang
    *else
        %newprm_%=ang
    *endif
    !
    *set,ang,
    !
*elseif,ptyp1_,eq,0,then
    !
    *if,dir_conv,eq,0,then
        *if,ang1_,lt,0,then
            ang=ang1_+360
        *else
            ang=ang1_
        *endif
    *else
        *if,ang1_,gt,0,then
            ang=-(360-ang1_)
        *else
            ang=ang1_
        *endif
    *endif
    !
    *if,ptyp2_,eq,3,then
        %newprm_%=ang
        *set,ang,
    *endif
*endif
!
*set,a1_,
*set,ang1_,
*set,dir_conv,
*set,ptyp1_,


w:\ansys\mac\tools\zero.mac.html

!   TITLE:  zero.mac (SOLVE)
!
!---------------------------------------------------------------------------
!       Rev -   03/28/2001  D. Edwards
!       Rev A   04/21/2001  D. Edwards
!               Added "z" prefix to avoid parameter name conflicts.
!---------------------------------------------------------------------------
!
!   Find the zero of a function using Ridder's method.  Return the
!   result in global parameter "root".
!
!   Ref.  Press, "Numerical Recipes in C", 2nd ed., Cambridge, 1992, p358
!
!---------------------------------------------------------------------------
!
!   Usage:  zero,f,x1,x2,offset,xacc
!
!   Arguments:
!
!          f =  Macro name defining the function to find the root of.
!               The macro must accept the independant variable as
!               its first argument.  f must return f(x) in global
!               parameter in "yzero".
!
!         x1 =  Lower bracket.  The root must reside between x1 and x2.
!
!         x2 =  Upper bracket.
!
!     offset =  Find where function equals "offset" instead of zero.
!               This will find x=root such that
!
!                   f(root) = offset
!
!       xacc =  The root returned by this macro, "root", will be
!               refined to approximately this accuracy.  Accuracy defaults
!               to 1.0E-4 if xacc is not specified.
!
!---------------------------------------------------------------------------
!
!   Example:    zero,'ztest',.5,2,0,1e-5
!
!               Macro calls of the form
!
!                   ztest,x
!
!               will be repeatedly performed to converge on the root
!               between .5 and 2 with an accuracy of approximately 1e-5.
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

zMAXIT_=30
zUNUSED_=-1.11e30

zf_=arg1
zx1_=arg2
zx2_=arg3
zoffset_=arg4
zxacc_=arg5

*if,zoffset_,eq,0,then
    zoffset_=0
*endif

*if,zxacc_,eq,0,then
    zxacc_=1e-4
*endif

zdone_=0                ! Flag set to 1 when converged on root

/out,zero,out
*msg,,zxacc_
Results of zero.mac (xacc = %g):
*msg

*msg,,zoffset_
Loop #___________x________________f(x)___________f(x)-(%g)

*msg

/out

*set,yzero
parsav,,zero,parm
%zf_%,zx1_
parres,change,zero,parm
zfl_=yzero-zoffset_

/out,zero,out,,append
*vwrite,zx1_,yzero,zfl_
(' x1 ',F18.4,E18.4,E18.3)
/out

*set,yzero
parsav,,zero,parm
%zf_%,zx2_
parres,change,zero,parm
zfh_=yzero-zoffset_

/out,zero,out,,append
*vwrite,zx2_,yzero,zfh_
(' x2 ',F18.4,E18.4,E18.3)
/out

and,'zb1_',zfl_>0,zfh_<0
and,'zb2_',zfl_<0,zfh_>0
or,'zb_',zb1_,zb2_

*if,zb_,ne,0,then
    zxl_=zx1_
    zxh_=zx2_
    zans_=zUNUSED_

    *do,zj_,1,zMAXIT_
        zxm_=.5*(zxl_+zxh_)

        *set,yzero
        parsav,,zero,parm
        %zf_%,zxm_
        parres,change,zero,parm
        zfm_=yzero-zoffset_

/out,zero,out,,append
*vwrite,zj_,zxm_,yzero,zfm_
(F3.0,' ',F18.4,E18.4,E18.3)
/out

        zs_=sqrt(zfm_*zfm_-zfl_*zfh_)

        *if,zs_,eq,0,then
            zdone_=1
            *exit
        *endif

        *if,zfl_,ge,zfh_,then
            zsign_=1.0
        *else
            zsign_=-1.0
        *endif

        zxnew_=zxm_+(zxm_-zxl_)*zsign_*zfm_/zs_

        *if,abs(zxnew_-zans_),le,zxacc_,then
            zdone_=1
            *exit
        *endif

        zans_=zxnew_
        *set,yzero
        parsav,,zero,parm
        %zf_%,zans_
        parres,change,zero,parm
        zfnew_=yzero-zoffset_

/out,zero,out,,append
*vwrite,zxnew_,yzero,zfnew_
('    ',F18.4,E18.4,E18.3)
/out

        *if,zfnew_,eq,0,then
            zdone_=1
            *exit
        *endif

        ! if (SIGN(fm,fnew) != fm) {
        *if,zfnew_,ge,0,then
            zb_=abs(zfm_)
        *else
            zb_=-abs(zfm_)
        *endif

        *if,zb_,ne,zfm_,then
            zxl_=zxm_
            zfl_=zfm_
            zxh_=zans_
            zfh_=zfnew_
        *else
          ! if (SIGN(fl,fnew) != fl) {
            *if,zfnew_,ge,0,then
              zb_=abs(zfl_)
            *else
                zb_=-abs(zfl_)
            *endif

            *if,zb_,ne,zfl_,then
                zxh_=zans_
                zfh_=zfnew_
            *else
              ! if (SIGN(fh,fnew) != fh) {
              *if,zfnew_,ge,0,then
                  zb_=abs(zfh_)
              *else
                  zb_=-abs(zfh_)
              *endif

              *if,zb_,ne,zfh_,then
                  zxl_=zans_
                  zfl_=zfnew_
              *else
                *msg,error
                Error in zero.mac: Not supposed to get here.
              *endif
      *endif
        *endif

        *if,abs(zxh_-zxl_),le,zxacc_,then
            zdone_=1
            *exit
        *endif
    *enddo

    *if,zdone_,eq,1,then
        root=zans_
    *else
        *msg,error,zMAXIT_
        Exceeded maximum iterations in %i in zero.mac
    *endif

*else
    *if,zfl_,eq,0,then
        root=zx1_
        zdone_=1
    *endif

    *if,zfh_,eq,0,then
        root=zx2_
        zdone_=1
    *endif

    *if,zdone_,eq,0,then
        *msg,error
        Root must be bracketed in zero.mac
    *endif
*endif

*if,zdone_,eq,1,then

/out,zero,out,,append
*msg

*msg,,root,zfnew_+zoffset_
 *** f(%g) = %g
*msg

*msg,,zj_
Found root in %i loops
/out
*uilist,zero,out

*endif

*set,zMAXIT_
*set,zUNUSED_
*set,zf_
*set,zx1_
*set,zx2_
*set,zoffset_
*set,zxacc_
*set,zdone_
*set,zfl_
*set,zfh_
*set,zfnew_
*set,zb_
*set,zb1_
*set,zb2_
*set,zans_
*set,zj_
*set,zxm_
*set,zxl_
*set,zxh_
*set,zfm_
*set,zs_
*set,zsign_
*set,zxnew_


w:\ansys\mac\tools\create_mat_prop.mac.html

!   TITLE:  create_mat_prop.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/14/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro allows the user to create a new material and its properties;
!   or to define additional properties to an already existing material.
!
!
!   COMMAND SYNTAX:
!
!                            (1)   (2)    (3)   (4)    (5)   (6)    (7)
!           CREATE_MAT_PROP, mat, prop1, val1, prop2, val2, prop3, val3
!
!
!   ARGUMENTS:
!
!           mat = material name
!
!           propN = material property label
!
!           valN = material property value of propN
!
!
!   DESCRIPTION:
!
!   If a material that is not previously defined in the material library
!   listing, or a generic user defined material, is to be created, then
!   a new material name may be input in argument 1, and up to 3 material
!   properties and their values in the remaining arguments.
!
!   A generic material that is to be defined will be added to the material
!   name array 'mat_name', along with its material properties.
!
!   If the name in argument 1 is an existing material in 'mat_name', then
!   the remaining arguments, that define the property values, will be input
!   into the respective property values for that material. If these values
!   are already defined, then these new values will over-write the existing
!   values.
!
!   If more than 3 properties are to be defined, then simply rerunning this
!   macro with the new additional properties will add these properties values
!   to the 'mat_prop' array.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

mat_=arg1
!
*get,nummat_,parm,mat_name,dim,y
!
*if,nummat_,gt,0,then
    arry_search,'mat_name','%mat_%'
    !
    *if,hits,eq,0,then
        !
        *dim,matbuff_,char,1,nummat_            ! add column to MAT_NAME
        !
        *do,abcd_,1,nummat_,1
            matbuff_(1,abcd_)=mat_name(1,abcd_)
        *enddo
        !
        *set,mat_name(1),
        !
        *dim,mat_name,char,1,nummat_+1
        !
        *do,abcd_,1,nummat_,1
            mat_name(1,abcd_)=matbuff_(1,abcd_)
        *enddo
        !
        mat_name(1,nummat_+1)=mat_
        !
        *set,matbuff_(1),
        !
        !
        *get,matpr_,parm,mat_prop,dim,x         ! add column to MAT_PROP
        *get,matpc_,parm,mat_prop,dim,y
        !
        *dim,matpbuf_,array,matpr_,matpc_
        !
        *do,bcde_,1,matpc_,1
            *do,cdef_,1,matpr_,1
                matpbuf_(cdef_,bcde_)=mat_prop(cdef_,bcde_)
            *enddo
        *enddo
        !
        *set,mat_prop(1),
        !
        *dim,mat_prop,array,matpr_,matpc_+1
        !
        *do,bcde_,1,matpc_,1
            *do,cdef_,1,matpr_,1
                mat_prop(cdef_,bcde_)=matpbuf_(cdef_,bcde_)
            *enddo
        *enddo
        !
        *get,matpc_,parm,mat_prop,dim,y
        mat_prop(1,matpc_)=matpc_
        col_=matpc_
        !
        *set,matpbuf_(1),
    *else
        col_=hit(1,2)
    *endif
    !
    *do,abcd_,2,6,2                 ! assign material property values
        prop_=arg%abcd_%
        !
        *get,ptyp_,parm,prop_,type
        !
        *if,ptyp_,ne,0,then
            prop_=upcase(prop_)
            val_=arg%abcd_+1%
            !
            arry_search,'prop_lab','%prop_%'
            row_=hit(1,1)
            !
            mat_prop(row_+1,col_)=val_
        *endif
    *enddo
    !
    *get,numprop_,parm,mat_prop,dim,x
    *get,nummat_,parm,mat_name,dim,y
    !
    *do,abcd_,1,nummat_,1               ! assign material numbers
        mat_prop(1,abcd_)=abcd_
        namhold_=mat_name(1,abcd_)
        %namhold_%=abcd_
    *enddo
    !
    *do,abcd_,1,nummat_,1               ! initialize material properties
        *do,bcde_,2,numprop_,1
            !
            mpval_=mat_prop(bcde_,abcd_)
            !
            *if,mpval_,ne,0,then
                prop_=prop_lab(bcde_-1,1)
                matnum_=mat_prop(1,abcd_)
                !
                mp,prop_,matnum_,mpval_
            *endif
        *enddo
    *enddo
*else
    mat_select,arg1
    create_mat_prop,arg1,arg2,arg3,arg4,arg5,arg6,arg7
*endif
!
*set,prop_,
*set,val_,
*set,row_,
*set,col_,
*set,numprop_,
*set,nummat_,
*set,mat_,
*set,hits,
*set,abcd_,
*set,bcde_,
*set,cdef_,
*set,matnum_,
*set,mpval_,
*set,numprop_,
*set,nummat_,
*set,matpc_,
*set,matpr_,
*set,namhold_,


w:\ansys\mac\tools\create_rotaset.mac.html

!   TITLE:  create_rotaset.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    05/09/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro assigns area number and associated material number into an
!   array called ROTASET for use in ROTATE_VOLM_MSH.
!
!   COMMAND SYNTAX:
!
!
!       CREATE_ROTASET, a1, mat1, a2, mat2, a3, mat3, a4, mat4
!
!
!   ARGUMENTS:
!
!           aN = area number
!
!           matN = associated material number for area aN.
!
!   DESCRIPTION:
!
!   This macro assigns to the N x 2 array ROTASET the area numbers which
!   are to be rotate meshed and the corresponding material number for that
!   area. Therefore, the area number in the N x 1 position is given a mat-
!   erial number in the N x 2 position.
!
!   The command can take up to 8 arguments; 4 area number and 4 material
!   numbers.  If more than 4 areas are needed to be specified, then simply
!   run this macro on a second line immediately following the first line,
!   and prior to ROTATE_VOLM_MSH. ( This may be repeated as many times as
!   necessary ) Once ROTATE_VOLM_MSH is run, this array is deleted, allowing
!   it to be initialized for another ROTATE_VOLM_MSH operation.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*get,ptyp_,parm,rotaset,type        ! determine whether ROTASET exists
!
*if,ptyp_,ne,1,then                 ! If AMATMAX_ does not exist, then
    *dim,rotaset,array,1,2
    amatnum_=0                      ! initialize material numbers
    offst_=0                        ! initialize offset counter
*endif
!
*do,klm_,1,8,1                      ! assign material numbers
    !
    *if,arg%klm_%,eq,0,then         ! if argument = 0, then exit loop
        *exit
    *else                           ! if argument ~= 0, then store in array
        amatnum_=amatnum_+1
        !
        *if,mod(klm_,2),eq,1,then                   ! if argument # is odd then
            rotaset(amatnum_-offst_,1)=arg%klm_%    ! store in 1st column (area)
        *else
            offst_=offst_+1
            rotaset(amatnum_-offst_,2)=arg%klm_%    ! if argument # is even then
        *endif                                      ! store in 2nd column (mat)
        !
        *if,mod(klm_,2),eq,0,then
            *dim,buffer_,array,amatnum_-offst_,2    ! create buffer array
            !
            *do,ijk_,1,amatnum_-offst_,1            ! store contents of array
                buffer_(ijk_,1)=rotaset(ijk_,1)     ! in buffer
                buffer_(ijk_,2)=rotaset(ijk_,2)
            *enddo
            !
            *set,rotaset(1),                        ! delete array
            !
            *dim,rotaset,array,amatnum_-offst_+1,2  ! recreate array with 1
            !                                       ! higher DIM
            *do,ijk_,1,amatnum_-offst_,1            ! transfer buffer contents
                rotaset(ijk_,1)=buffer_(ijk_,1)     ! to array
                rotaset(ijk_,2)=buffer_(ijk_,2)
            *enddo
            !
            *set,buffer_(1),                        ! delete buffer
        *endif
    *endif
*enddo
!
!
*set,ijk_,
*set,klm_,
*set,ptyp_,


w:\ansys\mac\tools\mat_extract.mac.html

!   TITLE:  mat_extract.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro extracts a specified material property value from a specified
!   material.
!
!
!   COMMAND SYNTAX:
!
!           MAT_EXTRACT, mat_prop, mat
!
!
!   ARGUMENTS:
!
!           mat_prop = selected material property to be extracted.
!
!           mat = selected material to extract material property value from.
!
!   DESCRIPTION:
!
!   The user specified material property and material type is used to extract,
!   from the material property matrix (array) 'mat_prop', a particular material
!   property value. This value is returned in a parameter of the same name.
!
!   EXAMPLE:
!
!           It is desired to extract the material property, Young's Modulus,
!           EX, from material AL6061. Therefore, this macro call is of the
!           form:
!
!               mat_extract,'ex','al6061'
!
!           The desired material property value, EX, is returned in a
!           parameter of the same name, 'ex'.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

prop_=arg1
mat_=arg2
!
!
prop_=upcase(prop_)
!
*get,nummat_,parm,mat_name,dim,y
!
*if,nummat_,gt,0,then
    arry_search,'prop_lab','%prop_%'
    row_=hit(1,1)
    !
    arry_search,'mat_name','%mat_%'
    col_=hit(1,2)
    !
    %prop_%=mat_prop(row_+1,col_)
*endif
!
*set,prop_,
*set,row_,
*set,col_,
*set,nummat_,
*set,mat_,
*set,hits,


w:\ansys\mac\tools\mat_library.mac.html

!   TITLE:  mat_library.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro assigns material constants, numbers and names to the material
!   arrays.
!
!
!   COMMAND SYNTAX:
!
!               MAT_LIBRARY, mat_name
!
!
!   ARGUMENTS:
!
!           mat_name = material name to be assigned
!
!
!   DESCRIPTION:
!
!   The material arrays containing all pertinent material data are:
!
!       prop_lab = the 42 x 1 array containing the character names of the
!                  various material properties. There are 42 properties in
!                  all, therefore, each row element is a material property.
!
!       mat_name = the 1 x N character array containing the material
!                  names. Each column element of this array is a specific
!                  material name.
!
!       mat_prop = the 43 x N scalar array containing the material
!                  numbers and property values. The 1st row of this array
!                  contains the material numbers assigned to the material
!                  names, where each column corresponds to the columns of
!                  the array 'mat_name'; and the rows correspond to the
!                  the material property labels in array 'prop_lab'. The
!                  values of these material properties are stored in this
!                  array, where the row index is the material property
!                  label (e.g., EX, DENS, VISC, etc.) and the column is the
!                  material.
!
!           For example:
!
!           material name --->  al6061 = 1  <--- the material number, which
!                                                is column 1 of 'mat_name'.
!
!           material name --->  ti5057 = 2  <--- the material number, which
!                   .             .      .       is column 2 of 'mat_name'.
!                   .             .      .              .
!                   .             .      .              .
!                   .             .      .              .
!           material name --->  cres17 = N  <--- the material number, which
!                                                is column N of 'mat_name'.
!
!
!           N is the number of different materials.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
mat_=arg1
!
!
!-------------------------------------------------------------------------
!------------------ Create Material Property Label Array -----------------
!-------------------------------------------------------------------------
!
!
numprop_=42
!
*get,ptyp1_,parm,prop_lab,type
!
*if,ptyp1_,ne,4,then
    *dim,prop_lab,char,numprop_,1       ! create property label array
        !
        prop_lab(1,1)='EX'          ! Elastic (Young's) Moduli (X)
        prop_lab(2,1)='EY'          ! Elastic (Young's) Moduli (Y)
        prop_lab(3,1)='EZ'          ! Elastic (Young's) Moduli (Z)
        !
        prop_lab(4,1)='ALPX'        ! Coefficients of Thermal Expansion (X)
        prop_lab(5,1)='ALPY'        ! Coefficients of Thermal Expansion (Y)
        prop_lab(6,1)='ALPZ'        ! Coefficients of Thermal Expansion (Z)
        !
        prop_lab(7,1)='REFT'        ! Reference Temperature
        !
        prop_lab(8,1)='PRXY'        ! Major Poisson's Ratio (XY)
        prop_lab(9,1)='PRYZ'        ! Major Poisson's Ratio (YZ)
        prop_lab(10,1)='PRXZ'       ! Major Poisson's Ratio (XZ)
        !
        prop_lab(11,1)='NUXY'       ! Minor Poisson's Ratio (XY)
        prop_lab(12,1)='NUYZ'       ! Minor Poisson's Ratio (YZ)
        prop_lab(13,1)='NUXZ'       ! Minor Poisson's Ratio (XZ)
        !
        prop_lab(14,1)='GXY'        ! Shear Moduli (XY)
        prop_lab(15,1)='GYZ'        ! Shear Moduli (YZ)
        prop_lab(16,1)='GXZ'        ! Shear Moduli (XZ)
        !
        prop_lab(17,1)='DAMP'       ! Damping Matrix Multiplier
        !
        prop_lab(18,1)='MU'         ! Coefficient of Friction
        !
        prop_lab(19,1)='DENS'       ! Mass Density
        !
        prop_lab(20,1)='C'          ! Specific Heat
        !
        prop_lab(21,1)='ENTH'       ! Enthalpy
        !
        prop_lab(22,1)='KXX'        ! Thermal Conductivities (X)
        prop_lab(23,1)='KYY'        ! Thermal Conductivities (Y)
        prop_lab(24,1)='KZZ'        ! Thermal Conductivities (Z)
        !
        prop_lab(25,1)='HF'         ! Convection (Film) Coefficient
        !
        prop_lab(26,1)='EMIS'       ! Emissivity
        !
        prop_lab(27,1)='QRATE'      ! Heat Generation Rate
        !
        prop_lab(28,1)='VISC'       ! Viscosity
        !
        prop_lab(29,1)='SONC'       ! Sonic Velocity
        !
        prop_lab(30,1)='RSVX'       ! Electrical Resistivities (X)
        prop_lab(31,1)='RSVY'       ! Electrical Resistivities (Y)
        prop_lab(32,1)='RSVZ'       ! Electrical Resistivities (Z)
        !
        prop_lab(33,1)='PERX'       ! Electrical Permittivities (X)
        prop_lab(34,1)='PERY'       ! Electrical Permittivities (Y)
        prop_lab(35,1)='PERZ'       ! Electrical Permittivities (Z)
        !
        prop_lab(36,1)='MURX'       ! Magnetic Relative Permeabilities (X)
        prop_lab(37,1)='MURY'       ! Magnetic Relative Permeabilities (Y)
        prop_lab(38,1)='MURZ'       ! Magnetic Relative Permeabilities (Z)
        !
        prop_lab(39,1)='MGXX'       ! Magnetic Coercive Forces (X)
        prop_lab(40,1)='MGYY'       ! Magnetic Coercive Forces (Y)
        prop_lab(41,1)='MGZZ'       ! Magnetic Coercive Forces (Z)
        !
        prop_lab(42,1)='LSST'       ! Dielectric Loss Tangent
*endif
!
!
!-------------------------------------------------------------------------
!------------ Create Material Name & Material Property Arrays ------------
!-------------------------------------------------------------------------
!
!
*get,ptyp2_,parm,mat_prop,type
!
*if,ptyp2_,ne,1,then                ! create material property array
    *dim,mat_prop,array,numprop_+1,1
*else
    *get,matpc_,parm,mat_prop,dim,y
    !
    *dim,matpbuf_,array,numprop_+1,matpc_
    !
    *do,bcd_,1,matpc_,1
        *do,cde_,2,numprop_+1,1
            matpbuf_(cde_,bcd_)=mat_prop(cde_,bcd_)
        *enddo
    *enddo
    !
    *set,mat_prop(1),
    !
    *dim,mat_prop,array,numprop_+1,matpc_+1
    !
    *do,bcd_,1,matpc_,1
        *do,cde_,2,numprop_+1,1
            mat_prop(cde_,bcd_)=matpbuf_(cde_,bcd_)
        *enddo
    *enddo
    !
    *get,matpc_,parm,mat_prop,dim,y
    !
    *set,matpbuf_(1),
*endif
!
!
!-------------------------------------------------------------------------
!----------------------- Material Property Listing -----------------------
!-------------------------------------------------------------------------
!
!
mat_list
!
!
!-------------------------------------------------------------------------
!----------------------- Assign Material Properties ----------------------
!-------------------------------------------------------------------------
!
*do,ijk_,1,numprop_,1
    !
    prop_=prop_lab(ijk_,1)
    !
    *get,typ_,parm,%prop_%,type
    !
    *if,typ_,eq,0,then
        arry_search,'prop_lab','%prop_%'
        row_=hit(1,1)
        !
        arry_search,'mat_name','%mat_%'
        col_=hit(1,2)
        !
        mat_prop(row_+1,col_)=%prop_%
    *endif
    !
    *set,%prop_%
*enddo
!
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
!
*set,ijk_,
*set,prop_,
*set,row_,
*set,col_,
*set,mat_,
*set,matpc_,
*set,cde_,
*set,bcd_,
*set,numprop_,
*set,ptyp1_,
*set,ptyp2_,
*set,typ_,


l:\ansys\mac\tools\mat_list.mac.html

!   TITLE:  mat_list.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro is a listing of all materials, and their properties.
!
!
!   DESCRIPTION:
!
!   The materials are listed by their name in the IF-THEN structure, and
!   their material properties are specified within these structures. This
!   macro is called by 'mat_library.mac'.
!
!
!           TABLE OF CONTENTS OF MATERIALS & PARAMETER NAMES
!           ________________________________________________
!
!   Metallic:
!
!       1.  AL 6061-T6 .................................... al6061
!       2.  AL 6061-T0 .................................... al6061a
!       3.  A356.0-T6 AL, AMS-A-21180 ..................... ala356
!       4.  17-4PH CRES, Cond H1025, AMS 5643 ............. c17_4
!       5.  304 CRES, Cond A, ASTM A276 ................... c304a
!       6.  CRES 440C ..................................... c440c
!       7.  416 CRES, Cond H, ASTM A582 ................... c416
!       8.  416 CRES, Cond A, ASTM A582 ................... c416a
!       9.  416 CRES, Cond T, ASTM A582 ................... c416b
!       10.  Tungsten Alloy, AMS-T-21014 .................. tungsten
!       11.  INCONEL 718 , AMS 5662,5663 .................. inc718
!       12.  15-5PH CRES, Cond H1025, AMS 5862 ............ c15_5
!       13.  410 CRES ..................................... c410
!       14.  410 CRES, Cast ............................... c410c
!       15.  Titanium (Pure), AMS 4900 .................... ti4900
!
!
!   Non-Metallic (General):
!
!       1.  Sand .......................................... sand
!       2.  Air ........................................... air
!
!   Insulators (Thermal/Electrical):
!
!       1.  Epon 828 epoxy ................................ epon828
!       2.  Ceramic Tile Insulation, AETB-8 ............... aetb_8
!
!   Units:
!
!       Modulus of Elasticity:              EX      psi
!       Density:                            DENS    lbf-s^2/in^4
!       Poisson's ratio:                    NUXY
!       Coefficient of Thermal Exansion:    ALPX    1/degF
!       Conduction Coefficient:             KXX     Btu/(hr-in-degF)
!       Specific Heat:                      C       Btu-in/(lbf-s^2-degF)
!
!       Convection coefficient: (used with SF command) Btu/(hr-in^2-degF)
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
constants
!
!
!________________________________ METALLIC _______________________________
!
!
!------------------------ 1.  AL 6061-T6 / al6061 ------------------------
!
*if,mat_,eq,'al6061',then
    EX=9.9e6
    DENS=.098/g_bin
    NUXY=0.33
    ALPX=12.25e-6       ! at -40 deg
*endif
!
!------------------------ 2.  AL 6061-T0 / al6061a -----------------------
!
*if,mat_,eq,'al6061a',then
    EX=9.9e6
    DENS=.098/g_bin
    NUXY=0.33
    ALPX=12.25e-6       ! at -40 deg
*endif
!
!----------------- 3.  A356.0-T6 AL, AMS-A-21180 / ala356 ----------------
!
*if,mat_,eq,'ala356',then
    EX=10.4E6
    DENS=.097/g_bin
    NUXY=0.33
    ALPX=11.1E-6        ! at -40 deg
*endif
!
!------------ 4.  17-4PH CRES, Cond H1025, AMS 5643 / c17_4 --------------
!
!   Ref 1
!
*if,mat_,eq,'c17_4',then
    EX=28.5e6
    DENS=.283/g_bin
    NUXY=0.27
    ALPX=6.15e-6        ! at -40 deg
*endif
!
!---------------- 5.  304 CRES, Cond A, ASTM A276 / c304a ----------------
!
*if,mat_,eq,'c304a',then
    EX=28.0e6
    DENS=.285/g_bin
    NUXY=0.27
    ALPX=9.6e-6         ! at -40 deg
*endif
!
!------------------------- 6.  CRES 440C / c440c -------------------------
!
*if,mat_,eq,'c440c',then
    EX=28.0E6
    DENS=.283/g_bin
    NUXY=0.27
    ALPX=5.56e-6        ! at -40 deg
*endif
!
!---------------- 7.  416 CRES, Cond H, ASTM A582 / c416 -----------------
!
!   Ref 2
!
*if,mat_,eq,'c416',then
    EX=28.5E6
    DENS=.283/g_bin
    NUXY=0.27
    ALPX=5.23e-6        ! at -40 deg
*endif
!
!---------------- 8.  416 CRES, Cond A, ASTM A582 / c416a ----------------
!
*if,mat_,eq,'c416a',then
    EX=28.5E6
    DENS=.283/g_bin
    NUXY=0.27
    ALPX=5.23e-6        ! at -40 deg
*endif
!
!--------------- 9.  416 CRES, Cond T, ASTM A582 / c416b -----------------
!
*if,mat_,eq,'c416b',then
    EX=28.0E6
    DENS=.283/g_bin
    NUXY=0.27
    ALPX=5.23e-6        ! at -40 deg
*endif
!
!-------------- 10.  Tungsten Alloy, AMS-T-21014 / tungsten --------------
!
*if,mat_,eq,'tungsten',then
    EX=50.0e6
    DENS=.607/g_bin
    NUXY=0.27
    ALPX=2.4e-6         ! at -40 deg
*endif
!
!--------------- 11.  INCONEL 718 , AMS 5662,5663 / inc718 ---------------
!
*if,mat_,eq,'inc718',then
    EX=29.4E6
    DENS=0.286/g_bin
    NUXY=0.29
    ALPX=7.0e-6
*endif
!
!------------ 12.  15-5PH CRES, Cond H1025, AMS 5862 / c15_5 -------------
!
*if,mat_,eq,'c15_5',then
    EX=28.5E6
    DENS=0.283/g_bin
    NUXY=0.27
    ALPX=6.25e-6
*endif
!
!------------------------- 13.  410 CRES / c410 --------------------------
!
*if,mat_,eq,'c410',then
    EX=28.5E6
    DENS=0.283/g_bin
    NUXY=0.27
    ALPX=5.28e-6
*endif
!
!------------------------- 14.  410 CRES / c410c --------------------------
!
*if,mat_,eq,'c410c',then
    EX=28.5E6
    DENS=0.280/g_bin
    NUXY=0.27
    ALPX=5.28e-6
*endif
!
!--------------------- 15.  Titanium (Pure) / ti4900 ----------------------
!
*if,mat_,eq,'ti4900',then
    EX=15.5E6
    DENS=0.163/g_bin
    NUXY=0.34
    ALPX=5.28e-6
    KXX=10.7
    C=0.15*g_bin
*endif
!
!
!__________________________ NON-METALLIC / GENERAL ________________________
!
!
!---------------------------- 1.  Sand / sand -----------------------------
!
*if,mat_,eq,'sand',then
    KXX=0.025
    DENS=0.054/g_bin
    C=0.28*g_bin
*endif
!
!
!_____________________ INSULATORS / THERMAL,ELECTRICAL ____________________
!
!
!---------------------- 1.  Epon 828 epoxy / epon828 ----------------------
!
*if,mat_,eq,'epon828',then
    EX=1.62E6
    DENS=.066/g_bin
    NUXY=0.4
    ALPX=15.0e-6        ! at -40 deg
*endif
!
!------------------ 2.  Ceramic Tile Insulation / aetb_8 ------------------
!
*if,mat_,eq,'aetb_8',then
    DENS=4.919e-3
    KXX=0.0642
    C=0.275*g_bin
    ALPX=1.77e-6
*endif
!
!--------------------------------------------------------------------------
!


w:\ansys\mac\tools\mat_select.mac.html

!   TITLE:  mat_select.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/13/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro assigns material properties and numbers used in part macros.
!
!
!   COMMAND SYNTAX:
!
!           MAT_SELECT, mat_1, mat_2, mat_3, mat_4, mat_5
!
!
!   ARGUMENTS:
!
!           mat_N = selected material.  This is the character name of the
!                   material to be initiated into the part macro.
!
!
!   DESCRIPTION:
!
!   This macro calls the defined properties from the material library for
!   that material, as defined by its character name.  This character name
!   is assigned the material number and may be used as the parameter for
!   that material number. Once defined, any reoccurence of this material
!   in macro assemblies is ignored, and the pre-existing material number
!   already assigned is used. This will alleviate any overlap or redundant
!   material assignments.
!
!   Up to five material properties may be defined by this macro on 1 line.
!   If more than five materials are needed to be defined, then simply rerunning
!   this macro with the additional materials will add to the material list.
!   The material numbers are assigned to each material in the order in which
!   they occur.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
/prep7
!
*get,matmax_,parm,mat_name,dim,y    ! determine whether MATMAX_ exists
!
*if,matmax_,eq,0,then               ! If MATMAX_ does not exist, then
    matnum_=0                       ! initialize material numbers
    mati_=1
*else
    matnum_=matmax_                 ! else, pick up at the last maximum
    mati_=matmax_+1                 ! material number
*endif
!
*do,k_,1,5,1                        ! assign material numbers
    parhold_=arg%k_%
    *get,_ptyp,parm,parhold_,type
    !
    *if,_ptyp,eq,0,then
        *exit
    *else
        matnum_=matnum_+1
    *endif
*enddo
!
matmax_=matnum_                         ! assign maximum material number
!
*get,ptyp_,parm,mat_name,type
!
*do,k_,mati_,matmax_,1                  ! assign material name
    *if,ptyp_,eq,4,then
        namhold_=arg%k_-(mati_-1)%
        arry_search,'mat_name','%namhold_%'
        !
        *if,hits,eq,0,then
            *get,nummat_,parm,mat_name,dim,y
            *dim,matbuff_,char,1,nummat_+1
            !
            *do,abc_,1,nummat_,1
                matbuff_(1,abc_)=mat_name(1,abc_)
            *enddo
            !
            *set,mat_name(1),
            !
            *dim,mat_name,char,1,nummat_+1
            !
            *do,abc_,1,nummat_,1
                mat_name(1,abc_)=matbuff_(1,abc_)
            *enddo
            !
            mat_name(1,nummat_+1)=arg%k_-(mati_-1)%
            !
            *get,nummat_,parm,mat_name,dim,y
            !
            *set,matbuff_(1),
            !
            namhold_=mat_name(1,nummat_)
            mat_library,'%namhold_%'
        *endif
    *else
        *if,k_,eq,1,then
            *dim,mat_name,char,1,1
            !
            mat_name(1,k_)=arg%k_-(mati_-1)%
            !
            *get,nummat_,parm,mat_name,dim,y
        *else
            *get,nummat_,parm,mat_name,dim,y
            *dim,matbuff_,char,1,nummat_+1
            !
            *do,abc_,1,nummat_,1
                matbuff_(1,abc_)=mat_name(1,abc_)
            *enddo
            !
            *set,mat_name(1),
            !
            *dim,mat_name,char,1,nummat_+1
            !
            *do,abc_,1,nummat_,1
                mat_name(1,abc_)=matbuff_(1,abc_)
            *enddo
            !
            mat_name(1,nummat_+1)=arg%k_-(mati_-1)%
            !
            *get,nummat_,parm,mat_name,dim,y
            !
            *set,matbuff_(1),
        *endif
        !
        namhold_=mat_name(1,nummat_)
        mat_library,'%namhold_%'
    *endif
*enddo
!
*get,numprop_,parm,mat_prop,dim,x
*get,nummat_,parm,mat_name,dim,y
!
*do,abc_,1,nummat_,1                ! assign material numbers
    mat_prop(1,abc_)=abc_
    namhold_=mat_name(1,abc_)
    %namhold_%=abc_
*enddo
!
*do,abc_,1,nummat_,1                ! initialize material properties
    *do,bcd_,2,numprop_,1
        !
        mpval_=mat_prop(bcd_,abc_)
        !
        *if,mpval_,ne,0,then
            prop_=prop_lab(bcd_-1,1)
            matnum_=mat_prop(1,abc_)
            !
            mp,prop_,matnum_,mpval_
        *endif
    *enddo
*enddo
!
*set,abc_,
*set,bcd_,
*set,prop_,
*set,matnum_,
*set,mpval_,
*set,numprop_,
*set,nummat_,
*set,namhold_,
*set,parhold_,
*set,matmax_,
*set,mati_,
*set,ptyp_,
*set,k_,


w:\ansys\mac\tools\msh_algorithm.mac.html

!   TITLE:  msh_algorithm.mac (MESH)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED        07/05/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!
!       This sub-macro is a mesh algorithm for meshing areas and/or volumes.
!       This will allow for uniform automatic free meshing of areas and volumes
!       to maximize brick meshing capability, and keeping element aspect ratios
!       and angles to reasonable values. Only the areas that are to be free
!       meshed should be selected for the free meshing operations.
!
!       For mapped meshing, the area must have 4 sides, in which case the algor-
!       ithm will size the lines based on the specified minimum element edge
!       length parameter 'elmnl'. Only the areas that are to be map meshed should
!       be selected for mapped mesh operations. Fot either free or mapped area
!       meshing only, use option PERFMSH=1. If line sizing is desired, but no
!       meshing operation, then use options PERFLSZ=1 and PERFMSH=0. See the
!       argument descriptions below for all available options.
!
!       When meshing a volume(s) using option PERFMSH=2, an area or set of areas
!       must be selected that have pre-existing meshes. The algorithm will then
!       determine the opposite side of the volume that each selected area is
!       attached to, and sweep the mesh accordingly.
!
!       When meshing a volume(s) using option PERFMSH=3, an area or set of areas
!       must be selected for area meshing. The algorithm will then mesh the select-
!       ed areas, determine the opposite side of the volume, and sweep the mesh
!       accordingly.
!
!       If a selected area is attached to more than one volume, the algorithm will
!       sweep both volumes (if possible).  However, the user may specify the
!       desired volume to mesh by specifying the argument, 'VOLSEL'. In this case,
!       each volume that is specified by 'VOLSEL' must be meshed separately using
!       this command; i.e., area and/or volume mesh one area at a time. (See below)
!
!       If volume free meshing or volume transition meshing is desired, then op-
!       tions PERFMSH=4 or PERFMSH=5, respectively, may be chosen.  If either of
!       these options are specified, then the only other arguments necessary for
!       this command are:
!
!                               etpv (element type for volume meshing)
!                               elmnl (element minimum edge length)
!                               elmxl (element maximum edge length)
!
!       When sweeping elements through a set of volumes that were created by rot-
!       ating a set of areas about an axis, it is necessary that all of the volumes
!       contain the same number of elements through their swept arc angles, regard-
!       less of their different arc lengths. To acheive this end, the last two arg-
!       uments, RADROT and VARCANG, should be specified.  RADROT allows the user to
!       choose the radius at which the most square elements may be created.  This
!       is done to 'average out' the effect of volume element stretching as a re-
!       sult of volume sweeping through a range of radii at a given arc angle. The
!       arc angle that the volumes were rotated through is specified in VARCANG.
!       By using these arguments, the user can control the element 'stretching' en-
!       countered in a rotated volume, and localize it such that it is minimized
!       throughout. Again, if a selected area (or areas) is attached to more than
!       one volume, the algorithm will sweep both volumes, but the user may specify
!       the desired volume to mesh by specifying the argument, 'VOLSEL'. Each vol-
!       ume that is specified by 'VOLSEL' must be meshed separately using this
!       command.
!
!       In the case where it is desired to know the ELMNL value used in a preceding
!       mesh operation, a parameter, ELLHNDOF (ELement Length HaND-OFf), stores the
!       ELMNL value of the last MSH_ALGORITHM operation. This parameter "hands_off"
!       this value to a future MSH_ALGORITHM operation.  It is used for an ESIZE
!       parameter in a sweep operation if a line is shared by two different vol-
!       umes. If this shared line is already meshed in an area of one volume, and
!       elements are swept along its length in the other volume, this parameter
!       will allow for the elements sized in the area mesh to merge with the ele-
!       ments of the swept volume by keeping the number of elements swept equal to
!       the number of elements sized in the area mesh operation operation.
!
!       ** NOTE:  All mapped meshing should be performed prior to
!                 the free meshing operations. Be sure that you have
!                 a proper selected set prior to execution of this
!                 command or the operation will fail, resulting in
!                 exiting from the ANSYS session.
!
!       Necessary input for execution of this macro:
!
!               ** A selected set of areas and/or volumes
!
!           (1) perflsz = perform line sizing options:
!
!                       0 = do not perform line sizing
!                       1 = perform line sizing (over-ride previous line sizing)
!                       -1 = perform line sizing (DO NOT over-ride previous line
!                            sizing)
!
!           (2) perfmsh = perform mesh options:
!
!                       0 = do not perform meshing operation
!
!                       1 = perform area mesh operation only
!
!                       2 = perform volume mesh operation only (use area
!                           sweeping; i.e., using the VSWEEP command)
!
!                       3 = perform area and volume mesh operations
!                           (using area sweeping; i.e., using the VSWEEP
!                           command)
!
!                       4 = free volume mesh
!
!                       5 = transition mesh
!
!           (3) mstyp = mesh type:
!
!                       0 (or blank) = free mesh
!
!                       1 = map mesh
!
!           (4) mshdens = mesh density.  If the desired mesh density is coarse or
!                         fine, then this parameter will create the desired mesh.
!                         This will allow the line sizing algorithm to size all the
!                         lines that are less than or equal to 2.5 times the min-
!                         imum element edge length, ELMNL. This will aid in keeping
!                         element aspect ratios to reasonable values when the de-
!                         sired minimum element edge length, ELMNL, is more than 3
!                         times the smallest line. (e.g., for stress analysis, the
!                         desired mesh density is fine; and for dynamic analysis,
!                         the desired mesh density is coarse).
!
!                               0 (or blank) = fine mesh density
!
!                               1 = coarse mesh density
!
!                               n = user defined divisions for all lines less
!                                   than or equal to 3.0*ELMNL.
!
!                         If MSHDENS is assigned any numerical value (n) other
!                         than 0 or 1, then any line that is less than or equal
!                         to 3 timesELMNL is sized that numerical value line
!                         divisions.
!
!           (5) elmszovr = element sizing over-ride parameter. In volume sweeping
!                          operations (PERFMSH=2 and PERFMSH=3), the number of
!                          elements swept in a volume length is normally calcu-
!                          lated by the algorithm based on an optimum element as-
!                          pect ratio approximately equal to 1. However, if a
!                          desired number of elements is specified in this par-
!                          ameter, then this value will over-ride the calculated
!                          value and sweep this number of elements.
!
!                          If ELMSZVOR is a negative number, then the algorithm
!                          will sweep the volume a number of elements with a user
!                          specified aspect ratio (the numerical value of ELMSZVOR)
!                          that are able to be fit along the volume sweep length.
!                          (e.g., if ELMSZVOR = -3, then the elements along the
!                          sweep length will be 3 times longer than ELMNL)
!
!           (6) atargov = area target over-ride parameter.  In the case where the
!                         source and target areas of the VSWEEP operation share a
!                         common keypoint(s), the algorithm will fail and the area
!                         target must be specified by the user.  Specifying the
!                         target area, ATARGOV, will over-ride the target selec-
!                         tion algorithm and sweep the volume in question from the
!                         selected mesh area to the target area, ATARGOV.  When
!                         using this option, VOLSEL must be specified; i.e., the
!                         volume that is to be swept must be specified by VOLSEL.
!
!           (7) etpa = element type to be used for area meshing
!
!           (8) etpv = element type to be used for volume meshing
!
!           (9) elmnl = element minimum edge length
!
!          (10) elmxl = element maximum edge length
!
!          (11) mtrl = material properties # to be used in meshing operations
!
!          (12) rl = real constant set #, if applicable
!
!          (13) ecs = coordinate system # for associated elements (element
!                     coordinate systems)
!
!          (14) volsel = If the selected area(s) for meshing are attached to more
!                        than one volume, the desired volume for meshing is speci-
!                        fied in this parameter.  In this case, each volume will
!                        have to be meshed separately with the MSH_ALGORITHM
!                        command.
!
!          (15) radrot = user specified radius of rotation at which the number of
!                        elements, swept through a known volume arc angle, VARCANG,
!                        may be calculated. This parameter is specified when sweep-
!                        ing a rotated volume, and allows for control of the number
!                        of elements in an arc angle.
!
!          (16) varcang = volume arc angle of a rotated volume(s)
!
!          (17) ell = element longitudinal length.  This parameter specifies the
!                     element edge length used to calculate the number of elements
!                     swept along the length of a rotated volume.  This may be used
!                     in adjoining rotated volumes with different element edge
!                     lengths specified in their meshes.  This allows for all
!                     volumes to have the same number of swept elements, allowing
!                     their meshes to interface.  This is only valid when RADROT
!                     and VARCANG are specified.
!
!
!--------------------------------- COMMAND SYNTAX -------------------------------
!
!                  (1)      (2)     (3)     (4)      (5)       (6)     (7)   (8)
! MSH_ALGORITHM, perflsz, perfmsh, mstyp, mshdens, elmszovr, atargov, etpa, etpv,
!
!                elmnl, elmxl, mtrl,  rl,  ecs, volsel, radrot, varcang, ell
!                 (9)    (10)  (11)  (12)  (13)  (14)    (15)    (16)    (17)
!
!--------------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

perflsz=arg1
perfmsh=arg2
mstyp=arg3
mshdens=arg4
elmszovr=arg5
atargov=arg6
etpa=arg7
etpv=arg8
elmnl=arg9
elmxl=ar10
mtrl=ar11
rl=ar12
ecs=ar13
volsel=ar14
radrot=ar15
varcang=ar16
ell_=ar17
!
!
esize,,1                    ! set element size default
!
*if,mshdens,eq,1,then
     nelm_1=1
     nelm_2=1
     mshfctr=2.75           ! meshing factor
*elseif,mshdens,eq,0,then
     nelm_1=2
     nelm_2=3
     mshfctr=2.5
*else
     nelm_1=mshdens
     nelm_2=mshdens
     mshfctr=3.0
*endif
!
!
*if,varcang,ne,0,then
    *if,radrot,ne,0,then
        *if,ell_,ne,0,then
            _sarc=radrot*(pi/2)
            _nelm90=nint(_sarc/ell_)
            _nelmrot=nint(varcang/(90/_nelm90))
        *else
            _sarc=radrot*(pi/2)
            _nelm90=nint(_sarc/elmnl)
            _nelmrot=nint(varcang/(90/_nelm90))
        *endif
    *endif
*endif
!
!
*if,perfmsh,eq,1,then
    !
    _astrchk=1              ! area storage check parameter
    _amchk=1                ! area mesh check parameter
    _vmschk=0               ! volume mesh by sweep check parameter
    _vmfchk=0               ! volume mesh by free-mesh check parameter
    _vmtchk=0               ! volume mesh by transition-mesh check parameter
    !
    cm,mshaset,area
    !
*elseif,perfmsh,eq,2,then
    !
    perflsz=0
    _astrchk=1
    _amchk=0
    _vmschk=1
    _vmfchk=0
    _vmtchk=0
    !
    cm,mshaset,area
    !
*elseif,perfmsh,eq,3,then
    !
    _astrchk=1
    _amchk=1
    _vmschk=1
    _vmfchk=0
    _vmtchk=0
    !
    cm,mshaset,area
    !
*elseif,perfmsh,eq,4,then
    !
    *if,perflsz,ne,0,then
        *if,perflsz,eq,1,then
            perflsz=0
            lresize_=1
        *elseif,perflsz,eq,-1,then
            perflsz=0
            lresize_=0
        *endif
    *else
        lresize_=1
    *endif
    !
    _vmfchk=1
    _amchk=0
    _astrchk=0
    _vmschk=0
    _vmtchk=0
    cm,mshvset,volu
    !
*elseif,perfmsh,eq,5,then
    !
    *if,perflsz,ne,0,then
        *if,perflsz,eq,1,then
            perflsz=0
            lresize_=1
        *elseif,perflsz,eq,-1,then
            perflsz=0
            lresize_=0
        *endif
    *else
        lresize_=1
    *endif
    !
    _vmtchk=1
    _amchk=0
    _astrchk=0
    _vmschk=0
    _vmfchk=0
    cm,mshvset,volu
    !
*elseif,perfmsh,eq,0,then
    !
    *if,perflsz,eq,0,then
        perflsz=1
    *endif
    !
    _astrchk=1
    _amchk=0
    _vmschk=0
    _vmfchk=0
    _vmtchk=0
    cm,mshaset,area
    !
*endif
!
!
*if,perflsz,eq,0,then
    _slchk=0
*else
    *if,perflsz,eq,1,then
        lresize_=1                  ! resize lines check parameter
    *elseif,perflsz,eq,-1,then
        lresize_=0
    *endif
    !
    _slchk=1                        ! size lines check parameter
    !
    *if,mstyp,eq,0,then
        _slfchk=1                   ! size line by free-mesh check parameter
        _slmchk=0                   ! size line by map-mesh check parameter
    *elseif,mstyp,eq,1,then
        _slfchk=0
        _slmchk=1
    *endif
*endif
!
!
*if,_astrchk,eq,1,then           ! create mesh-area array
!
!---------------------- A.  Create Array Storing Areas ---------------------
!
!
*get,_amin,area,,num,min        ! retrieve MINIMUM area number
!
*get,acount,area,,count         ! # of specified areas in the selected set
!
*dim,msha,array,acount          ! store mesh areas in an array, 'msha'
!
*do,ii,1,acount,1
    *if,ii,eq,1,then
        msha(ii,1)=_amin
    *else
        jj=ii-1
        *get,xxx,area,msha(jj,1),nxth
        msha(ii,1)=xxx
    *endif
*enddo
!
!
!-------------------------------------------------------------------------------
!
*endif                      ! (_astrchk)
!
!
!
*if,_slchk,eq,1,then        ! size lines algorithm
!
*if,_slfchk,eq,1,then
!
!------------------- B.  Size Lines On Each Area (Free Mesh) -------------------
!
!
*do,ii,1,acount,1
    !
    asel,s,area,,msha(ii,1)
    lsla,s
    !
    *get,_lmin,line,,num,min        ! retrieve MINIMUM line numbers
    !
    *get,lcount,line,,count         ! # of specified lines in selected area
    !
    *dim,lsiz,array,lcount          ! store area lines in array, 'lsiz'
    !
    *do,jj,1,lcount,1
        *if,jj,eq,1,then
            lsiz(jj,1)=_lmin
        *else
            kk=jj-1
            *get,xxx,line,lsiz(kk,1),nxth
            lsiz(jj,1)=xxx
        *endif
    *enddo
    !
    *do,jj,1,lcount,1
        !
        *get,lleng,line,lsiz(jj,1),leng
        !
        *if,lleng,le,2.0*elmnl,then
            nelm=nelm_1
        *elseif,lleng,le,mshfctr*elmnl,then
            nelm=nelm_2
        *else
            nelm=nint(lleng/elmnl)
        *endif
        !
        *get,lszchk_,line,lsiz(jj,1),attr,ndnx
        !
        *if,lszchk_,eq,0,then
            lesize,lsiz(jj,1),,,nelm,1,
        *else
            *if,lresize_,eq,1,then
                lesize,lsiz(jj,1),,,nelm,1,
            *endif
        *endif
    *enddo
    !
    *set,lsiz(1),
*enddo
!
!
!---------------------------------------------------------------------------
!
*endif          ! (_slfchk)
!
!
!
*if,_slmchk,eq,1,then
!
!------------------- C.  Size Lines On Each Area (Map Mesh) -------------------
!
!
*do,mm,1,acount,1
    !
    asel,s,area,,msha(mm,1)
    lsla,s
    !
    max_e_dim_array,'l','lsiz','array'   ! Store lines of area in array and
    !                                    ! retrieve minimum length and index.
    hi_hld=lsizc(max_indx,1)        ! Switch minimum value index position to
    hi_lin=lsiz(max_indx,1)         ! 1st position.
    !
    frst_hld=lsizc(1,1)
    frst_lin=lsiz(1,1)
    !
    lsizc(1,1)=hi_hld
    lsiz(1,1)=hi_lin
    !
    lsizc(max_indx,1)=frst_hld
    lsiz(max_indx,1)=frst_lin
    !
    *do,jj,1,2,1
        *if,jj,eq,1,then
            *if,lsizc(jj,1),le,2.0*elmnl,then
                nelm=nelm_1
            *elseif,lsizc(jj,1),le,mshfctr*elmnl,then
                nelm=nelm_2
            *else
                nelm=nint(lsizc(jj,1)/elmnl)
            *endif
            !
            lesize,lsiz(jj,1),,,nelm,1,
        *else
            *if,opp_side,eq,2,then
                opp_hld=lsizc(opp_side,1)
                opp_lin=lsiz(opp_side,1)
                !
                thrd_hld=lsizc(3,1)
                thrd_lin=lsiz(3,1)
                !
                lsizc(opp_side,1)=thrd_hld
                lsiz(opp_side,1)=thrd_lin
                !
                lsizc(3,1)=opp_hld
                lsiz(3,1)=opp_lin
            *endif
            !
            *if,lsizc(jj,1),le,2.0*elmnl,then
                nelm=nelm_1
            *elseif,lsizc(jj,1),le,mshfctr*elmnl,then
                nelm=nelm_2
            *else
                nelm=nint(lsizc(jj,1)/elmnl)
            *endif
            !
            lesize,lsiz(jj,1),,,nelm,1,
        *endif
        !
        *do,kk,jj,4,1
            *if,kk,eq,jj,then
                *get,k1,line,lsiz(kk,1),kp,1
                *get,k2,line,lsiz(kk,1),kp,2
            *endif
            !
            *if,kk,ne,jj,then
                *get,k%kk+1%,line,lsiz(kk,1),kp,1
                *get,k%kk+2%,line,lsiz(kk,1),kp,2
                !
                *if,k%kk+1%,ne,k1,then
                   *if,k%kk+1%,ne,k2,then
                      *if,k%kk+2%,ne,k1,then
                         *if,k%kk+2%,ne,k2,then
                                lesize,lsiz(kk,1),,,nelm,1,
                                opp_side=kk
                         *endif
                      *endif
                   *endif
                *endif
            *endif
        *enddo
    *enddo
    !
    *set,lsizc(1),
    *set,lsiz(1),
*enddo
!
!
!---------------------------------------------------------------------------
!
*endif          ! (_slmchk)
!
*endif          ! (_slchk)
!
!
!
*if,_amchk,eq,1,then
!
!-------------------- D.  Area Mesh Operation (perfmsh=1) ------------------
!
!
asel,s,area,,mshaset
!
desize,,,,,,elmnl,elmxl,
!
aatt,mtrl,rl,etpa,ecs
!
mshkey,mstyp
!
amesh,all
!
!
!---------------------------------------------------------------------------
!
*endif          ! (_amchk)
!
!
!
*if,_vmschk,eq,1,then
!
!------------------ E.  Volume Mesh Operation (perfmsh=3) ------------------
!
!
asel,s,area,,mshaset            ! select all areas to be meshed and swept
!
*do,im,1,acount,1
    !
    asel,s,area,,msha(im,1)     ! select each area to be meshed and swept
    vsla,s                      ! select volume(s) attached to area
    !
    *if,volsel,ne,0,then        ! reselect volume to be swept, if more than 1
        vsel,r,volu,,volsel
    *endif
    !
    *if,atargov,eq,0,then
        !
        entity_array,'v','vmsh_set','array' ! create array of volumes to be swept
            v_count=ecount                  ! retrieve volume count
            !
        *do,jm,1,v_count,1
            !
            vsel,s,volu,,vmsh_set(jm,1)     ! select volume
            aslv,s                          ! select all areas attached to volume
            !
            entity_array,'a','v_aset','array'   ! store all areas in an array
                a_count=ecount                  ! retrieve area count
                !
            *do,jjjj,1,a_count,1            ! transpose mesh area to 1st position
                !
                *if,v_aset(jjjj,1),eq,msha(im,1),then
                    *if,jjjj,eq,1,then
                        *exit
                    *else
                        a_hold=v_aset(1,1)
                        v_aset(1,1)=msha(im,1)
                        v_aset(jjjj,1)=a_hold
                        *exit
                    *endif
                *endif
            *enddo
            !
            *do,jjjj,1,a_count,1
                !
                asel,s,area,,v_aset(jjjj,1)     ! select each individual area
                lsla,s
                !
                entity_array,'l','a_lset%jjjj%','array' ! store lines in an array
                    l_cnt%jjjj%=ecount                  ! retrieve line count
            *enddo
            !
            !------------------------ Comparison Routine ----------------------
            !
            *do,jjjj,2,a_count,1        ! from array '2' to array 'a_count'
                !
                *do,kkkk,1,l_cnt1,1     ! from element '1' of 1st to 'l_cnt1'
                    !
                    *do,llll,1,l_cnt%jjjj%,1    ! from element '1' to 'l_cntN'
                        !
                        *if,a_lset%jjjj%(llll,1),eq,a_lset1(kkkk,1),then
                            !
                            exchk=1    ! do-loop exit check parameter
                            *exit
                        *else
                            *if,(kkkk*llll),eq,(l_cnt1*l_cnt%jjjj%),then
                                atarg=v_aset(jjjj,1)
                                targindx=jjjj
                                exchk=-1
                            *endif
                        *endif
                    *enddo
                    !
                    *if,exchk,eq,1,then
                        *set,exchk,
                        *exit
                    *endif
                *enddo
                !
                *if,exchk,eq,-1,then
                    *set,exchk,
                    *exit
                *endif
            *enddo
            !
            !------------------------------------------------------------------
            !
            vsel,s,volu,,vmsh_set(jm,1)     ! select all lines of mesh volume
            aslv,s
            lsla,s
            cm,v_lset,line
            !
            *do,ijk,1,l_cnt1,1              ! unselect lines of mesh area
                lsel,u,line,,a_lset1(ijk,1)
            *enddo
            !
            *do,ijk,1,l_cnt%targindx%,1     ! unselect lines of target area
                lsel,u,line,,a_lset%targindx%(ijk,1)
            *enddo
            !
            max_enty_dim,'l'            ! retrieve max length of remaining lines
            !
            *if,max_leng,le,2.0*elmnl,then      ! size lines for extrusion
                 nelm=nelm_1
            *elseif,max_leng,le,mshfctr*elmnl,then
                 nelm=nelm_2
            *else
                 nelm=nint(max_leng/elmnl)
            *endif
            !
            *if,varcang,ne,0,then       ! If radius of rotation & volume arc
                *if,radrot,ne,0,then    ! angle are specified, then size
                    esize,,_nelmrot     ! according to rotation arc length.
                *endif
            *else
                esize,,nelm             ! Otherwise, use calculated number
            *endif                      ! for extrusion.
            !
            *if,elmszovr,ne,0,then      ! If number of elements in extrusion
                *if,elmszovr,gt,0,then  ! is specified (over-ride calculated),
                    esize,,elmszovr     ! then use 'elmszovr' for extrusion.
                *elseif,elmszovr,lt,0,then  ! If 'elmszovr' is negative, then
                                        ! calculate the number of elements in
                                        ! the line that will give you an aspect
                                        ! ratio equal to the absolute value of
                                        ! 'elmszovr'.
                    nelm=nint(max_leng/((abs(elmszovr))*elmnl))
                    esize,,nelm
                *endif
            *endif
            !
            type,etpv
            mat,mtrl
            !
            vsweep,vmsh_set(jm,1),msha(im,1),atarg,0    ! sweep volume
            !
            *if,jm,eq,v_count,then      ! reset volume array if last volume
                *set,vmsh_set(1),
            *endif
            !
            *do,ijk,1,a_count,1         ! reset area-lines array
                *set,a_lset%ijk%(1),
            *enddo
            !
            *set,v_aset(1),             ! reset volume-areas array
        *enddo
    *else
        atarg=atargov
        !
        vsel,s,volu,,volsel
        aslv,s
        lsla,s
        !
        asel,s,area,,msha(im,1)
        asel,a,area,,atarg
        lsla,u
        !
        max_enty_dim,'l'            ! retrieve max length of remaining lines
        !
        *if,max_leng,le,2.0*elmnl,then      ! size lines for extrusion
             nelm=nelm_1
        *elseif,max_leng,le,mshfctr*elmnl,then
             nelm=nelm_2
        *else
             nelm=nint(max_leng/elmnl)
        *endif
        !
        *if,varcang,ne,0,then       ! If radius of rotation & volume arc
            *if,radrot,ne,0,then    ! angle are specified, then size
                esize,,_nelmrot      ! according to rotation arc length.
            *endif
        *else
            esize,,nelm             ! Otherwise, use calculated number
        *endif                      ! for extrusion.
        !
        *if,elmszovr,ne,0,then      ! If number of elements in extrusion
            *if,elmszovr,gt,0,then  ! is specified (over-ride calculated),
                esize,,elmszovr     ! then use 'elmszovr' for extrusion.
            *elseif,elmszovr,lt,0,then  ! If 'elmszovr' is negative, then
                                        ! calculate the number of elements in
                                        ! the line that will give you an aspect
                                        ! ratio equal to the absolute value of
                                        ! 'elmszovr'.
                nelm=nint(max_leng/((abs(elmszovr))*elmnl))
                esize,,nelm
            *endif
        *endif
        !
        type,etpv
        mat,mtrl
        !
        vsweep,volsel,msha(im,1),atarg,0    ! sweep volume
    *endif
*enddo
!
*if,_amchk,eq,1,then
    *do,im_,1,acount,1
        asel,s,area,,msha(im_,1)
        aclear,all
    *enddo
*endif
!
!---------------------------------------------------------------------------
!
*endif          ! (_vmschk)
!
!
!
*if,_vmfchk,eq,1,then
!
!---------------- F.  Volume Free Mesh Operation (perfmsh=4) ---------------
!
!
vsel,s,volu,,mshvset
aslv,s
!
*get,_amin,area,,num,min        ! retrieve MINIMUM area number
!
*get,acount,area,,count         ! # of specified areas in the selected set
!
*dim,msha,array,acount          ! store mesh areas in an array, 'msha'
!
*do,ii,1,acount,1
    *if,ii,eq,1,then
        msha(ii,1)=_amin
    *else
        jj=ii-1
        *get,xxx,area,msha(jj,1),nxth
        msha(ii,1)=xxx
    *endif
*enddo
!
*do,ii,1,acount,1
    !
    asel,s,area,,msha(ii,1)
    lsla,s
    !
    *get,_lmin,line,,num,min        ! retrieve MINIMUM line numbers
    !
    *get,lcount,line,,count         ! # of specified lines in selected area
    !
    *dim,lsiz,array,lcount          ! store area lines in array, 'lsiz'
    !
    *do,jj,1,lcount,1
        *if,jj,eq,1,then
            lsiz(jj,1)=_lmin
        *else
            kk=jj-1
            *get,xxx,line,lsiz(kk,1),nxth
            lsiz(jj,1)=xxx
        *endif
    *enddo
    !
    *do,jj,1,lcount,1
        !
        *get,lleng,line,lsiz(jj,1),leng
        !
        *if,lleng,le,2.0*elmnl,then
                nelm=nelm_1
        *elseif,lleng,le,mshfctr*elmnl,then
                nelm=nelm_2
        *else
                nelm=nint(lleng/elmnl)
        *endif
        !
        *get,lszchk_,line,lsiz(jj,1),attr,ndnx
        !
        *if,lszchk_,eq,0,then
            lesize,lsiz(jj,1),,,nelm,1,
        *else
            *if,lresize_,eq,1,then
                lesize,lsiz(jj,1),,,nelm,1,
            *endif
        *endif
    *enddo
    !
    *set,lsiz(1),
*enddo
!
desize,,,,,,elmnl,elmxl,
!
vatt,mtrl,rl,etpv,ecs
!
mshkey,0
!
vmesh,all
!
!---------------------------------------------------------------------------
!
*endif          ! (_vmfchk)
!
!
!
*if,_vmtchk,eq,1,then
!
!------------ G.  Volume Transition Mesh Operation (perfmsh=5) -------------
!
!
vsel,s,volu,,mshvset
aslv,s
!
*get,_amin,area,,num,min        ! retrieve MINIMUM area number
!
*get,acount,area,,count         ! # of specified areas in the selected set
!
*dim,msha,array,acount          ! store mesh areas in an array, 'msha'
!
*do,ii,1,acount,1
    *if,ii,eq,1,then
        msha(ii,1)=_amin
    *else
        jj=ii-1
        *get,xxx,area,msha(jj,1),nxth
        msha(ii,1)=xxx
    *endif
*enddo
!
*do,ii,1,acount,1
    !
    asel,s,area,,msha(ii,1)
    lsla,s
    !
    *get,_lmin,line,,num,min        ! retrieve MINIMUM line numbers
    !
    *get,lcount,line,,count         ! # of specified lines in selected area
    !
    *dim,lsiz,array,lcount          ! store area lines in array, 'lsiz'
    !
    *do,jj,1,lcount,1
        *if,jj,eq,1,then
            lsiz(jj,1)=_lmin
        *else
            kk=jj-1
            *get,xxx,line,lsiz(kk,1),nxth
            lsiz(jj,1)=xxx
        *endif
    *enddo
    !
    *do,jj,1,lcount,1
        !
        *get,lleng,line,lsiz(jj,1),leng
        !
        *if,lleng,le,2.0*elmnl,then
                nelm=nelm_1
        *elseif,lleng,le,2.5*elmnl,then
                nelm=nelm_2
        *else
                nelm=nint(lleng/elmnl)
        *endif
        !
        *get,lszchk_,line,lsiz(jj,1),attr,ndnx
        !
        *if,lszchk_,eq,0,then
            lesize,lsiz(jj,1),,,nelm,1,
        *else
            *if,lresize_,eq,1,then
                lesize,lsiz(jj,1),,,nelm,1,
            *endif
        *endif
    *enddo
    !
    *set,lsiz(1),
*enddo
!
desize,,,,,,elmnl,elmxl,
!
vatt,mtrl,rl,etpv,ecs
!
mopt,pyra,on
mshape,1,3d
mshkey,0
!
vmesh,all
!
mopt,defa
mshape,0
!
!---------------------------------------------------------------------------
!
*endif          ! (_vmtchk)
!
!
init_entity_num
!
ellhndof=elmnl              ! element length hand-off variable
elszohof=abs(elmszovr)      ! element size overide hand-off variable
!
lplot
!
!
*do,ii_,1,100,1
    *set,l_cnt%ii_%,
*enddo
!
*set,msha(1),
*set,perflsz,
*set,perfmsh,
*set,mstyp,
*set,etpa,
*set,etpv,
*set,mtrl,
*set,rl,
*set,ecs,
*set,ell_,
*set,volsel,
*set,atargov,
*set,vmax,
*set,vmin,
*set,_amin,
*set,opp_hld,
*set,opp_lin,
*set,thrd_hld,
*set,thrd_lin,
*set,hi_hld,
*set,hi_lin,
*set,frst_hld,
*set,frst_lin,
*set,opp_side,
*set,ii_,
*set,ecount,
*set,v_count,
*set,acount,
*set,a_count,
*set,radrot,
*set,varcang,
*set,_nelmrot,
*set,elmszovr,
*set,mshdens,
*set,nelm_1,
*set,nelm_2,
*set,mshfctr,
*set,xxx,
*set,lleng,
*set,elmnl,
*set,elmxl,
*set,lcount,
*set,_lmin,
*set,targindx,
*set,max_indx,
*set,max_leng,
*set,max_lnum,
*set,_sarc,
*set,_vmschk,
*set,_astrchk,
*set,_amchk,
*set,_slchk,
*set,_vmtchk,
*set,_vmfchk,
*set,_slfchk,
*set,_slmchk,
*set,ii,
*set,im,
*set,im_,
*set,llll,
*set,jjjj,
*set,kkkk,
*set,lszchk_,
*set,lresize_,
cmdele,mshaset,
cmdele,mshvset,


w:\ansys\mac\tools\msh_standrd.mac.html

!   TITLE:  msh_standrd.mac (MESH)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED        02/01/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is a standard (simplified) version of mesh algorithm for
!   simply meshing volumes with a sweep operation.
!
!
!   COMMAND SYNTAX:
!
!                       (1)     (2)     (3)      (4)      (5)  (6)   (7)
!        MSH_STANDRD, perfmsh, mstyp, mshdens, elmszovr, etpa, etpv, elmnl,
!
!                     elmxl, mat, real, perflsz
!                      (8)   (9)  (10)   (11)
!
!
!   ARGUMENTS:
!
!   The defaults are:
!
!               a.)  perform line sizing (PERFLSZ=1)
!               b.)  material type 1 (MTRL=1)
!               c.)  no specified real constant set (RL not specified)
!
!   This macro is used when the following MSH_ALGORITHM arguments need not be
!   specified:
!
!               a.) ECS:
!                       default element coordinate system is used
!
!               b.) VOLSEL:
!                       volumes DO NOT have to be specified for areas
!                       attached to more than 1 volume
!
!               c.) ATARGOV:
!                       target areas DO NOT have to be specified
!
!               d.) RADROT, VARCANG, ELL:
!                       where radii of rotation, volume arc angles and/or
!                       element longitudinal lengths DO NOT have to be
!                       specified
!
!
!   Therefore, the only arguments necessary for a basic execution of
!   MSH_ALGORITHM are:
!
!       (1) perfmsh = perform mesh options:
!
!             * 1 = perform area mesh operation only
!
!                 * NOTE: If specifying this option, this macro need not be
!                         used.  MSH_AREA is a further simplified version of
!                         MSH_ALGORITHM for the explicit purpose of area-meshing
!                         only.
!
!               2 = perform volume mesh operation only (use area
!                   sweeping; i.e., using the VSWEEP command)
!
!               3 = perform area and volume mesh operations
!                   (using area sweeping; i.e., using the VSWEEP
!                   command)
!
!               4 = free volume mesh
!
!               5 = transition mesh
!
!       (2) mstyp = mesh type:
!
!               0 (or blank) = free mesh
!
!               1 = map mesh
!
!       (3) mshdens = mesh density.  If the desired mesh density is coarse or
!                     fine, then this parameter will create the desired mesh.
!                     This will allow the line sizing algorithm to size all the
!                     lines that are less than or equal to 2.5 times the min-
!                     imum element edge length, ELMNL. This will aid in keeping
!                     element aspect ratios to reasonable values when the de-
!                     sired minimum element edge length, ELMNL, is more than 3
!                     times the smallest line. (e.g., for stress analysis, the
!                     desired mesh density is fine; and for dynamic analysis,
!                     the desired mesh density is coarse).
!
!                           0 (or blank) = fine mesh density
!
!                           1 = coarse mesh density
!
!                           n = user defined divisions for all lines less
!                               than or equal to 3.0*ELMNL.
!
!                     If MSHDENS is assigned any numerical value (n) other
!                     than 0 or 1, then any line that is less than or equal
!                     to 3 timesELMNL is sized that numerical value line
!                     divisions.
!
!       (4) elmszovr = element sizing over-ride parameter. In volume sweeping
!                      operations (PERFMSH=2 and PERFMSH=3), the number of
!                      elements swept in a volume length is normally calcu-
!                      lated by the algorithm based on an optimum element as-
!                      pect ratio approximately equal to 1. However, if a
!                      desired number of elements is specified in this par-
!                      ameter, then this value will over-ride the calculated
!                      value and sweep this number of elements.
!
!                      If ELMSZVOR is a negative number, then the algorithm
!                      will sweep the volume a number of elements with a user
!                      specified aspect ratio (the numerical value of ELMSZVOR)
!                      that are able to be fit along the volume sweep length.
!                      (e.g., if ELMSZVOR = -3, then the elements along the
!                      sweep length will be 3 times longer than ELMNL)
!
!       (5) etpa = element type to be used for area meshing
!
!       (6) etpv = element type to be used for volume meshing
!
!       (7) elmnl = element minimum edge length
!
!       (8) elmxl = element maximum edge length
!
!       *** (9) mat = material properties # to be used in meshing operations.
!                     If left blank, defaults to 1.
!
!       *** (10) real = real constant set #, if applicable.
!
!       *** (11) perflsz = perform line sizing option:
!
!                       0 = do not perform line sizing
!                       1 = perform line sizing (default)
!                       -1 = perform line sizing (DO NOT over-ride previous
!                            line sizing)
!
!
!       *** NOTE: Arguments 9, 10 and 11 are all defaults as listed above.
!                 Therefore, if using these defaults, then these arguments
!                 may be left blank. That is the purpose for placing these
!                 at the end of the argument list. Otherwise, they may be
!                 specified as needed.
!
!   See MSH_ALGORITHM documentation for an in-depth explanation of its use.
!
!
!   DESCRIPTION:
!
!   This macro may be used to execute MSH_ALGORITHM under the more common set
!   of circumstances encountered in a majority of volume meshing operations. Its
!   use will alleviate the cumbersome task of choosing the arguments to use or
!   specify in MSH_ALGORITHM when meshing volumes in models where most arguments
!   are not commonly used. Therefore, this macro may be used for simple volume
!   mesh operations implementing a simple linear sweep, i.e., no arced volumes,
!   where the source and target areas of the VSWEEP operation do not share any
!   common keypoint(s), and no specifying of element coordinate systems to mesh
!   within.
!
!
!--------------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

pfmsh_=arg1
mtyp_=arg2
mdens_=arg3
eszovr_=arg4
etypa_=arg5
etypv_=arg6
mnl_=arg7
mxl_=arg8
mat_=arg9
rlcs_=ar10
lsiz_=ar11
!
!
*if,mat_,eq,0,then
    mat_=1
*endif
!
*if,lsiz_,eq,0,then
    lsiz_=1
*endif
!
msh_algorithm,lsiz_,pfmsh_,mtyp_,mdens_,eszovr_,,etypa_,etypv_,mnl_,mxl_,mat_,rlcs_
!
!
*set,pfmsh_,
*set,mtyp_,
*set,etypa_,
*set,etypv_,
*set,eszovr_,
*set,mdens_,
*set,mnl_,
*set,mxl_,
*set,mat_,
*set,rlcs_,
*set,lsiz_,


w:\ansys\mac\tools\msh_area.mac.html

!   TITLE:  msh_area.mac (MESH)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED        02/01/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is a standard (simplified) version of mesh algorithm for
!   area meshing.
!
!
!   COMMAND SYNTAX:
!
!                  (1)     (2)     (3)   (4)    (5)    (6)    (7)  (8)   (9)
!       MSH_AREA, mstyp, mshdens, etpa, elmnl, elmxl, lszmsh, mat, real, ecs
!
!
!   ARGUMENTS:
!
!       (1) mstyp = mesh type:
!
!               0 (or blank) = free mesh
!
!               1 = map mesh
!
!       (2) mshdens = mesh density.  If the desired mesh density is coarse or
!                     fine, then this parameter will create the desired mesh.
!                     This will allow the line sizing algorithm to size all the
!                     lines that are less than or equal to 2.5 times the min-
!                     imum element edge length, ELMNL. This will aid in keeping
!                     element aspect ratios to reasonable values when the de-
!                     sired minimum element edge length, ELMNL, is more than 3
!                     times the smallest line. (e.g., for stress analysis, the
!                     desired mesh density is fine; and for dynamic analysis,
!                     the desired mesh density is coarse).
!
!                           0 (or blank) = fine mesh density
!
!                           1 = coarse mesh density
!
!                           n = user defined divisions for all lines less
!                               than or equal to 3.0*ELMNL.
!
!                     If MSHDENS is assigned any numerical value (n) other
!                     than 0 or 1, then any line that is less than or equal
!                     to 3 timesELMNL is sized that numerical value line
!                     divisions.
!
!       (3) etpa = element type to be used for area meshing
!
!       (4) elmnl = element minimum edge length
!
!       (5) elmxl = element maximum edge length
!
!       *** (6) lszmsh = Options for line sizing and performing mesh operation:
!
!               - When it is desired to resize the previously sized lines:
!
!         (default) 1 (or blank) = perform line sizing and mesh operation(s)
!                   2 = perform line sizing, DO NOT mesh
!
!               - When it is desired to NOT resize the previously sized lines:
!
!                   -1 = perform line sizing and mesh operation(s)
!                   -2 = perform line sizing, DO NOT mesh
!
!                   3 = DO NOT perform line sizing, perform mesh operation
!
!
!       *** (7) mat = material properties # to be used in meshing operations.
!                     If left blank (defaults to 1).
!
!       *** (8) real = real constant set #, if applicable.
!
!       *** (9) ecs = coordinate system # for associated elements (element
!                     coordinate systems) (defaults to global cartesian)
!
!       *** NOTE: Arguments 6, 7, 8 and 9 are all defaults as listed above.
!                 Therefore, if using these defaults, then these arguments
!                 may be left blank. Otherwise, they may be specified as needed.
!
!       See MSH_ALGORITHM documentation for an in-depth explanation of their use.
!
!   DESCRIPTION:
!
!   The purpose of this sub_macro is to execute MSH_ALGORITHM under the simpler
!   set of circumstances most commonly encountered in area meshing operations
!   only. Its use will alleviate the cumbersome task of deciphering all the
!   arguments to use or specify in MSH_ALGORITHM when meshing only areas, where
!   most arguments are not used.
!
!   The defaults are:
!
!               a.)  perform line sizing and area meshing (LSZMSH=1)
!               b.)  material type 1 (MTRL=1)
!               c.)  no specified real constant set (REAL not specified)
!               d.)  default element coordinate system (ECS=0)
!
!   This macro is used when the following MSH_ALGORITHM arguments NEED NOT be
!   specified:
!
!         a.) PERFMSH:
!                 perform mesh is already set to 1 (PERFMSH=1), area meshing
!                 only
!
!         b.) ELMSZOVR:
!                 no element size over-ride since no volume sweeping
!
!         c.) ETPV:
!                 no volume meshing
!
!         d.) VOLSEL:
!                 volumes DO NOT have to be specified since no volume sweeping
!
!         e.) ATARGOV:
!                 target areas DO NOT have to be specified since no volume
!                 sweeping
!
!         f.) RADROT, VARCANG, ELL:
!                 where radii of rotation, volume arc angles and/or element
!                 element longitudinal lengths DO NOT have to be specified
!                 since no volume sweeping
!
!         g.) SPRAT:
!                 elements of constant spacing ratio are used
!
!
!--------------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

mtyp_=arg1
mdens_=arg2
etypa_=arg3
mnl_=arg4
mxl_=arg5
lszmsh_=arg6
matl_=arg7
rlcs_=arg8
elcs_=arg9
!
!
*if,matl_,eq,0,then
    matl_=1
*endif
!
*if,lszmsh_,eq,0,then
    lsiz_=1
    pfmsh_=1
*elseif,lszmsh_,eq,1,then
    lsiz_=1
    pfmsh_=1
*elseif,lszmsh_,eq,2,then
    lsiz_=1
    pfmsh_=0
*elseif,lszmsh_,eq,3,then
    lsiz_=0
    pfmsh_=1
*elseif,lszmsh_,eq,-1,then
    lsiz_=-1
    pfmsh_=1
*elseif,lszmsh_,eq,-2,then
    lsiz_=-1
    pfmsh_=0
*endif
!
msh_algorithm,lsiz_,pfmsh_,mtyp_,mdens_,,,etypa_,,mnl_,mxl_,matl_,rlcs_,elcs_
!
!
*set,mtyp_,
*set,mdens_,
*set,etypa_,
*set,mnl_,
*set,mxl_,
*set,matl_,
*set,rlcs_,
*set,elcs_,
*set,lsiz_,
*set,pfmsh_,
*set,lszmsh_,


w:\ansys\mac\tools\fan_mesh_algorithm.mac.html

!   TITLE:  fan_mesh_algorithm.mac (MESH)
!
!---------------------------------------------------------------------------
!       Rev -     10/12/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro takes a selected set of rotated volumes, all of which

!
!------------------------ COMMAND SYNTAX / Option 1 ------------------------
!
!                     (1)    (2)    (3)     (4)      (5)     (6)   (7)
! FAN_MESH_ALGORITHM, opt, kp#, mstyp, mshdens, elmszovr, etpa, etpv,
!
!                  elmnl, elmxl, mtrl, rl, ecs, sprat, radrot, varcang
!                   (8)    (9)   (10) (11) (12) (13)    (14)    (15)
!
!--------------------------------- Option 2 --------------------------------
!
!                    (1)    (2)    (3)     (4)      (5)     (6)   (7)
! FAN_MESH_ALGORITHM, opt, ln#, mstyp, mshdens, elmszovr, etpa, etpv,
!
!                  elmnl, elmxl, mtrl, rl, ecs, sprat, radrot, varcang
!                   (8)    (9)   (10) (11) (12) (13)    (14)    (15)
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

!
! option 1 = select by point
!! option 2 = select by line
!
opt_=arg1
!mshdens=arg4
nelm_=arg4
!
!

*go,:skip3      !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

*if,mshdens,eq,1,then
    nelm_1=1
    nelm_2=1
    mshfctr=2.75            ! meshing factor
*elseif,mshdens,eq,0,then
    nelm_1=2
    nelm_2=3
    mshfctr=2.5
*else
    nelm_1=mshdens
    nelm_2=mshdens
    mshfctr=3.0
*endif
!
*do,jj_,1,ecount,1
    !
    *get,lleng,line,lset1_(jj_,1),leng
    !
    *if,lleng,le,2.0*elmnl,then
        nelm=nelm_1
    *elseif,lleng,le,mshfctr*elmnl,then
        nelm=nelm_2
    *else
        nelm=nint(lleng/elmnl)
    *endif
*enddo
!

:skip3          !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

cm,msha_,area
!
lsla,s
cm,lset1_,line
!
*if,opt_,eq,1,then
    !
    ckp_=arg2
    sprat_=arg3
    !
    ksel,s,kp,,ckp_
    lslk,r
    !
    get_max_entity
    l1_=lm
    !
    get_min_entity
    l2_=l_min
    !
    *get,k11_,line,l1_,kp,1          ! retrieve 1st and 2nd kp of line 1
    *get,k12_,line,l1_,kp,2
    !
    *get,k21_,line,l2_,kp,1          ! retrieve 1st and 2nd kp of line 2
    *get,k22_,line,l2_,kp,2
    !
    *if,k11_,eq,k21_,then
        mkp_=k11_
        lesize,l1_,,,nelm_,sprat_,
        lesize,l2_,,,nelm_,sprat_,
    *elseif,k11_,eq,k22_,then
        mkp_=k11_
        lesize,l1_,,,nelm_,sprat_,
        lesize,l2_,,,nelm_,1/sprat_,
    *elseif,k12_,eq,k21_,then
        mkp_=k12_
        lesize,l1_,,,nelm_,1/sprat_,
        lesize,l2_,,,nelm_,sprat_,
    *elseif,k12_,eq,k22_,then
        mkp_=k12_
        lesize,l1_,,,nelm_,1/sprat_,
        lesize,l2_,,,nelm_,1/sprat_,
    *endif
    !

    *go,:skip2      !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    lsel,s,line,,lset1_
    !
    lsel,u,line,,l1_
    lsel,u,line,,l2_
    !

    entity_array,'l',lset1_,'array
    !
    *do,jj_,1,ecount,1
        !
        *get,lleng,line,lset1_(jj_,1),leng
        !
        *if,lleng,le,2.0*elmnl,then
            nelm=nelm_1
        *elseif,lleng,le,mshfctr*elmnl,then
            nelm=nelm_2
        *else
            nelm=nint(lleng/elmnl)
        *endif
        !
        lesize,lset1_(jj_,1),,,nelm,1,
    *enddo
    !
    *set,lset1_(1),

:skip2      !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

*endif
!

*go,:skip       !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

min_e_dim_array,'l',msha_ln_,'array'
!

:skip       !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


w:\ansys\mac\tools\rotate_volm_msh.mac.html

!   TITLE:  rotate_volm_msh.mac (MESH)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      03/20/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     05/09/2001        J. Rinaldi
!
!           Created provision for using ROTASET array for multiple area
!           materials.
!---------------------------------------------------------------------------
!
!
!   OBJECTIVE:
!
!   This sub-macro takes a set of rotated volumes, of any arc length, and
!   volume meshes them.
!
!   COMMAND SYNTAX:
!
!
!                         (1)     (2)     (3)      (4)     (5)   (6)    (7)
!       ROTATE_VOLM_MSH, actcs,  mstyp, mshdens, elmszovr, etpa, etpv, elmnl,
!
!                        elmxl, mtrl,  rl,  ecs,  radrot, varcang, ell
!                         (8)   (9)   (10)  (11)   (12)    (13)    (14)
!
!
!   ARGUMENTS:
!
!           (1) actcs = active coordinate system (need not be cylindrical) whose
!                       Z axis the volumes are rotated about.
!
!           (9) mtrl = material properties # to be used in meshing operations.
!
!                      If multiple areas/materials are desired, then the macro
!                      command CREATE_ROTASET should be executed prior to use
!                      of this macro, and this argument should be specified:
!
!                       mtrl = 'array'
!
!
!   The remaining arguments are the arguments used in MSH_ALGORITHM.  See
!   MSH_ALGORITHM for a description of arguments 2-14.  Note that PERFLSZ,
!   PERFMSH, ATARGOV, and VOLSEL (in MSH_ALGORITHM) have pre-determined
!   values and are not at the discretion of the user.
!
!   DESCRIPTION:
!
!   The algorithm meshes a user selected set of areas as located relative to
!   the Z axis of a user specified C.S., ACTCS.  The Z axis of this C.S. is
!   located at the axis of rotation of the rotated volumes with the Z axis
!   oriented parallel to the axis of rotation. It then sweeps all the rotated
!   volumes in line with these areas, however many volumes and arc angles that
!   they occupy.
!
!   This macro is an extension of the MSH_ALGORITHM , enhancing the user meshing
!   capabilities to the special case of revolved volumes, thereby automating the
!   meshing process for volumes of revolution.  A cylindrical coordinate system
!   oriented as described in the above paragraph is all that is necessary for
!   successful execution.
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

actcs_=arg1
a1_=arg2
b2_=arg3
c3_=arg4
e5_=arg5
f6_=arg6
g7_=arg7
h8_=arg8
i9_=arg9
j0_=ar10
k1_=ar11
n4_=ar12
o5_=ar13
p6_=ar14
!
!
csys,actcs_                             ! active CS
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,1,then                   ! If axis CS is not cylindrical, then
    create_cs,0,'acs_',1,0,0,0,0,0,0    ! create cylindrical CS at same location.
*endif
!
*get,ptyp_,parm,i9_,type
!
*if,ptyp_,eq,0,then
    entity_array,'a','rotaset_','array'     ! create array of selected areas
    alimit_=ecount
*else
    *get,ptyp2_,parm,rotaset,type       ! determine whether ROTASET exists
    *get,alimit_,parm,rotaset,dim,x     ! # of areas (rows) in material array
    alimit_=alimit_-1
    *get,matpos_,parm,rotaset,dim,y     ! # of columns in material array
*endif
!
*do,abc_,1,alimit_,1                    ! iterate through area array
    *do,xyz_,1,3600,1                   ! iterate through all volumes ( < 3600 )
        csys,acs_
        !
        *if,ptyp_,eq,0,then
            *if,xyz_,eq,1,then              ! If volume iteration = 1 then
                asel,s,area,,rotaset_(abc_,1)   ! select area from array
            *else                           ! If volume iteration ~= 1 then
                asel,s,area,,atarg          ! select target area from previous mesh
            *endif
        *else
            *if,i9_,eq,'array',then
                *if,xyz_,eq,1,then              ! If volume iteration = 1 then
                    asel,s,area,,rotaset(abc_,1)    ! select area from array
                *else                           ! If volume iteration ~= 1 then
                    asel,s,area,,atarg      ! select target area from previous mesh
                *endif
            *else
                *exit
            *endif
        *endif
        !
        csys,0                          ! initialize global cartesian system
        asum                            ! retrieve area summary info
        *get,acx_,area,,cent,x          ! retrieve x,y,z coordinates of centroid
        *get,acy_,area,,cent,y
        *get,acz_,area,,cent,z
        k,,acx_,acy_,acz_               ! create KP @ centroid location
        aloctr_=km+1                    ! store KP# in parameter
        csys,acs_                       ! initialize axial CS
        aloc_=ky(aloctr_)               ! angular position with respect to ACS_
        kdele,aloctr_                   ! delete locator KP
        !
        vsla,s                          ! select volume(s) attached to area
        *get,vcnt_,volu,,count          ! count # of volumes attached to area
        !
        *if,xyz_,eq,1,then              ! If volume iteration = 1 then
            *if,vcnt_,gt,1,then             ! If volume count > 1 then
                cm,vset1,volu                   ! store volumes in component group
                vsel,u,loc,y,aloc_,aloc_+180    ! reselect volume in -y direction
                get_max_entity
                vfinal_=vm                      ! store last volume to mesh
                cmsel,s,vset1                   ! select component group
                vsel,r,loc,y,aloc_,aloc_+180    ! reselect volume in +y direction
                get_max_entity
                v2bmsh_=vm                      ! volume to be meshed
            *else                           ! If volume count ~> 1 then
                get_max_entity
                v2bmsh_=vm                  ! volume to be meshed
            *endif
            !
            v1st_=v2bmsh_                   ! assign the 1st volume to be meshed
        *else
            *if,vcnt_,gt,1,then             ! If volume count > 1 then
                cm,vset1,volu                   ! store volumes in component group
                vsel,r,loc,y,aloc_,aloc_+180    ! reselect volume in +y direction
                get_max_entity
                v2bmsh_=vm                      ! volume to be meshed
            *else                           ! If volume count ~> 1 then
                *exit
            *endif
        *endif
        !
        *if,ptyp_,eq,0,then
            v_=v2bmsh_
            !
            *if,xyz_,eq,1,then
                msh_algorithm,1,3,a1_,b2_,c3_,,e5_,f6_,g7_,h8_,i9_,j0_,k1_,v_,n4_,o5_,p6_
            *else
                msh_algorithm,0,2,a1_,b2_,c3_,,e5_,f6_,g7_,h8_,i9_,j0_,k1_,v_,n4_,o5_,p6_
            *endif
        *else
            mata_=rotaset(abc_,matpos_)
            !
            *if,xyz_,eq,1,then
                msh_algorithm,1,3,a1_,b2_,c3_,,e5_,f6_,g7_,h8_,mata_,j0_,k1_,v2bmsh_,n4_,o5_,p6_
            *else
                msh_algorithm,0,2,a1_,b2_,c3_,,e5_,f6_,g7_,h8_,mata_,j0_,k1_,v2bmsh_,n4_,o5_,p6_
            *endif
        *endif
        !
        *get,vfintyp_,parm,vfinal_,type
        !
        *if,vfintyp_,ne,-1,then
            *if,v2bmsh_,eq,vfinal_,then
                *exit
            *endif
        *endif
    *enddo
    !
    *if,ptyp_,ne,0,then
        *if,i9_,ne,'array',then
            *exit
        *endif
    *endif
*enddo
!
init_entity_num
!
allsel,all
!
csys,actcs_
!
lplot
!
!
*if,ptyp_,eq,0,then
    *set,rotaset_(1),
*else
    *if,ptyp2_,ne,-1,then
        *set,rotaset(1),
        *set,amatmax_,
    *endif
*endif
!
*set,actcs_,
*set,acstyp_,
*set,acs_,
*set,aloc_,
*set,aloctr_,
*set,acx_,
*set,acy_,
*set,acz_,
*set,mata_,
*set,v_,
*set,a1_,
*set,b2_,
*set,c3_,
*set,e5_,
*set,f6_,
*set,g7_,
*set,h8_,
*set,i9_,
*set,j0_,
*set,k1_,
*set,n4_,
*set,o5_,
*set,p6_,
*set,abc_,
*set,xyz_,
*set,ptyp_,
*set,ptyp2_,
*set,alimit_,
*set,matpos_,
*set,v2bmsh_,
*set,vfintyp_,
*set,vfinal_,
cmdele,vset1


w:\ansys\mac\tools\cpl_nodes.mac.html

!   TITLE:  cpl_nodes.mac (LOADS)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      12/11/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     05/04/2001        D. Edwards
!
!           Updated macro to optimize for speed:
!               1. Replaced create_cs with 'clocal' command
!               2. Replaced target set array with dmin_ parameter
!---------------------------------------------------------------------------
!
!
!   This sub-macro couples a user specified set of degrees of freedom (DOF)
!   of two sets of surface nodes from two separate parts.  The surfaces must
!   be coplanar, coincident or separated by a given distance within a specified
!   tolerance.
!
!   This macro may be used to couple the DOF of nodes from two separate and
!   different mesh layout patterns on any 2 given surfaces, allowing coupling
!   of non-coincident nodes.  This is achieved by specifying a cubical tol-
!   erance band around each node, with each node located at the center of
!   the cube. The tolerance band width argument, TOL, is defined as the
!   total width of the band around a node, as measured from a cartesian c.s.
!   centered at the node location.  This is depicted in figure 1.
!
!                            ___________________
!                           |       TOL         | TOL/2
!                           |                   |
!                           |       y ^         |
!                           |         |         |
!                           |         |         |
!                           |         *---> x   | TOL
!                           |      source       |
!                           |       node        |
!                           |                   |
!                           |                   |
!                           |___________________| -TOL/2
!                        -TOL/2               TOL/2
!
!                       FIGURE 1.  Tolerance band
!
!   Of the two surfaces, one surface (set of areas) is specified as the source
!   area(s), and the other set target area(s).  The area(s) of each surface are
!   stored in a component group, and those names are entered in as arguments
!   as specified below.  The algorithm then takes each node of the source
!   area and checks for the nearest node in the target area within the tolerance
!   band. Any nodes from the target area that are within the tolerance region
!   in figure 1 will be considered for coupling.  If there is more than 1 node
!   in this region, the algorithm will couple the source node with a target node
!   that is the least distance from it.
!
!   The input for this command macro must be carefully defined SOURCE and TARGET
!   area sets.  These area sets must be component groups with distinct user de-
!   fined names. Once the area sets are defined, then the input arguments to be
!   supplied to this macro may be input as follows:
!
!
!       (1) source_aset = component group character name of area(s) com-
!                         prising the source area.
!
!       (2) target_aset = component group character name of area(s) com-
!                         prising the target area.
!
!       (3) node_cs = the coordinate system in which the nodal coordinates
!                     are to be measured from. The local coordinate system
!                     created at each node is a cartesian coordinate sys-
!                     tem from which the tolerance band is created, and
!                     is created from NODE_CS.
!
!       (4) tol = the total width of the tolerance bands for considering a
!                 node for coupling.
!
!       (5) dof_lab = the DOF label for the coupling. (e.g., UX, UY, UZ,
!                     ROTX, ALL, ....) See the CP command help for all
!                     options.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                (1)          (2)        (3)    (4)    (5)
! CPL_NODES, source_aset, target_aset, node_cs, tol, dof_lab
!
!---------------------------------------------------------------------------
!
!
/nopr
!
s_aset=arg1
t_aset=arg2
n_cs=arg3
tol_=arg4
dof_lab=arg5
!
csys,n_cs
!
cmsel,s,%s_aset%
nsla,s,1
nrotat,all
cm,s_nset,node
!
cmsel,s,%t_aset%
nsla,s,1
nrotat,all
cm,t_nset,node
!
nsel,s,node,,s_nset
entity_array,'n','s_set','array'
s_cnt=ecount
!
t2_=.5*tol_
ctcs_=csn+1
!
*do,qrs_,1,s_cnt,1
    !
    csys,n_cs
    !
    clocal,ctcs_,0,nx(s_set(qrs_,1)),ny(s_set(qrs_,1)),nz(s_set(qrs_,1))
    !
    nsel,s,node,,t_nset
    !
    nsel,r,loc,x,-t2_,t2_
    nsel,r,loc,y,-t2_,t2_
    nsel,r,loc,z,-t2_,t2_
    !
    *get,ncnt_,node,,count              ! # of selected target nodes
    !
    *if,ncnt_,ge,1,then
        !
        dmin_=tol_
        t_node=0
        s_node=s_set(qrs_,1)
        !
        *do,ijk_,1,ncnt_
            t_node=ndnext(t_node)
            dist_=distnd(s_node,t_node)
            !
            *if,dist_,lt,dmin_,then
                dmin_=dist_
                nmin_=t_node
            *endif
        *enddo
        !
        nsel,s,node,,nmin_
        nsel,a,node,,s_node
        !
        cp,next,%dof_lab%,all
        !
        nsel,s,node,,t_nset
        nsel,u,node,,nmin_
        cm,t_nset,node
    *endif
*enddo
!
csdele,ctcs_
!
allsel,all
!
*set,arr_chk1
*set,arr_chk2
*set,ctcs_
*set,dist_
*set,dmin_
*set,dof_lab
*set,ecount
*set,ijk_
*set,n_cs
*set,nmin_
*set,qrs_
*set,s_aset
*set,s_cnt
*set,s_node
*set,s_nset
*set,s_set(1)
*set,t2_
*set,tol_
*set,t_aset
*set,t_node
*set,t_nset
/gopr


w:\ansys\mac\tools\harm_solv3.mac.html

!   TITLE:  harm_solv3.mac (SOLVE)

/COM,ANSYS RELEASE  5.4    UP19970828         16:53:05    01/06/2000
/input,start,ans     ,/export/cae/ansys54/docu/,,,,,,,,,,,,,,,,1
!
/prep7
!
ET,1,BEAM4
!
/units,bin
!
UIMP,1,EX, , ,30e6,
UIMP,1,DENS, , ,.101/386.4,
UIMP,1,NUXY, , ,0.33,
!
n,1,0
n,21,20
fill
E,1,2
EGEN,20,1,1
!
pi=3.1415927
rad=0.5
!
a=pi*rad**2
izz=(1/4)*pi*rad**4
thkz=2*rad
thky=thkz
shrz=10/9
shry=10/9
!
R,1,a,izz,iyy,thkz,thky,0
rmore,0,1/12,shrz,shry
!
*get,prkey_,active,0,prkey
/nopr
!
/VIEW, 1 ,1,1,1
/ANG, 1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC, 1 ,-0.300000,,,1
/REP,FAST
!
/title,Harmonic Analysis Trial
eplot
!
/solu
antype,harmic       ! harmonic response element
hropt,reduc     ! full harmonic response
hrout,off       ! print results as amplitudes & phase angles
outpr,basic,1
nsubst,500      ! 50 intervals in range
harfrq,0,10000      ! frequency range 0 to 100 Hz
kbc,1           ! step boundary condition
m,all,uy
!
f,1,fy,1.00
nsel,all
solve
finish
!
/post26
!
csys,0              ! Selected node 1
nsel,s,loc,x,20,,
*get,n1,node,,num,max
!
nsel,s,loc,x,4,,        ! Selected node 2
*get,n2,node,,num,max
!
nsel,s,loc,x,8,,        ! Selected node 3
*get,n3,node,,num,max
!
nsel,s,loc,x,12,,       ! Selected node 4
*get,n4,node,,num,max
!
nsel,s,loc,x,16,,       ! Selected node 5
*get,n5,node,,num,max
!
nsel,all
!
nsol,2,n1,u,y,disp1
nsol,3,n2,u,y,disp2
nsol,4,n3,u,y,disp3
nsol,5,n4,u,y,disp4
nsol,6,n5,u,y,disp5

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

!plcplx,3
/grid,1
/axlab,x,freq
/axlab,y,disp
plvar,2,3,4,5,6
!
finish


w:\ansys\mac\tools\harmonic_example.mac.html

!
!------------------------------------------------------------------------------
!
!   TITLE:  harmonic_example.mac (SOLVE)
!
! Two masses attached by 3 springs (section 4.6 of "4 Harmonic Response
! Analysis", pg. 4-19) modified to 2 masses of 0.5 and 1.0 lb-sec^2/in with
! damping.  Mass 1 is vibrated sinusoidally with an amplitude of 200 lb
! in a frequency range from 0 to 7.5 Hz.  A damping ratio (DMPRAT) of
! 0.05 is used for this system.  A FULL harmonic analysis is calculated for
! frequency steps (fstep) of 50 Hz increments.
!
!------------------------------------------------------------------------------
!
/prep7
/title,harmonic response of a two-mass-spring system

et,1,combin14,,,2
et,2,mass21,,,4
et,3,mass21,,,4
r,1,200         ! spring constant = 200
r,2,.5          ! mass = 0.5
r,3,1.0
n,1
n,4,1
fill
e,1,2
e,2,3
e,3,4
type,2
real,2
e,2         ! mass element
type,3
real,3
e,3         ! mass element
finish
!
/solu
antype,harmic       ! harmonic response element
hropt,full      ! full harmonic response
hrout,off       ! print results as amplitudes & phase angles
outpr,basic,1
nsubst,50       ! 30 intervals in range
harfrq,0,7.5        ! frequency range 0 to 7.5Hz
kbc,1           ! step boundary condition
d,1,uy,,,4      ! constrain all 44 DOF
d,1,ux,,,4,3        ! constrain nodes 1 and 4 in ux
dmprat,.05
f,2,fx,200
solve
finish
!
/post26
nsol,2,2,u,x,2ux    ! store ux displacements
nsol,3,3,u,x,3ux
/grid,1
/axlab,y,disp       ! Y-axis label
plvar,2,3       ! plot variables 2 and 3
finish


w:\ansys\mac\tools\harmonic_solv.mac.html

!       TITLE:  harmonic_solv.mac (SOLVE)
/solu
!
nsel,s,loc,z,0,0,,
ddele,all
!
antype,harmic           ! initiate harmonic analysis
hropt,msup,10,1         ! mode-superposition option
hrout,off           ! results as amplitude & phase angle
outpr,basic,1
nsubst,1000         ! 1000 intervals in frequency range
harfrq,0,2500           ! frequency range from 0 to 2500 Hz
kbc,1               ! step boundary condition
d,all,uy,2.00
!nsel,s,loc,z,20,,
!nsel,r,loc,y,0.5,,
!*get,nnum1,node,,num,max
!f,all,fy,20.0          ! apply load amplitude
nsel,all
solve
!
finish
!
/post26
!
csys,0              ! Selected node 1
nsel,s,loc,z,20,,
nsel,r,loc,y,0.5,,
*get,nnum1,node,,num,max
!
nsel,s,loc,z,4,,        ! Selected node 2
nsel,r,loc,y,0.5,,
*get,nnum2,node,,num,max
!
nsel,s,loc,z,8,,        ! Selected node 3
nsel,r,loc,y,0.5,,
*get,nnum3,node,,num,max
!
nsel,s,loc,z,12,,       ! Selected node 4
nsel,r,loc,y,0.5,,
*get,nnum4,node,,num,max
!
nsel,s,loc,z,16,,       ! Selected node 5
nsel,r,loc,y,0.5,,
*get,nnum5,node,,num,max
!
file,harmonic,rfrq
nsol,2,nnum1,u,y,disp1
nsol,3,nnum2,u,y,disp2
nsol,4,nnum3,u,y,disp3
nsol,5,nnum4,u,y,disp4
nsol,6,nnum5,u,y,disp5
plcplx,3
/grid,1
/axlab,x,freq
/axlab,y,disp
plvar,2,3,4,5,6
finish
!


w:\ansys\mac\tools\harmonic_solv2.mac.html

!------------------------------------------------------------------------------
!
!   TITLE:  harmonic_solv2.mac (SOLVE)
!
! Cylindrical rod of length 20 inches and 1.00 inch diameter cantilevered such
! that the cantilevered end is vibrated sinusoidally with an amplitude of 2.00
! inches in a frequency range from 0 to 10000 Hz.  A damping ratio (DMPRAT) of
! 0.05 is used for this system.  A FULL harmonic analysis is calculated for
! frequency steps (fstep) of 100 Hz increments.
!
!------------------------------------------------------------------------------
!
/COM,ANSYS RELEASE  5.4    UP19970828         16:53:05    01/06/2000
/input,start,ans     ,/export/cae/ansys54/docu/,,,,,,,,,,,,,,,,1
/prep7

!
ET,1,PLANE42
ET,2,SOLID45
!
/units,bin
!
UIMP,1,EX, , ,30e6,
UIMP,1,DENS, , ,.101/386.4,
UIMP,1,NUXY, , ,0.33,
!
k,,0.5,0
k,,0,0.5
k,,-0.5,0
k,,0,-0.5
!
csys,1
!
l,1,2
l,2,3
l,3,4
l,4,1
a,1,2,3,4
!
LESIZE,ALL, , ,4,1,1
!
MSHKEY,1
AMESH,all
!
/VIEW, 1 ,1,1,1
/ANG, 1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC, 1 ,-0.300000,,,1
/REP,FAST
!
ESIZE,0,4*20,
TYPE,   2
MAT,       1
REAL,
ESYS,       0
!
VOFFST,1,20, ,
!
/ZOOM, 1 ,BACK
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC,  1, -3.109    , -2.586    ,  5.695
/REPLO
!
/title,Harmonic Analysis Trial, Damping Ratio of 0.05, UX Constraint
/REPLOT
!
ALLSEL,ALL
VSEL,ALL
ASEL,ALL
LSEL,ALL
KSEL,ALL
ESEL,ALL
NSEL,ALL
!
eplot
!
/solu
!
maxf=10000          ! MAXIMUM FREQUENCY IN RANGE
minf=0          ! MINIMUM FREQUENCY IN RANGE
fstep=100               ! NUMBER OF FREQUENCIES PER STEP
numinc=(maxf-minf)/fstep    ! NUMBER OF INCREMENTS IN FREQUENCY RANGE
!
antype,harmic       ! harmonic response element
hropt,full      ! full harmonic response
hrout,off       ! print results as amplitudes & phase angles
outpr,basic,1
nsubst,numinc       ! 100 intervals in range
harfrq,minf,maxf    ! frequency range 0 to 100 Hz
kbc,1
dmprat,0.05     ! step boundary condition
!d,all,uz       ! constrain all z DOF
!d,all,ux       ! constrain all x DOF
!
nsel,s,loc,z,0,,
d,all,uy,2.00
nsel,all
solve
finish
!
/post26
!
csys,0              ! Selected node 1
nsel,s,loc,z,20,,
nsel,r,loc,y,0.5,,
*get,n1,node,,num,max
!
nsel,s,loc,z,4,,        ! Selected node 2
nsel,r,loc,y,0.5,,
*get,n2,node,,num,max
!
nsel,s,loc,z,8,,        ! Selected node 3
nsel,r,loc,y,0.5,,
*get,n3,node,,num,max
!
nsel,s,loc,z,12,,       ! Selected node 4
nsel,r,loc,y,0.5,,
*get,n4,node,,num,max
!
nsel,s,loc,z,16,,       ! Selected node 5
nsel,r,loc,y,0.5,,
*get,n5,node,,num,max
!
nsel,all
!
nsol,2,n1,u,y,disp1
nsol,3,n2,u,y,disp2
nsol,4,n3,u,y,disp3
nsol,5,n4,u,y,disp4
nsol,6,n5,u,y,disp5
!plcplx,3
/grid,1
/axlab,x,freq (Hz)
/axlab,y,Y displacement
prnsol,u,y
plvar,2,3,4,5,6
!
finish


w:\ansys\mac\tools\harmonic_solv3.mac.html

!       TITLE:  harmonic_solv3.mac (SOLVE)

/COM,ANSYS RELEASE  5.4    UP19970828         16:53:05    01/06/2000
/input,start,ans     ,/export/cae/ansys54/docu/,,,,,,,,,,,,,,,,1
!
/prep7
!
ET,1,BEAM4
!
/units,bin
!
UIMP,1,EX, , ,30e6,
UIMP,1,DENS, , ,.101/386.4,
UIMP,1,NUXY, , ,0.33,
!
n,1,0
n,21,20
fill
E,1,2
EGEN,20,1,1
!
pi=3.1415927
rad=0.5
!
a=pi*rad**2
izz=(1/4)*pi*rad**4
thkz=2*rad
thky=thkz
shrz=10/9
shry=10/9
!
R,1,a,izz,iyy,thkz,thky,0
rmore,0,1/12,shrz,shry
!
/VIEW, 1 ,1,1,1
/ANG, 1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC, 1 ,-0.300000,,,1
/REP,FAST
!
/title,Harmonic Analysis Trial
eplot
!
/solu
antype,harmic       ! harmonic response element
hropt,reduc     ! full harmonic response
hrout,off       ! print results as amplitudes & phase angles
outpr,basic,1
nsubst,500      ! 50 intervals in range
harfrq,0,10000      ! frequency range 0 to 100 Hz
kbc,1           ! step boundary condition
m,all,uy
!
f,1,fy,1.00
nsel,all
solve
finish
!
/post26
!
csys,0              ! Selected node 1
nsel,s,loc,x,20,,
*get,n1,node,,num,max
!
nsel,s,loc,x,4,,        ! Selected node 2
*get,n2,node,,num,max
!
nsel,s,loc,x,8,,        ! Selected node 3
*get,n3,node,,num,max
!
nsel,s,loc,x,12,,       ! Selected node 4
*get,n4,node,,num,max
!
nsel,s,loc,x,16,,       ! Selected node 5
*get,n5,node,,num,max
!
nsel,all
!
nsol,2,n1,u,y,disp1
nsol,3,n2,u,y,disp2
nsol,4,n3,u,y,disp3
nsol,5,n4,u,y,disp4
nsol,6,n5,u,y,disp5
!plcplx,3
/grid,1
/axlab,x,freq
/axlab,y,disp
plvar,2,3,4,5,6
!
finish


w:\ansys\mac\tools\modal_solv.mac.html

!       TITLE:  modal_solv.mac (SOLVE)

/COM,ANSYS RELEASE  5.4    UP19970828         16:53:05    01/06/2000
/input,start,ans     ,/export/cae/ansys54/docu/,,,,,,,,,,,,,,,,1
!
/prep7
!
ET,1,PLANE42
ET,2,SOLID45
!
/units,bin
!
UIMP,1,EX, , ,30e6,
UIMP,1,DENS, , ,.101/386.4,
UIMP,1,NUXY, , ,0.33,
!
k,,0.5,0
k,,0,0.5
k,,-0.5,0
k,,0,-0.5
!
csys,1
!
l,1,2
l,2,3
l,3,4
l,4,1
a,1,2,3,4
!
LESIZE,ALL, , ,4,1,1
!
MSHKEY,1
AMESH,all
!
/VIEW, 1 ,1,1,1
/ANG, 1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC, 1 ,-0.300000,,,1
/REP,FAST
!
ESIZE,0,4*20,
TYPE,   2
MAT,       1
REAL,
ESYS,       0
!
VOFFST,1,20, ,
!
/ZOOM, 1 ,BACK
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/DIST, 1 ,1.371742,1
/REP,FAST
/FOC,  1, -3.109    , -2.586    ,  5.695
/REPLO
!
/title,Harmonic Analysis Trial
/REPLOT
!
nsel,s,loc,z,0,0,,
d,all,all
!
ALLSEL,ALL
VSEL,ALL
ASEL,ALL
LSEL,ALL
KSEL,ALL
ESEL,ALL
NSEL,ALL
!
eplot
!
/SOLU
!
ANTYPE,2
!
MODOPT,SUBSP,10
EQSLV,FRONT
MXPAND,10, , ,0
LUMPM,0
PSTRES,0
!
MODOPT,SUBSP,10,0,5000, ,OFF
RIGID,
SUBOPT,0,0,0,0,0,ALL
!
solve
!
finish
!


w:\ansys\mac\tools\create_image.mac.html

!   TITLE:  create_image.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/06/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a graphics image file of the currently displayed
!   ANSYS graphics window.
!
!   COMMAND SYNTAX:
!
!
!                        (1)    (2)     (3)   (4)
!        CREATE_IMAGE, imgtyp, orient, revrs, colr
!
!
!   ARGUMENTS:
!
!       (1) imgtyp = image format type: Valid inputs are:
!
!               'pscr' - encapsulated postscript (EPS)
!
!               'tiff' - tagged image file format (default)
!
!               'epsi' - encapsulated postscript with TIFF preview
!
!               'bmp' - bitmap ( PC only )
!
!               'wmf' - windows metafile format ( PC only )
!
!               'emf' - enhanced metafile format ( PC only )
!
!               'jpeg' - Joint Photographic Expert Group format
!
!       (2) orient = image orientation on the page
!
!               0 = landscape (default)
!
!               1 = portrait
!
!       (3) revrs = reverse video background ( print background )
!
!               0 = reverse video background ( white vackground ) (default)
!
!               1 = normal ( black background )
!
!       (4) colr = color of image
!
!               0 = color print ( at specified color depth ) (default)
!
!               1 = black and white
!
!               2 = greyscale
!
!
!   DESCRIPTION:
!
!   This macro creates a graphics file of the current output window in the
!   specified graphics format. If the image is a TIFF or EPS format, then
!   it compresses the file. The ANSYS /UI commmand is used to perform this
!   function.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

imgtyp_=arg1
orient_=arg2
revrs_=arg3
colr_=arg4
!
!
*get,imgptyp_,parm,imgtyp_,type
!
*if,imgptyp_,eq,0,then
    imgtyp_='tiff'
*endif
!
*if,orient_,eq,0,then
    orient_='landscape'
*elseif,orient_,eq,1,then
    orient_='portrait'
*else
    orient_='portrait'
*endif
!
*if,revrs_,eq,0,then
    revrs_='reverse'
*elseif,revrs_,eq,1,then
    revrs_='norm'
*else
    revrs_='norm'
*endif
!
*if,colr_,eq,0,then
    colr_='color'
*elseif,colr_,eq,1,then
    colr_='mono'
*elseif,colr_,eq,2,then
    colr_='grey'
*else
    colr_='color'
*endif
!
/ui,copy,save,%imgtyp_%,graph,%colr_%,%revrs_%,%orient_%,yes
!
*set,imgtyp_,
*set,orient_,
*set,revrs_,
*set,colr_,
*set,imgptyp_,


w:\ansys\mac\tools\draw_view.mac.html

!   TITLE:  draw_view.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      05/23/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro is used to take an existing part volume(s) and create the
!   third-angle projection views used for dimensioning and annotation of
!   parameters.
!
!   COMMAND SYNTAX:
!
!       OPTION 1:
!
!                      (1)  (2)   (3)    (4)    (5)    (6)    (7)
!           DRAW_VIEW, opt, vcs, distf, view1, view2, view3, view4
!
!       OPTION 2:
!
!                      (1)   (2)
!           DRAW_VIEW, opt, view
!
!
!   DESCRIPTION:
!
!   The convention used in the creation of drawing views is the current U.S.
!   standard of third-angle projection.  This macro may be used in 1 of 2
!   possible ways:
!
!           1.) Create annotated drawing views on 1 sheet, showing all views
!               simultaneously with their respective dimensions. This may be
!               for smaller, less-featured parts.
!
!           2.) Create different annotated drawing views to be used as separate
!               drawing documents. This is for heavily dimensioned/annotated
!               parts that require more detailed annotation.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

opt_=arg1
!
*if,opt_,eq,1,then
    vcentr_=arg2
    !
    *get,actcs_,active,,csys
    !
    csys,vcentr_                        ! initiate relative coordinate system
    !
    *get,vcnttyp_,cdsy,vcentr_,attr,kcs
    !
    *if,vcnttyp_,ne,0,then
        create_cs,0,'vcentr_',0,0,0,0,0,0,0
    *endif
    !
    *if,opt_,ne,1,then
        *if,opt_,ne,2,then
            opt_=2
        *endif
    *endif
*endif
!
!
!--------------------- Configure Input Options ----------------------
!
!
*if,opt_,eq,1,then
    !
    distf_=arg3
    !
    *get,disttyp_,parm,distf_,type
    !
    *if,disttyp_,ne,0,then
        distf_=1.0
    *else
        *if,distf_,eq,0,then
            distf_=1.0
        *endif
    *endif
    !
    view1_=arg4
    !
    *get,v1typ_,parm,view1_,type
    !
    *if,v1typ_,ne,3,then
        view1_='all'
    *endif
    !
    *if,view1_,eq,'all',then
        viewlim_=5
        !
        view1_='l'
        view2_='r'
        view3_='t'
        view4_='bot'
        view5_='back'
    *else
        viewlim_=4
        !
        view2_=arg5
        view3_=arg6
        view4_=arg7
        !
        *get,v2typ_,parm,view2_,type
        *get,v3typ_,parm,view3_,type
        *get,v4typ_,parm,view4_,type
        !
        *if,v2typ_,ne,3,then
            view2_='null'
        *endif
        !
        *if,v3typ_,ne,3,then
            view3_='null'
        *endif
        !
        *if,v4typ_,ne,3,then
            view4_='null'
        *endif
    *endif
*elseif,opt_,eq,2,then
    !
    view_=arg2
    !
    *get,vtyp_,parm,view_,type
    !
    *if,vtyp_,ne,3,then
        view_='r'
    *endif
*endif
!
!
!--------------------- Create Component Groups ----------------------
!
!
*get,vcnt_,volu,,count          ! retrieve # of volumes
*get,acnt_,area,,count          ! retrieve # of areas
!
*if,vcnt_,gt,0,then
    cm,partvol_,volu            ! component group of part volumes
    parttyp_='partvol_,'
*else
    *if,acnt_,gt,0,then
        cm,partar_,area         ! component group of part areas
        parttyp_='partar_'
    *else
        cm,partln_,line         ! component group of part lines
        parttyp_='partln_'
    *endif
*endif
!
!
*if,opt_,eq,1,then
!
!---------------------------- Option 1 ------------------------------
!
!
csys,vcentr_
!
*do,abc__,1,viewlim_,1
    cmsel,s,%parttyp_%
    !
    *if,parttyp_,eq,'partvol_',then
        aslv,s
        lsla,s
        ksll,s
    *elseif,parttyp_,eq,'partar_',then
        lsla,s
        ksll,s
    *elseif,parttyp_,eq,'partln_',then
        ksll,s
    *endif
    !
    *if,view%abc__%_,eq,'l',then
        !
        max_kp_dist,vcentr_,'-x'
            a_=max_dist
            !
        max_kp_dist,vcentr_,'+z'
            b_=max_dist
            !
        dgap_=a_+b_+distf_*(a_+b_)
        !
        create_cs,0,'vw%abc__%_',0,-dgap_,0,0,0,0,90
        !
    *elseif,view%abc__%_,eq,'r',then
        !
        max_kp_dist,vcentr_,'+x'
            a_=max_dist
            !
        max_kp_dist,vcentr_,'+z'
            b_=max_dist
            !
        dgap_=a_+b_+distf_*(a_+b_)
        !
        create_cs,0,'vw%abc__%_',0,dgap_,0,0,0,0,-90
        !
    *elseif,view%abc__%_,eq,'t',then
        !
        max_kp_dist,vcentr_,'+y'
            a_=max_dist
            !
        max_kp_dist,vcentr_,'+z'
            b_=max_dist
            !
        dgap_=a_+b_+distf_*(a_+b_)
        !
        create_cs,0,'vw%abc__%_',0,0,dgap_,0,0,90,0
        !
    *elseif,view%abc__%_,eq,'bot',then
        !
        max_kp_dist,vcentr_,'-y'
            a_=max_dist
            !
        max_kp_dist,vcentr_,'+z'
            b_=max_dist
            !
        dgap_=a_+b_+distf_*(a_+b_)
        !
        create_cs,0,'vw%abc__%_',0,0,-dgap_,0,0,-90,0
        !
    *elseif,view%abc__%_,eq,'back',then
        !
        max_kp_dist,vcentr_,'+y'
            a1_=max_dist
            !
        max_kp_dist,vcentr_,'+z'
            b1_=max_dist
            !
        dgap1_=a1_+b_1+distf_*(a1_+b1_)
        !
        !
        max_kp_dist,vcentr_,'-y'
            a2_=max_dist
            !
        dgap2_=a1_+a2_+distf_*(a1_+a2_)
        !
        create_cs,0,'vw%abc__%_',0,0,dgap1_+dgap2_,0,0,180,0
        !
    *endif
    !
    csys,vcentr_
    !
    *if,view%abc__%_,ne,'null',then
        *if,vcnt_,gt,0,then
            vtran,vw%abc__%_,%parttyp_%,,,,1,0
            vplot
        *else
            *if,acnt_,gt,0,then
                atran,vw%abc__%_,%parttyp_%,,,,1,0
                aplot
            *else
                ltran,vw%abc__%_,%parttyp_%,,,,1,0
                lplot
            *endif
        *endif
    *endif
*enddo
!
init_entity_num
!
view,'f'
!
!--------------------------------------------------------------------
!
*endif          ! END Option 1
!
!
!
*if,opt_,eq,2,then
!
!---------------------------- Option 2 ------------------------------
!
view,'%view_%'
!
*if,vcnt_,gt,0,then
    aplot
*else
    *if,acnt_,gt,0,then
        aplot
    *else
        lplot
    *endif
*endif
!
!--------------------------------------------------------------------
!
*endif          ! END Option 2
!
!
!
*if,vcnt_,gt,0,then
    aplot
*else
    *if,acnt_,gt,0,then
        aplot
    *else
        lplot


w:\ansys\mac\tools\mod_info.mac.html

!   TITLE:  mod_info.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     11/1/2000     J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro displays the current model information.  Options for
!   information on models are:
!
!           1 = the last eight model names in the current database, in order.
!
!           2 = the last eight parameter file arrays in the current database,
!               in order.
!
!           3 = the current model coordinate system names
!
!
*get,prkey_,active,0,prkey
/nopr

!
!*if,modl_num,lt,8,then
!diff_=modl_num-
!multipro,'start',1
    !*cset,1,3,_opt,'Enter Information Option',0
    !*cset,61,62,'Enter the type of model inform','ation desired - 1 = model names'
    !*cset,63,64,'2 = parameter array names - 3',' = model C.S. names'
!multipro,'end'
!
!*stat,cs_arry
*list,block,parm

*go,:skip

*if,_opt,eq,1,then
    *msg,ui,'KM',%km%,'LM',%lm%,'AM',%am%,'VM',%vm%
    %c = %i&
    %c = %i&
    %c = %i&
    %c = %i
*endif
!
*if,decision,eq,1,then
    *msg,ui,'NM',%nm%,'EM',%em%
    %c = %i&
    %c = %i


w:\ansys\mac\tools\reverse_video.mac.html

!  TITLE:  reverse_video.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -    RELEASED   03/22/2001      J. Judd
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro reverses the graphics window background from black/white
!   to white/black.
!
!
!   COMMAND SYNTAX:
!
!       REVERSE_VIDEO, on_off
!
!
!   ARGUMENTS:
!
!       on_off = background color.
!
!               1 = white background
!
!               0 = black background
!
!
!   DESCRIPTION:
!
!   The graphics window background becomes white when 'ON' (on_off = 1) and
!   black when 'OFF' (on_off = 0).
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*if,arg1,eq,1,then
   /RGB,INDEX,100,100,100, 0
   /RGB,INDEX, 80, 80, 80,13
   /RGB,INDEX, 60, 60, 60,14
   /RGB,INDEX,  0,  0,  0,15
*elseif,arg1,eq,0,then
   /RGB,INDEX,  0,  0,  0, 0
   /RGB,INDEX, 60, 60, 60,13
   /RGB,INDEX, 80, 80, 80,14
   /RGB,INDEX,100,100,100,15
*endif
!
/REPLOT


w:\ansys\mac\tools\rplot_nodal.mac.html

!
!       TITLE:  rplot_nodal.mac (POST)
!
!---------------------------------------------------------------------------
!               Rev -     01/13/2001      D. Edwards
!               Rev A     04/26/2001      D. Edwards
!                         Add support for running in batch mode:
!                          Added /nopr & /gopr commands near line 160
!---------------------------------------------------------------------------
!
!  Plot nodal results versus node location for the selected node set.
!
!  The input arguments are:
!
!   (1) cs = Coordinate system number to use when obtaining
!            node locations and nodal results.
!
!   (2) SrtDir = Coorinate system direction to sort nodes by.
!
!   (3) Item1 = Nodal degree of freedom result label, "Item1" from ANSYS
!               Commands Manual, *get, Table 5. i.e. displacement (U),
!               stress (S), current (CURR), etc.
!
!   (4) Comp1 = Component "IT1NUM" from Table 5 of the *get command.
!
!   (5-m) Itemn,Compn = Additional results to plot on the same graph
!                       (n = 8 max, m = 12 max). All these arguments
!                       are optional and can be left blank.
!
!  Additional plotting manipulations and capabilities are obtained by
!  setting certain parameters prior to calling this macro. None of the
!  parameters defined below are required, but they can be specified in
!  any combination to enable the desired features.
!
!   The nodal results can optionally have a function or mathematical
!   operation applied to the result data (y-axis data) prior to plotting
!   it. This is done by setting any of the following parameters:
!
!       fcn1='FN'   ! Optional Ansys function to apply to Item1, Comp1
!       fcn2='FN'   ! Optional Ansys function to apply to Item2, Comp2
!       .
!       .
!       .
!       fcnn='FN'   ! Optional Ansys function to apply to Itemn, Compn
!                   ! (where n = 8 or less)
!
!       Where 'FN' is any of the single argument functions listed in
!       section 3.9 of the ANSYS APDL Guide.
!       (file:///D|/ANSYS56/docu/catalog/english/ansyshelp/Hlp_P_APDL3_9.html)
!
!       The mathematical operations are applied through the definition
!       of Ansys parameters, fcn1, fcn2, etc.  fcn1 is applied to the
!       first curve, fcn2 is applied to the second curve and so on.
!
!       A mathematical function is applied by suffixing the character
!       contents of the fcn parameter with "(X)"  where "X" is a result
!       value.  See examples below.
!
!       NOTE:  These parm's are unset after each call to rplot_nodal.
!
!   Two additional parameters can be set prior to calling this macro
!   which will cause a data file to be written for use in other
!   plotting programs:
!
!       mkasc=1     If this parm is defined, an ASCII data file called
!                   rplot_nodal.asc will be written for import into
!                   Tk-Solver. Use the File -> Import... menu to bring
!                   in the data.
!
!       mkdat=1     Define this parm to have an ASCII data file created
!                   in the format easily read into PSI-Plot, Excel, etc.
!                   The file will be named rplot_nodal.dat.
!
!   NOTE:  These parameters are unset at the end of rplot_nodal.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!             (1)  (2)     (3)    (4)    (5)    (6)... (11 max) (12 max)
! rplot_nodal,cs ,SrtDir, Item1, Comp1, Item2, Comp2,...,Itemn, Compn
!
!   NOTE: Only four arguments are required.
!
!------------------------------ EXAMPLES -----------------------------------
!
!   1.  Plot the absolute value of minimum principal stress and von Mises
!       stress verses angular position of the currently selected node set.
!       Write data files, rplot_nodal.asc and rplot_nodal.dat.
!
!           mkasc=1
!           mkdat=1
!           fcn1='abs'
!           rplot_nodal,cyl1cs,'y','s','3','s','eqv'
!
!   2.  Plot von Mises stress, 1/2 the principal stress and the
!       absolute value of the shear stress verses the x coordinates
!       of the currently selected node set. Do NOT write data files,
!       rplot_nodal.asc and rplot_nodal.dat.
!
!           fcn2='.5*'
!           fcn3='abs'
!           rplot_nodal,ct1cs,'x','s','eqv','s','1','s','xy'
!
!-------------------------- DEPENDENCY LIST ------------------------------
!
!   rplot_nodal.mac
!       striplis.pl
!       line1.pl
!
!---------------------------------------------------------------------------

! # of data sets (curves) to plot
*get,npairs_,cmd,0,nargs
npairs_=(npairs_-3)/2

*get,prkey_,active,0,prkey
/nopr

fini
/post1

!
! Give the input meaningful names
!
cs_=arg1
SrtDir_=upcase(arg2)

*dim,items_,char,npairs_
*dim,comps_,char,npairs_
*dim,cmb_,char,npairs_      ! Combine items & comps

*do,i_,1,npairs_
    *if,i_,lt,5,then
        items_(i_)=arg%3+2*(i_-1)%
    *else
        items_(i_)=ar%3+2*(i_-1)%
    *endif

    *if,i_,lt,4,then
        comps_(i_)=arg%4+2*(i_-1)%
    *else
        comps_(i_)=ar%4+2*(i_-1)%
    *endif
        cmb_(i_)='%items_(i_)%%comps_(i_)%'
*enddo

!
! Save current settings
!
*get,csys_,active,0,csys
*get,rsys_,active,0,rsys
*get,dsys_,active,0,dsys

!
! All three coordinate systems must be set to get
! consistent results
!
rsys,cs_
csys,cs_
dsys,cs_        ! Needed for consistent NLIST

!
! Create a list of nodal locations for the abscissa (x-axis)
!
nsort,loc,SrtDir_,1,0
/nopr
/out,coords_,lis
nlist,all,,,coord,SrtDir_,node,node
/out

!
! Strip away extraneous lines from the list files
! before reading them into Ansys
!
/sys,striplis.pl coords_.lis

*get,ncount_,node,0,count               ! Number of nodes in set

!
! Read the abscissa (x-axis) data into a vector
! Depending on the "SrtDir" read the 2nd, 3rd or 4th column
! of numbers from "coords.lis"
!
! The file format is (I8,2X,3(1X,G19.12))
!
*set,%SrtDir_%_
*dim,%SrtDir_%_,array,ncount_

*if,SrtDir_,eq,'X',then
*vread,%SrtDir_%_(1),coords_,lis
(11X,G19.12)

*elseif,SrtDir_,eq,'Y'
*vread,%SrtDir_%_(1),coords_,lis
(31X,G19.12)

*elseif,SrtDir_,eq,'Z'
*vread,%SrtDir_%_(1),coords_,lis
(51X,G19.12)

*else
*msg,error,SrtDir_
Sort Direction %C is invalid, use X, Y or Z.
*endif

!
! Read in the node numbers
!
*dim,vnodes_,array,ncount_

*vread,vnodes_(1),coords_,lis
(F8.0)
!
! Read the y-axis data into a table
!
avprin,0,0                          ! Use nodal average

*set,a_
*dim,a_,table,ncount_,npairs_       ! Store all the y-axis data here

!
! The following algorithim could be written with on two *do loops
! instead of three.  But, this is faster for the case of plotting
! many data points and no applied math function.
!
*do,i_,1,npairs_
    *get,ptype_,parm,fcn%i_%,type   ! Define math function
    *if,ptype_,eq,3,then
        temp_=fcn%i_%
        *do,j_,1,ncount_
            *get,dup,node,vnodes_(j_),items_(i_),comps_(i_)
            dup=%temp_%(dup)
            a_(j_,i_)=dup
        *enddo
    *else
        *do,j_,1,ncount_
            *get,a_(j_,i_),node,vnodes_(j_),items_(i_),comps_(i_)
        *enddo
    *endif
    /gcolumn,i_,%items_(i_)%%comps_(i_)%
*enddo

*vplot,%SrtDir_%_(1),a_(1,1),2,3,4,5,6,7,8

!
! Write the data to a Tk-Solver ".asc" file
! if parameter "MKASC" is defined.
!
*get,ptype_,parm,mkasc,type
*if,ptype_,ne,-1,then
/nopr
/out,rplot_nodal,asc
*msg,info
node:
*vwrite,vnodes_(1)
(F8.0)

*msg,info,SrtDir_
%C:
*vwrite,%SrtDir_%_(1)
(E20.12)

*do,i_,1,npairs_
*msg,info,cmb_(i_)
%C:
*vwrite,a_(1,i_)
(E20.12)
*enddo
/out

*endif

!
! Write the data to a PSI-Plot ".dat" file
! if parameter "MKDAT" is defined.
!
*get,ptype_,parm,mkdat,type
*if,ptype_,ne,-1,then

! Create the first line of column names
/nopr
/out,rplot_nodal,dat
*vwrite
('node')
*vwrite,SrtDir_
(A8)
*vwrite,cmb_(1)
(A8)
/out
/sys,line1.pl rplot_nodal.dat

! Write out all the data in column format
/out,rplot_nodal,dat,,append
*if,npairs_,eq,1,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1,1)
(F8.0,2E20.12)
*elseif,npairs_,eq,2,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2)
(F8.0,3E20.12)
*elseif,npairs_,eq,3,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3)
(F8.0,4E20.12)
*elseif,npairs_,eq,4,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4)
(F8.0,5E20.12)
*elseif,npairs_,eq,5,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5)
(F8.0,6E20.12)
*elseif,npairs_,eq,6,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6)
(F8.0,7E20.12)
*elseif,npairs_,eq,7,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6),a_(1,7)
(F8.0,8E20.12)
*else
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6),a_(1,7),a_(1,8)
(F8.0,9E20.12)
*endif
/out

*endif

!
! Restore settings and Clean Up
!
/nopr
rsys,rsys_
csys,csys_
dsys,dsys_

*do,i_,1,npairs_
    *set,fcn%i_%
*enddo

*set,mkasc
*set,mkdat

!*set,%SrtDir_%_    ! If this is unset then plotting won't work
!*set,SrtDir_       ! If this is unset then plotting won't work
                    ! Also do NOT unset "a_"

*set,cmb_
*set,comps_
*set,Comp_
*set,csys_
*set,cs_
*set,dsys_
*set,dup
*set,fcnx_
*set,items_
*set,Item_
*set,i_
*set,j_
*set,ncount_
*set,npairs_
*set,ptype_
*set,rsys_
*set,temp_
*set,vnodes_


w:\ansys\mac\tools\rvplot_nodal.mac.html

!
!       TITLE:  rvplot_nodal.mac (POST)
!
!---------------------------------------------------------------------------
!               Rev -     01/26/2001      D. Edwards
!---------------------------------------------------------------------------
!
!  Plot nodal results versus node location for the selected node set.
!
!  This is the vector version of rplot_nodal.mac which uses *Vxx operations
!  to obtain the POST1 results for plotting.  This version of rplot_nodal
!  only uses Perl for writing PSI-Plot .DAT files (see mkdat option).
!
!  See "rplot_nodal.mac" for usage information.
!
!---------------------- DEPENDENCY LIST ------------------------------
!
!   rvplot_nodal.mac
!       line1.pl
!
!---------------------------------------------------------------------------

! # of data sets (curves) to plot
*get,npairs_,cmd,0,nargs
npairs_=(npairs_-3)/2

*get,prkey_,active,0,prkey
/nopr

fini
/post1

!
! Give the input meaningful names
!
cs_=arg1
SrtDir_=arg2

*dim,items_,char,npairs_
*dim,comps_,char,npairs_
*dim,cmb_,char,npairs_      ! Combine items & comps

*do,i_,1,npairs_
    *if,i_,lt,5,then
        items_(i_)=arg%3+2*(i_-1)%
    *else
        items_(i_)=ar%3+2*(i_-1)%
    *endif

    *if,i_,lt,4,then
        comps_(i_)=arg%4+2*(i_-1)%
    *else
        comps_(i_)=ar%4+2*(i_-1)%
    *endif
        cmb_(i_)='%items_(i_)%%comps_(i_)%'
*enddo

!
! Save current settings
!
*get,csys_,active,0,csys
*get,rsys_,active,0,rsys
*get,dsys_,active,0,dsys

!
! All three coordinate systems must be set to get
! consistent results
!
rsys,cs_
csys,cs_
dsys,cs_        ! Needed for consistent NLIST

!
! Make a list of all the selected node numbers
!

! First get the max & min node numbers of the selected set
*get,nmax_,node,0,num,max
*get,nmin_,node,0,num,min
bw_=nmax_-nmin_+1               ! Bandwidth = Max possible # nodes in set

!
! Create one matrix containing all the data and
! define columns as follows:
!   1. Mask
!   2. Node number
!   3. Sort coordinate of nodes
!   4. Results for curve 1
!   5. Results for curve 2
!   .
!   .
!   n. Results for curve n
!
*dim,umat_,array,bw_,3+npairs_      ! Uncompressed full bandwidth matrix

! Get the mask vector of selected/unselected nodes in range
*vget,umat_(1,1),node,nmin_,nsel    ! -1=unsel,  0=undefined, 1=selected

! Make a list of node numbers
*vmask,umat_(1,1)
*vfill,umat_(1,2),ramp,nmin_,1

!
! Create a list of nodal locations for the abscissa (x-axis)
!
*vmask,umat_(1,1)
*vget,umat_(1,3),node,nmin_,loc,SrtDir_

!
! Fill the results into the uncompressed matrix
!
avprin,0,0                          ! Use nodal average
*do,i_,4,3+npairs_
    *vmask,umat_(1,1)
    *vget,umat_(1,i_),node,nmin_,items_(i_-3),comps_(i_-3)
*enddo

!
! Move the data into a compressed table
!
*get,ncount_,node,0,count           ! Number of nodes in set
*dim,vnodes_,array,bw_

*vlen,bw_
*vmask,umat_(1,1)
*vfun,vnodes_(1),comp,umat_(1,2)

*set,%SrtDir_%_
*dim,%SrtDir_%_,array,bw_
*vmask,umat_(1,1)
*vfun,%SrtDir_%_(1),comp,umat_(1,3)

!
! Apply the any math functions that may have been specified
!
! The use of temp_ and dup_ are work arounds for Ansys quirks.
!
*set,a_
*dim,a_,table,bw_,npairs_
*do,i_,1,npairs_
    *get,ptype_,parm,fcn%i_%,type   ! Define math function
    *if,ptype_,eq,3,then

        ! Check for 'abs' and 'ABS' only. 'Abs' will be slower
        *if,fcn%i_%,eq,'ABS',then
            fcn%i_%='abs'
        *endif

        *if,fcn%i_%,eq,'abs',then
            ! Compress matrix of y-data using abs value result
            *vabs,1
            *vmask,umat_(1,1)
            *vfun,a_(1,i_),comp,umat_(1,3+i_)
        *else
            ! Apply math function to result
            temp_=fcn%i_%
            *do,j_,1,ncount_
                *get,dup,node,vnodes_(j_),items_(i_),comps_(i_)
                dup=%temp_%(dup)
                a_(j_,i_)=dup
            *enddo
        *endif
    *else
        ! Compress matrix of y-data
        *vmask,umat_(1,1)
        *vfun,a_(1,i_),comp,umat_(1,3+i_)
    *endif
    /gcolumn,i_,%items_(i_)%%comps_(i_)%
*enddo

! Sort the matrix relative to the sort direction coordinate
*dim,orig_,,bw_

*vlen,ncount_
*moper,orig_(1),a_(1,1),sort,%SrtDir_%_(1)

*vlen,ncount_
*moper,orig_(1),vnodes_(1),sort,%SrtDir_%_(1)

*vlen,ncount_
*moper,orig_(1),%SrtDir_%_(1),sort,%SrtDir_%_(1)

*vlen,ncount_
*vplot,%SrtDir_%_(1),a_(1,1),2,3,4,5,6,7,8

*get,ptype_,parm,mkasc,type
*if,ptype_,ne,-1,then
/com, Write the data to a Tk-Solver ".asc" file
! if parameter "MKASC" is defined.
/nopr
/out,rplot_nodal,asc
*msg,info
node:
*vlen,ncount_
*vwrite,vnodes_(1)
(F8.0)

*msg,info,SrtDir_
%C:
*vlen,ncount_
*vwrite,%SrtDir_%_(1)
(E20.12)

*do,i_,1,npairs_
*msg,info,cmb_(i_)
%C:
*vlen,ncount_
*vwrite,a_(1,i_)
(E20.12)
*enddo
/out

*endif

*get,ptype_,parm,mkdat,type
*if,ptype_,ne,-1,then
/com, Write the data to a PSI-Plot ".dat" file
! if parameter "MKDAT" is defined.

! Create the first line of column names
/nopr
/out,rplot_nodal,dat
*vwrite
('node')
*vwrite,SrtDir_
(A8)
*vwrite,cmb_(1)
(A8)
/out
/sys,line1.pl rplot_nodal.dat

! Write out all the data in column format
/out,rplot_nodal,dat,,append
*vlen,ncount_
*if,npairs_,eq,1,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1,1)
(F8.0,2E20.12)
*elseif,npairs_,eq,2,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2)
(F8.0,3E20.12)
*elseif,npairs_,eq,3,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3)
(F8.0,4E20.12)
*elseif,npairs_,eq,4,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4)
(F8.0,5E20.12)
*elseif,npairs_,eq,5,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5)
(F8.0,6E20.12)
*elseif,npairs_,eq,6,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6)
(F8.0,7E20.12)
*elseif,npairs_,eq,7,then
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6),a_(1,7)
(F8.0,8E20.12)
*else
*vwrite,vnodes_(1),%SrtDir_%_(1),a_(1),a_(1,2),a_(1,3),a_(1,4),a_(1,5),a_(1,6),a_(1,7),a_(1,8)
(F8.0,9E20.12)
*endif
/out

*endif

!
! Restore settings and Clean Up
!
/nopr
rsys,rsys_
csys,csys_
dsys,dsys_

*do,i_,1,npairs_
    *set,fcn%i_%
*enddo

*set,mkdat
*set,mkasc

! These parameters must remain defined in order for printing to work correctly
!*set,%SrtDir_%_
!*set,SrtDir_
!*set,a_

*set,bw_
*set,cmb_
*set,comps_
*set,Comp_
*set,csys_
*set,cs_
*set,dsys_
*set,dup_
*set,fcnx_
*set,items_
*set,i_
*set,j_
*set,ncount_
*set,nmax_
*set,nmin_
*set,npairs_
*set,orig_
*set,ptype_
*set,rsys_
*set,temp_
*set,umat_
*set,vnodes_


w:\ansys\mac\tools\view.mac.html

!   TITLE:  view.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      05/23/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro restores the view of the graphics window to the specified
!   direction relative to the active coordinate system.
!
!
!   COMMAND SYNTAX:
!
!        VIEW, vdir
!
!
!   ARGUMENTS:
!
!           vdir = the view direction. Valid options are:
!
!                   'f'     =   front view (XY plane, +Z out)
!                   'back'  =   back view (XY plane, +Z in)
!                   'l'     =   left view (YZ plane, +X in)
!                   'r'     =   right view (YZ plane, +X out)
!                   't'     =   top (XZ plane, +Y out)
!                   'bot'   =   bottom (XZ plane, +Y in)
!                   'iso'   =   isometric (1st octant)
!                   'o'     =   oblique view
!                   'siso'  =   spherical isometric (1st octant, +Z up)
!
!
!   DESCRIPTION:
!
!   The various standard view directions (i.e., front, back, top, etc.)may be
!   specifed in macros, or command line, to accomodate viewing without the use
!   of cumbersome line code and GUI picking.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

positn_=arg1
!
*if,positn_,eq,'f',then
    /VIEW, 1 ,,,1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'back',then
    /VIEW, 1 ,,,-1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'l',then
    /VIEW, 1 ,-1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'r',then
    /VIEW, 1 ,1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'t',then
    /VIEW, 1 ,,1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'bot',then
    /VIEW, 1 ,,-1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'iso',then
    /VIEW, 1 ,1,1,1
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'o',then
    /VIEW, 1 ,1,2,3
    /ANG, 1
    /REP,FAST
*elseif,positn_,eq,'siso',then
    view,'iso'
    /USER, 1
    /DIST, 1,   4.70404142620
    /ANG,  1,  -118.200000000
    /REPLO
*endif
!
/AUTO, 1
/replot


w:\ansys\mac\tools\max_value.mac.html

!   TITLE:  max_value.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   05/10/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the maximum value from a set
!   of elements in an array. Input data necessary to run this macro:
!
!       anam = character name (use 6 or less) of the array to retrieve
!              maximum value from.  This macro will return the maximum
!              value to a parameter that is the character name of the
!              array with the letters 'mn' attached to the end (i.e., the
!              maximum value of the array rad(i,1) is returned as 'radmn';
!              the array z(i,j) returned as 'zmn'; etc.) If the returned
!              parameter exceeds 8 characters, just use the value
!              returned by the parameter 'max_val'.
!
!              NOTE:  Be cautioned that the value of the parameter
!                     'max_val' will be overwritten with each succesive
!                     use of this macro.
!
!       nrow = the number of rows in the array.
!
!       ncol = the number of columns if array is 2 or 3 dimensional.
!
!       npln = the number of planes if array is 3 dimensional.
!
!       dir = the direction of entities in the array in which to find the maximum.
!             It is the indical direction in which to iterate to find the
!             maximum:
!
!                   (1,2,3)  ====>  (row, column, plane)
!
!           1 = [DEFAULT] row iteration direction (the (r,X,Y) positions; iterate
!                                               over r holding X and Y constant)
!
!           2 = column iteration direction (the (X,c,Y) positions; iterate over
!                                           c holding X and Y constant)
!
!           3 = plane iteration direction ( the (X,Y,p) positions; iterate
!                                           over p holding X and Y constant)
!
!       pos1 = the row index position of the 1st element to begin iterations
!              with in searching for the maximum in the DIR direction. If
!              DIR=1, this parameter defaults to 1.
!
!       pos2 = the column index position of the 1st element to begin iterations
!              with in searching for the maximum in the DIR direction. If
!              DIR=2, this parameter defaults to 1.
!
!       pos3 = the plane index position of the 1st element to begin iterations
!              with in searching for the maximum in the DIR direction. If
!              DIR=3, this parameter defaults to 1.
!
!   *NOTE: If only a one dimensional array (column array) is queried, then
!          arguments 3 through 8 may be ignored.
!
!
!   ***** The output of this macro are:
!
!       1.) max_val  = the maximum value of the elements
!                      in the array
!
!       2.) max_indx  = the index of the maximum value element
!                       in the array
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!             (1)   (2)   (3)   (4)  (5)  (6)   (7)   (8)
! MAX_VALUE, anam, nrow, ncol, npln, dir, pos1, pos2, pos3
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

_anam=arg1
_nrow=arg2
_ncol=arg3
_npln=arg4
_dir=arg5
_pos1=arg6
_pos2=arg7
_pos3=arg8
!
!
*if,_nrow,eq,0,then         ! default # of ROWS value
    _nrow=1
*endif
!
*if,_ncol,eq,0,then         ! default # of COLUMNS value
    _ncol=1
*endif
!
*if,_npln,eq,0,then         ! default # of PLANES value
    _npln=1
*endif
!
*if,_dir,eq,0,then          ! default load direction value
    _dir=1
*endif
!
*if,_pos1,eq,0,then         ! default ROW position value
    _pos1=1
*endif
!
*if,_pos2,eq,0,then         ! default COLUMN position value
    _pos2=1
*endif
!
*if,_pos3,eq,0,then         ! default PLANE position value
    _pos3=1
*endif
!
*if,_dir,eq,1,then
    _pos1=1
*endif
!
*if,_dir,eq,2,then
    _pos2=1
*endif
!
*if,_dir,eq,3,then
    _pos3=1
*endif
!
!
*if,_dir,eq,1,then
    !
    *do,_nnn,1,_nrow,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_nnn,_pos2,_pos3)
        *else
            *if,_yyy,gt,%_anam%(_nnn,_pos2,_pos3),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_nnn,_pos2,_pos3)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_nrow,1
        *if,%_anam%(_nnn,_pos2,_pos3),eq,_yyy,then
            max_indx=_nnn
        *endif
    *enddo
*endif
!
!
*if,_dir,eq,2,then
    !
    *do,_nnn,1,_ncol,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_pos1,_nnn,_pos3)
        *else
            *if,_yyy,gt,%_anam%(_pos1,_nnn,_pos3),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_pos1,_nnn,_pos3)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_ncol,1
        *if,%_anam%(_pos1,_nnn,_pos3),eq,_yyy,then
            max_indx=_nnn
        *endif
    *enddo
*endif
!
!
*if,_dir,eq,3,then
    !
    *do,_nnn,1,_npln,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_pos1,_pos2,_nnn)
        *else
            *if,_yyy,gt,%_anam%(_pos1,_pos2,_nnn),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_pos1,_pos2,_nnn)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_npln,1
        *if,%_anam%(_pos1,_pos2,_nnn),eq,_yyy,then
            max_indx=_nnn
        *endif
    *enddo
*endif
!
!
max_val=_yyy
!
!
*set,_yyy,
*set,_nnn,
*set,_anam,
*set,_nrow,
*set,_ncol,
*set,_npln,
*set,_dir,
*set,_pos1,
*set,_pos2,
*set,_pos3,


w:\ansys\mac\tools\min_value.mac.html

!   TITLE:  min_value.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   05/10/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to retrieve the minimum value from a set
!   of elements in an array. Input data necessary to run this macro:
!
!       anam = character name (use 6 or less) of the array to retrieve
!              minimum value from.  This macro will return the minimum
!              value to a parameter that is the character name of the
!              array with the letters 'mn' attached to the end (e.g., the
!              minimum value of the array, rad(i,1), is returned as 'radmn';
!              the array z(i,j) returned as 'zmn'; etc.) If the returned
!              parameter exceeds 8 characters, just use the value
!              returned by the parameter 'min_val'.
!
!              NOTE:  Be cautioned that the value of the parameter
!                     'min_val' will be overwritten with each succesive
!                     use of this macro.
!
!       nrow = the number of rows in the array.
!
!       ncol = the number of columns if array is 2 or 3 dimensional.
!
!       npln = the number of planes if array is 3 dimensional.
!
!       dir = the direction of entities in the array in which to find the minimum.
!             It is the indical direction in which to iterate to find the
!             minimum:
!
!                   (1,2,3)  ====>  (row, column, plane)
!
!           1 = [DEFAULT] row iteration direction (the (r,X,Y) positions; iterate
!                                               over r holding X and Y constant)
!
!           2 = column iteration direction (the (X,c,Y) positions; iterate over
!                                           c holding X and Y constant)
!
!           3 = plane iteration direction ( the (X,Y,p) positions; iterate
!                                           over p holding X and Y constant)
!
!       pos1 = the row index position of the 1st element to begin iterations
!              with in searching for the minimum in the DIR direction. If
!              DIR=1, this parameter defaults to 1.
!
!       pos2 = the column index position of the 1st element to begin iterations
!              with in searching for the minimum in the DIR direction. If
!              DIR=2, this parameter defaults to 1.
!
!       pos3 = the plane index position of the 1st element to begin iterations
!              with in searching for the minimum in the DIR direction. If
!              DIR=3, this parameter defaults to 1.
!
!   *NOTE: If only a one dimensional array (column array) is queried, then
!          arguments 3 through 8 may be ignored.
!
!
!   ***** The output of this macro are:
!
!       1.) min_val  = the minimum value of the elements
!                      in the array
!
!       2.) min_indx  = the index of the minimum value element
!                       in the array
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!             (1)   (2)   (3)   (4)  (5)  (6)   (7)   (8)
! MIN_VALUE, anam, nrow, ncol, npln, dir, pos1, pos2, pos3
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

_anam=arg1
_nrow=arg2
_ncol=arg3
_npln=arg4
_dir=arg5
_pos1=arg6
_pos2=arg7
_pos3=arg8
!
!
*if,_nrow,eq,0,then         ! default # of ROWS value
    _nrow=1
*endif
!
*if,_ncol,eq,0,then         ! default # of COLUMNS value
    _ncol=1
*endif
!
*if,_npln,eq,0,then         ! default # of PLANES value
    _npln=1
*endif
!
*if,_dir,eq,0,then          ! default load direction value
    _dir=1
*endif
!
*if,_pos1,eq,0,then         ! default ROW position value
    _pos1=1
*endif
!
*if,_pos2,eq,0,then         ! default COLUMN position value
    _pos2=1
*endif
!
*if,_pos3,eq,0,then         ! default PLANE position value
    _pos3=1
*endif
!
*if,_dir,eq,1,then
    _pos1=1
*endif
!
*if,_dir,eq,2,then
    _pos2=1
*endif
!
*if,_dir,eq,3,then
    _pos3=1
*endif
!
!
*if,_dir,eq,1,then
    !
    *do,_nnn,1,_nrow,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_nnn,_pos2,_pos3)
        *else
            *if,_yyy,lt,%_anam%(_nnn,_pos2,_pos3),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_nnn,_pos2,_pos3)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_nrow,1
        *if,%_anam%(_nnn,_pos2,_pos3),eq,_yyy,then
            min_indx=_nnn
        *endif
    *enddo
*endif
!
!
*if,_dir,eq,2,then
    !
    *do,_nnn,1,_ncol,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_pos1,_nnn,_pos3)
        *else
            *if,_yyy,lt,%_anam%(_pos1,_nnn,_pos3),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_pos1,_nnn,_pos3)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_ncol,1
        *if,%_anam%(_pos1,_nnn,_pos3),eq,_yyy,then
            min_indx=_nnn
        *endif
    *enddo
*endif
!
!
*if,_dir,eq,3,then
    !
    *do,_nnn,1,_npln,1
        *if,_nnn,eq,1,then
            _yyy=%_anam%(_pos1,_pos2,_nnn)
        *else
            *if,_yyy,lt,%_anam%(_pos1,_pos2,_nnn),then
                _yyy=_yyy
            *else
                _yyy=%_anam%(_pos1,_pos2,_nnn)
            *endif
        *endif
    *enddo
    !
    *do,_nnn,1,_npln,1
        *if,%_anam%(_pos1,_pos2,_nnn),eq,_yyy,then
            min_indx=_nnn
        *endif
    *enddo
*endif
!
!
min_val=_yyy
!
!
*set,_yyy,
*set,_nnn,
*set,_anam,
*set,_nrow,
*set,_ncol,
*set,_npln,
*set,_dir,
*set,_pos1,
*set,_pos2,
*set,_pos3,


w:\ansys\mac\tools\arry_search.mac.html

!   TITLE:  arry_search.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/07/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro searches an array for a user specified element and
!   returns the indices of that element.
!
!   COMMAND SYNTAX:
!
!                        (1)       (2)
!        ARRY_SEARCH, arry_nam, arry_elem
!
!   ARGUMENTS:
!
!           arry_nam = the name of the array to be searched.
!
!           arry_elem = the element wihtin the array to search for.
!
!   DESCRIPTION:
!
!   This macro searches a user specified array for an element, and returns
!   the index positions of that element in an array called 'hit'. This array
!   is an N x 3 array, where N is the number of occurences ("hits") of the
!   element, and 3 is the index positions returned for each hit. Therefore,
!   a row is a particular element, and the 1st, 2nd and 3rd columns contain
!   the row, column and plane indices for that element, respectively.
!
!   If more than 1 element is found (and therefore, the 'hit' array has more
!   than 1 row), then each row is a particular element, with each column
!   containing an index. Therefore, 'hit' has the following form:
!
!                                        COLUMNS
!                       ROW     |   1   |   2   |   3   |
!                   -------------------------------------
!       1st hit -->     1       |   i1  |   j1  |   k1  |
!       2nd hit -->     2       |   i2  |   j2  |   k2  |
!       3rd hit -->     3       |   i3  |   j3  |   k3  |
!           .           .       |   .   |   .   |   .   |
!           .           .       |   .   |   .   |   .   |
!           .           .       |   .   |   .   |   .   |
!       Nth hit -->     N       |   iN  |   jN  |   kN  |
!
!   where, the iN, jN, and kN are the row, column and plane index positions
!   of the Nth element found in the array to be searched.
!
!   Additionally, the parameter 'hits' is the number of occurences (=N) of
!   a particular element in the array which is output by this macro.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

arrynam_=arg1
arryelm_=arg2
!
!
*get,hittyp_,parm,hit,type
!
*if,hittyp_,ne,-1,then
    *set,hit(1),
*endif
!
*get,rnum_,parm,%arrynam_%,dim,x
*get,colnum_,parm,%arrynam_%,dim,y
*get,plnnum_,parm,%arrynam_%,dim,z
!
rowhit_=0
!
*do,klm_,1,plnnum_,1
    *do,mno_,1,colnum_,1
        *do,nop_,1,rnum_,1
            *if,%arrynam_%(nop_,mno_,klm_),eq,arryelm_,then
                *if,rowhit_,eq,0,then
                    *dim,hit,array,1,3
                    !
                    hit(1,1)=nop_
                    hit(1,2)=mno_
                    hit(1,3)=klm_
                    !
                    *get,rowhit_,parm,hit,dim,x
                *else
                    *dim,buffer_,array,rowhit_+1,3
                    !
                    *do,abc_,1,rowhit_,1
                        buffer_(abc_,1)=hit(abc_,1)
                        buffer_(abc_,2)=hit(abc_,2)
                        buffer_(abc_,3)=hit(abc_,3)
                    *enddo
                    !
                    *set,hit(1),
                    !
                    *dim,hit,array,rowhit_+1,3
                    !
                    *do,abc_,1,rowhit_,1
                        hit(abc_,1)=buffer_(abc_,1)
                        hit(abc_,2)=buffer_(abc_,2)
                        hit(abc_,3)=buffer_(abc_,3)
                    *enddo
                    !
                    hit(rowhit_+1,1)=nop_
                    hit(rowhit_+1,2)=mno_
                    hit(rowhit_+1,3)=klm_
                    !
                    *get,rowhit_,parm,hit,dim,x
                    !
                    *set,buffer_(1),
                *endif
            *endif
        *enddo
    *enddo
*enddo
!
hits=rowhit_
!
*set,nop_,
*set,mno_,
*set,klm_,
*set,abc_,
*set,rowhit_,
*set,arrynam_,
*set,arryelm_,
*set,hittyp_,
*set,rnum_,
*set,colnum_,
*set,plnnum_,


l:\ansys\mac\tools\array_append.mac.html

! TITLE:  array_append.mac (MANAGEMENT)
!
!----------------------------------------------------------------------
! Rev: -    03/04/02       J. Judd
!----------------------------------------------------------------------
!
! OBJECTIVE:
!
!  Append character array to end of 2nd character array.
!
! COMMAND SYNTAX:
!
!                 (1)    (2)
!  array_append,'AFrom','ATo'
!
!   Note: arguments in single quotes are strings and must be entered in ' '.
!
! ARGUMENTS:
!
!  AFrom = array name in single quotes which data will come from.
!    ATo = array name in single quotes which will be appended to.
!
! DESCRIPTION:
!
! WARNING:
!
! EXAMPLES:
!
!
! TO BE DONE:
!
! - Add number and string array capability
! - Add column and plane capability
! - How not need to verify *set or *Dim with Popup?
! - Option to place From Array at different locations in To array
!   e.g. not just append to end.
! - Error checking
!
!---------------------------------------------------------------------------
*get,prkey_,active,,prkey
/nopr

AFrom_=ARG1
ATo_=ARG2

!- Error Check: input arguments are existing arrays?
!Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar, 4=character array, -1=undefined Parameter.
!*GET,TFrom_,PARM,%AFrom_%,TYPE
!*GET,TTo_,PARM,%ATo_%,TYPE

!- Error Check: ATo_ array type is compatible with AFrom_ data?
!               Example: can't put characters into normal (number) array.

!- Determine sizes of arrays
*GET,XFrom_,PARM,AFrom_,DIM,X
*GET,XTo_,PARM,ATo_,DIM,X

!- Copy both arrays to ATemp_
*DIM,ATemp_,CHAR,(XTo_+XFrom_)
*DO,AR21,1,XTo_
   ATemp_(AR21)=ATo_(AR21)
*ENDDO

*DO,AR21,1,XFrom_
   ATemp_(XTo_+AR21)=AFrom_(AR21)
*ENDDO

!- ReDim ATo_; Copy ATemp_ to ATo_; Erase ATemp_
!  How not need to verify *set or *Dim with Popup?
*set,%ATo_%(1)
*DIM,%ATo_%,CHAR,(XTo_+XFrom_)
*DO,AR21,1,(XTo_+XFrom_)
   %ATo_%(AR21)=ATemp_(AR21)
*ENDDO

!- Delete internal parameters and arrays
*set,AFrom_
*set,ATo_
*set,XFrom_
*set,XTo_
*set,ATemp_(1)

*if,prkey_,eq,1,then
  /gopr


l:\ansys\mac\tools\array_copy.mac.html

! TITLE:  array_copy.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!   Rev -   02/26/02    J. Judd
!---------------------------------------------------------------------------
!
! OBJECTIVE:
!
!   Copy a current array to a new array
!
! COMMAND SYNTAX:
!
!   array_copy,'From','To'
!
!   Note: arguments in single quotes are strings and must be entered in ' '.
!
! ARGUMENTS:
!
!   'From' = name of current array from which to copy.
!   'To'   = name of new array to which to copy.
!
! DESCRIPTION:
!
!   Creates a new array and then copies the old array to the new array.
!   Works with one dimensional or multi-dimensional arrays, character arrays, or tables.
!
! WARNINGS:
!
!  - Not supported by ANSYS ED
!  - Contains __ levels of *IF/*DO constructs.  Maximimum is __ levels.
!  - Assume currently that do not have oddly defined matrix (e.g. 1x1x50)
!
!---------------------------------------------------------------------------
*get,prkey_,active,,prkey
/nopr

!- Check that arguments are character scalars
*GET,AR91,PARM,ARG1,TYPE
*GET,AR92,PARM,ARG2,TYPE
*IF,AR91,NE,3,OR,AR92,NE,3,THEN
   AR25='stop'
   *MSG,WARN
   Arguments 'From' +/or 'To' are not entered as strings.%/ &
   Use single quotes around array names.%/ &
   Command aborted.
*ELSE
   !- Get Dimensions of 'From' matrix -
   *GET,AR21,PARM,ARG1,DIM,X
   *GET,AR22,PARM,ARG1,DIM,Y
   *GET,AR23,PARM,ARG1,DIM,Z

   !- Get Type of matrix and error check
   *GET,AR24,PARM,%ARG1%,TYPE
      ! 0=scalar, 1=array, 2=table, 3=character scalar,
      ! 4=character array, -1=undefined Parameter.
   *IF,AR24,EQ,0,OR,AR24,EQ,3,THEN
      AR25='stop'
      *MSG,WARN
      The 'From' matrix entered is either a scalar or chararacter scalar.%/ &
      Command Aborted.
   *ELSEIF,AR24,EQ,-1,THEN
      AR25='stop'
      *MSG,WARN
      The 'From' matrix entered is an undefined parameter.%/ &
      Command Aborted.
   *ELSEIF,AR24,EQ,1,THEN
      AR25='array'
   *ELSEIF,AR24,EQ,2,THEN
      AR25='table'
   *ELSEIF,AR24,EQ,4,THEN
      AR25='char'
   *ENDIF
*ENDIF  !(AR91 NOR AR92 = 3)
!--------------------------------
*IF,AR25,NE,'stop',THEN

   !- Dimension 'To' matrix
   *IF,AR22,EQ,1,AND,AR23,EQ,1,THEN
      *DIM,ARG2,%AR25%,AR21
   *ELSEIF,AR23,EQ,1,THEN
      *DIM,ARG2,%AR25%,AR21,AR22
   *ELSE
      *DIM,ARG2,%AR25%,AR21,AR22,AR23
   *ENDIF

   !- Transfer values
   !  (*VFUN,,COPY,, does not work for characters arrays and only does one column at a time)
   *IF,AR22,EQ,1,AND,AR23,EQ,1,THEN
      *DO,AR70,1,AR21
          %ARG2%(AR70)=%ARG1%(AR70)
      *ENDDO
   *ELSEIF,AR23,EQ,1,THEN
      *DO,AR70,1,AR21
          *DO,AR71,1,AR22
              %ARG2%(AR70,AR71)=%ARG1%(AR70,AR71)
          *ENDDO
      *ENDDO
   *ELSE
      *DO,AR70,1,AR21
          *DO,AR71,1,AR22
              *DO,AR72,1,AR23
                 %ARG2%(AR70,AR71,AR72)=%ARG1%(AR70,AR71,AR72)
              *ENDDO
          *ENDDO
      *ENDDO
   *ENDIF
*ENDIF  !(AR25 NE stop)

*if,prkey_,eq,1,then
  /gopr


w:\ansys\mac\tools\entity_array.mac.html

!   TITLE:  entity_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   05/13/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro retrieves a selected set of solid modeling entities
!   and stores them in an array of a user specified name.  The following
!   choice of entities are:
!
!                       ENTITY
!                      --------
!                       keypoint
!                       line
!                       area
!                       volume
!                       node
!                       element
!
!   Input arguments are:
!
!       A selected set of specified entities
!
!       entity = 'k' for keypoint entities
!                'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!                'n' for node entities
!                'e' for element entities
!
!       aname = character name for array
!
!       typ = array type:
!
!           'array' = normal (default) array
!           'table' = table array
!
!       dir = the direction of placement of the entities in the array .  It
!             is the indical direction in the index positions:
!
!                   (1,2,3)  ====>  (row, column, plane)
!
!           1 = [DEFAULT] store entities in each row (the (r,1,1) positions)
!
!           2 = store entities in each column (the (1,c,1) positions)
!
!           3 = store entities in each plane (the (1,1,p) positions)
!
!       #rows = The number of rows in the array. If DIR = 1, then the number
!               of rows is automatically determined by the number of entities
!               to be stored, and this argument is ignored.
!
!       #col = The number of columns in the array. If DIR = 2, then the number
!              of columns is automatically determined by the number of entities
!              to be stored, and this argument is ignored.
!
!       #pln = The number of planes in the array. If DIR = 3, then the number
!              of planes is automatically determined by the number of entities
!              to be stored, and this argument is ignored.
!
!   *NOTE: If only a one dimensional array (column array) is desired, then
!          arguments 4 through 7 may be ignored.
!
!
!   ***** Output for this macro:
!
!       1.) An array of the user specified name
!
!       2.) ecount = the number of entities (elements) in
!                    the array
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                (1)     (2)   (3)  (4)   (5)    (6)   (7)
! ENTITY_ARRAY, entity, aname, typ, dir, #rows, #col, #pln
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

_entity=arg1
_aname=arg2
_typ=arg3
_dir=arg4
_nrow=arg5
_ncol=arg6
_npln=arg7
!
!
*if,_nrow,eq,0,then
    _nrow=1
*endif
!
*if,_ncol,eq,0,then
    _ncol=1
*endif
!
*if,_npln,eq,0,then
    _npln=1
*endif
!
*if,_dir,eq,0,then
    _dir=1
*endif
!
!
*if,_entity,eq,'k',then     ! assignment of entity variable, '_ev'
    _ev='kp'
*elseif,_entity,eq,'l',then
    _ev='line'
*elseif,_entity,eq,'a',then
    _ev='area'
*elseif,_entity,eq,'v',then
    _ev='volu'
*elseif,_entity,eq,'n',then
    _ev='node'
*elseif,_entity,eq,'e',then
    _ev='elem'
*else
    _ev='z'
    *msg,warn,
    Invalid Entity Option. Use k, l, a, v, n or e
*endif
!
*if,_ev,ne,'z',then       ! If ev is assigned 'z', then abort
    !
    *get,_emin,_ev,,num,min   ! retrieve MIN keypoint numbers
    *get,ecount,_ev,,count    ! Retieve # of specified entities in the
    !                         ! selected entity set.
    !
    !------------------- Store Entities in an Array -----------------
    !
    !
    *if,_dir,eq,1,then
        !
        *dim,%_aname%,_typ,ecount,_ncol,_npln       ! dimension array
        !
        *do,_iii,1,ecount,1
            *if,_iii,eq,1,then
                %_aname%(_iii,1,1)=_emin
            *else
                _jjj=_iii-1
                *get,_xxx,_ev,%_aname%(_jjj,1,1),nxth
                %_aname%(_iii,1,1)=_xxx
            *endif
        *enddo
    *endif
    !
    !
    *if,_dir,eq,2,then
        !
        *dim,%_aname%,_typ,_nrow,ecount,_npln       ! dimension array
        !
        *do,_iii,1,ecount,1
            *if,_iii,eq,1,then
                %_aname%(1,_iii,1)=_emin
            *else
                _jjj=_iii-1
                *get,_xxx,_ev,%_aname%(1,_jjj,1),nxth
                %_aname%(1,_iii,1)=_xxx
            *endif
        *enddo
    *endif
    !
    !
    *if,_dir,eq,3,then
        !
        *dim,%_aname%,_typ,_nrow,_ncol,ecount       ! dimension array
        !
        *do,_iii,1,ecount,1
            *if,_iii,eq,1,then
                %_aname%(1,1,_iii)=_emin
            *else
                _jjj=_iii-1
                *get,_xxx,_ev,%_aname%(1,1,_jjj),nxth
                %_aname%(1,1,_iii)=_xxx
            *endif
        *enddo
    *endif
    !
    !
    !----------------------------------------------------------------
    !
*endif
!
*set,_xxx,
*set,_iii,
*set,_jjj,
*set,_entity,
*set,_emin,
*set,_typ,
*set,_aname,
*set,_ev,
*set,_nrow,
*set,_ncol,
*set,_npln,
*set,_dir,


w:\ansys\mac\tools\par_array.mac.html

!   TITLE:  par_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   07/22/2000      J. Rinaldi
!       Rev A   08/11/2001      D. Edwards
!               Convert to Perl for speed. Maintain exact same
!               functionality.
!---------------------------------------------------------------------------
!
!   This sub-macro creates a character array containing all active parameters
!   in the database, and a scalar array containing their corresponding values.
!   The only input necessary is a user specified array character name. This
!   name is the name of the array that will store all parameters of a given
!   parameter file.  The input name must be 5 characters or less, and will
!   also be used for the parameter value array.
!
!               pararnam = parameter file array name.  This name must be 5
!                          characters or less.
!
!   Both arrays will start with the character name as specidied in 'pararnam'.
!   However, the parameter value array name will end with a 'v' (-----v).
!   Therefore, the value array is just the parameter name array with a 'v'
!   attached to the end.
!
!   Only numeric scalar parameters are stored in the array.  These
!   parameters are deleted once stored.
!
!   Character scalars, arrays and parameters prefixed with an
!   underscore, "_" are not stored and are not deleted.
!
!   This macro also updates the system arrays:
!
!       PARFMXI
!       PAR_FILE
!       PFMXIBUF
!       PARFBUFF
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! PAR_ARRAY, pararnam
!
!---------------------------------------------------------------------------
!

*get,prkey_,active,0,prkey
/nopr

! pararnam=arg1
!
parsav,all,par_array,in
!
/syp,par_array.pl,arg1
!
parres,new,par_array,out


w:\ansys\mac\tools\par_array.pl.html

#!/usr/local/bin/perl
#
#   TITLE:  par_array.mac (MANAGEMENT)
#
#---------------------------------------------------------------------------
#       Rev -   07/22/2000      J. Rinaldi
#       Rev A   08/11/2001      D. Edwards
#               Convert to Perl for speed. Maintain exact same
#               functionality.
#---------------------------------------------------------------------------
#
#   This sub-macro creates a character array containing all active parameters
#   in the database, and a scalar array containing their corresponding values.
#   The only input necessary is a user specified array character name. This
#   name is the name of the array that will store all parameters of a given
#   parameter file.  The input name must be 5 characters or less, and will
#   also be used for the parameter value array.
#
#               pararnam = parameter file array name.  This name must be 5
#                          characters or less.
#
#   Both arrays will start with the character name as specidied in 'pararnam'.
#   However, the parameter value array name will end with a 'v' (-----v).
#   Therefore, the value array is just the parameter name array with a 'v'
#   attached to the end.
#
#   Ansys macro par_array.mac creates the parameter file "par_array.in"
#   and calls this Perl script.  This script creates "par_array.out" and
#   then par_array.mac replaces the current database parameters with those in
#   par_array.out.
#
#   par_array.out is written with the following properties:
#
#   1. Only numeric scalar parameters are stored in the part array.  These
#   parameters are deleted once stored.
#
#   2. Character scalars, arrays and parameters prefixed with an
#   underscore are not stored in Ansys array and are not deleted.
#
#   3. Append the PARFMXI and other arrays with the maximum index of
#   the part array, pararnam.
#
#------------------------------ COMMAND SYNTAX -----------------------------
#
# par_array.pl pararnam
#
#-----------------------------------------------------------------
#

$pararnam = $ARGV[0];
$pararnam =~ tr/a-z/A-Z/;

$fin  = "par_array.in";
$fout = "par_array.out";

#
#------------------------ Open Input/Output Files ----------------
#
open(IN,  "par_array.in")  || die "Unable to open $fin";
open(OUT, ">par_array.out") || die "Unable to create/open $fout";

#
#------------------------ Handle PARFMXI Arrays  ------------------
#

%parmxi = ();
$parmxi{PARFBUFF} = 1;
$parmxi{'PARFMXI '}  = 1;
$parmxi{PAR_FILE} = 1;
$parmxi{PFMXIBUF} = 1;

#
#------------------------- Process Input File --------------------
#

print OUT "/NOPR\n";

# Scan through input file one time, storing data in hash, output file as
# needed.

LINE: while (<IN>) {

    s/\015?\012/\n/;            # Handle DOS and UNIX ASCII

    # Process all arrays
    if (/^\*DIM/) {

        ($junk, $name) = split(/,/);

        if ($parmxi{$name} == 1) {
            func_parmxi();      # Uses $_ and $name
            redo LINE;
        }

        print OUT;

        if ($name eq 'ASSM_PAR') {

            # Process the special "ASSM_PAR" array
            while (<IN>) {

                s/\015?\012/\n/;            # Handle DOS and UNIX ASCII

                if (/$name/) {

                    /'(.*)'/;
                    $assm_par{$1} = 1;

                    print OUT;

                } else {

                    redo LINE;
                }
            }

        } else {

            # Process all other arrays
            while (<IN>) {

                s/\015?\012/\n/;            # Handle DOS and UNIX ASCII

                if (/$name/) {

                    print OUT;

                } else {

                    redo LINE;
                }
            }
        }
    }

    # Process all non-array parameters
    if (/^\*SET/) {

        # Write char scalars to OUT and read numeric scalars into a hash
        # Do not store _XXX parms in hash
        if (/'/) {

            print OUT "$_";

        } else {

            ($junk, $name) = split(/,/);

            if ($name =~ /^_/) {

                print OUT;

            } else {

                $num_parms{$name} = $_;
            }
        }
    }
}

#
#---------------------------- Write Output File ---------------------------
#

$count = 0;

for $name (sort keys %num_parms) {

    if ( $assm_par{$name} == 1 ) {

        # $name is in assm_par, therefore print it to OUT only
        print OUT $num_parms{$name};

    } else {

        # Store an entry in the part name array
        $line = sprintf("*SET,%-8s(%8u,       1,       1),'%s'\n",
                    $pararnam,++$count,$name);
        push @pnam, $line;

        # Store an entry in the part value array
        ($junk, $junk1, $value) = split(/,/, $num_parms{$name});
        $line = sprintf("*SET,%-8s(%8u,       1,       1),%s",
                    "${pararnam}V",$count,$value);
        push @pval, $line;

    }
}

# Write out the part name and value arrays

$count++;       # Add one for appended XXXmxi entry at end <- Needs to go!

printf OUT "*DIM,%-8s,CHAR,%8u,       1,       1\n", $pararnam, $count;

foreach (@pnam) {
    print OUT;
}

$mxi = "${pararnam}mxi";
$mxi =~ tr/A-Z/a-z/;
printf OUT "*SET,%-8s(%8u,       1,       1),'%s'\n", $pararnam,$count,$mxi;

printf OUT "*DIM,%-8s,ARRAY,%8u,       1,       1\n", "${pararnam}V", $count;

foreach (@pval) {
    print OUT;
}

printf OUT "*SET,%-8s(%8u,       1,       1),%u\n",
                "${pararnam}V",$count,$count;

# Print all the MXI crap

foreach (@mxi_dim_list) {
    if ($mxi_cnt) {
        @f = split (/,/);
        $f[3] = sprintf("%8u",$f[3]+1);
        $_ = "$f[0],$f[1],$f[2],$f[3],$f[4],$f[5]";
    }
    print OUT;
}

foreach (@mxi_parfmxi) {
    print OUT;
}
printf OUT "*SET,PARFMXI (%8u,       1,       1), %u\n",$mxi_cnt+1,$count;

foreach (@mxi_par_file) {
    print OUT;
}
printf OUT "*SET,PAR_FILE(%8u,       1,       1),'%-8s'\n",
                $mxi_cnt+1,$ARGV[0];

print OUT "/GO\n";

#
#------------------------ Close Input/Output Files --------------------------
#

close(IN);
close(OUT);

sub func_parmxi {

    push @mxi_dim_list, $_;

    if ($name eq "PARFBUFF" || $name eq "PFMXIBUF") {

        $_ = <IN>;      # Get the next line
        return;
    }

    @mxi_set_list=();
    $mxi_cnt=0;

    while (<IN>) {

        if (/$name/) {

            $mxi_cnt++;

            s/\015?\012/\n/;            # Handle DOS and UNIX ASCII
            push @mxi_set_list, $_;

        } else {

            last;
        }
    }

    if ($name eq 'PARFMXI ') {
        @mxi_parfmxi = @mxi_set_list;
    } else {
        @mxi_par_file = @mxi_set_list;
    }
}


w:\ansys\mac\tools\entity_file.mac.html

!   TITLE:  entity_file.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   08/22/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro stores a selected set of solid modeling entities in an
!   array of a user specified name.  The entity is filed away by its centroid
!   coordinates, X, Y and Z. Therefore, the entity may change number, but can
!   be selected by its centroidal center.
!
!   The following choice of entities are:
!
!                           ENTITY
!                          --------
!                           keypoint
!                           line
!                           area
!                           volume
!
!   Input for this macro are:
!
!           1.) A selected set of specified entities
!
!           2.) entity = 'k' for keypoint entities
!                        'l' for line entities
!                        'a' for area entities
!                        'v' for volume entities
!
!           3.) aname = character name for array
!
!           4.) use_decn = use decision. This parameter allows the user
!                          to decide whether to calculate the centroid
!                          for individual entities or a group of entities.
!
!                           0 (or blank) = individual
!                           1 = group
!
!                       ** NOTE: If use_decn = 1, then no arrays will be
!                                returned, and therefore 'aname' may be
!                                left blank.
!
!   The parameter 'arg_decn' is used to decide whether the argument 'default'
!   is to be used on the entity summary commands, 'ksum', 'asum', 'lsum' and
!   'vsum', since 'ksum' and 'lsum' do not have arguments.
!
!   Output for this macro:
!
!       1.) An array of the user specified name containing the centroid
!           triplets, X, Y and Z.
!
!                               ****** OR ******
!
!       2.) The centroid coordinate values of the respective selected
!           entities:
!
!               K_X_CNT, K_Y_CNT, K_Z_CNT  ---> keypoints
!
!               L_X_CNT, L_Y_CNT, L_Z_CNT  ---> lines
!
!               A_X_CNT, A_Y_CNT, A_Z_CNT  ---> areas
!
!               V_X_CNT, V_Y_CNT, V_Z_CNT  ---> volumes
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! ENTITY_FILE, entity, aname, use_decn
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

entity1=arg1
anam1=arg2
use_decn=arg3
!
!
*if,entity1,eq,'k',then
    ev1='kp'
    argdecn=0
    sum_parm='ksum'
*elseif,entity1,eq,'l',then
    ev1='line'
    argdecn=0
    sum_parm='lsum'
*elseif,entity1,eq,'a',then
    ev1='area'
    argdecn=1
    sum_parm='asum'
*elseif,entity1,eq,'v',then
    ev1='volu'
    argdecn=1           ! argument decision parameter
    sum_parm='vsum'
*else
    ev1='z'             ! If entity is not a 'k','l','a','v','n'
*endif                  ! or 'e' then assign 'ev1' the dummy variable 'z'.
!
!
*if,ev1,ne,'z',then                 ! If ev1 is assigned 'z', then abort
    !
    *if,use_decn,eq,0,then
        !
        entity_array,'%entity1%','%entity1%_set','array'
        !
        *dim,%anam1%,array,ecount+1,3         ! Initialize array
        !
        !-------------- Store Centroid X, Y & Z in Array ------------
        !
        %anam1%(1,1,1)=ecount+1
        !
        *do,iii,2,ecount+1,1
            !
            %entity1%sel,s,ev1,,%entity1%_set(iii-1,1)
            !
            *if,argdecn,eq,1,then
                %sum_parm%,default
            *else
                %sum_parm%
            *endif
            !
            *get,%entity1%_x_cnt,ev1,,cent,x
            *get,%entity1%_y_cnt,ev1,,cent,y
            *get,%entity1%_z_cnt,ev1,,cent,z
            !
            %anam1%(iii,1,1)=%entity1%_x_cnt
            %anam1%(iii,2,1)=%entity1%_y_cnt
            %anam1%(iii,3,1)=%entity1%_z_cnt
        *enddo
        !
        !------------------------------------------------------------
        !
    *else
        *if,argdecn,eq,1,then
            %sum_parm%,default
        *else
            %sum_parm%
        *endif
        !
        *get,%entity1%_x_cnt,ev1,,cent,x
        *get,%entity1%_y_cnt,ev1,,cent,y
        *get,%entity1%_z_cnt,ev1,,cent,z
    *endif
*endif
!
init_entity_num
!
lplot
!
*if,use_decn,eq,0,then
    *set,%entity1%_x_cnt,
    *set,%entity1%_y_cnt,
    *set,%entity1%_z_cnt,
    *set,%entity1%_set(1),
*endif
!
*set,iii,
*set,ev1,
*set,anam1,
*set,entity1,
*set,use_decn,
*set,argdecn,
*set,sum_parm,


w:\ansys\mac\tools\ang_array.mac.html

!   TITLE:  ang_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      04/18/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an array of angular dimensions, where each
!   element of the array corresponds to a specific angle in the array.
!
!
!   COMMAND SYNTAX:
!
!                     (1)      (2)      (3)      (4) . . . . . . (19)
!        ANG_ARRAY, num_ang, angle#1, angle#2, angle#3,......, angle#18
!
!
!   ARGUMENTS:
!
!           num_ang = the number of angle dimensions.
!
!           angle#n = the nth anglular dimension.
!
!
!   DESCRIPTION:
!
!   The array can be input up to 18 elements.  These angles are the
!   volume interval distances around a circle that the user defines for
!   input into PROFILE_BORE.MAC. This allows for the user to specify a
!   special shaped profile volume at the angular intervals of this array.
!   All angles must be placed in a clockwise order for correct execution
!   in ANG_DIFF.MAC.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_ang=arg1
!
*dim,ang,array,num_ang
!
*do,ii_,2,(num_ang+1),1
    !
    jj_=ii_-1
    !
    *if,ii_,lt,10,then
        *if,arg%ii_%,lt,0,then
            xx_=arg%ii_%+360
            ang(jj_,1)=xx_
        *else
            ang(jj_,1)=arg%ii_%
        *endif
    *else
        *if,ar%ii_%,lt,0,then
            xx_=ar%ii_%+360
            ang(jj_,1)=xx_
        *else
            ang(jj_,1)=ar%ii_%
        *endif
    *endif
*enddo
!
*set,ii_,
*set,jj_,
*set,xx_


w:\ansys\mac\tools\ln_array.mac.html

!   TITLE:  ln_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/17/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates an array of line numbers, where each element
!   of the array is an individual line number. The array can be input up
!   to 18 line numbers.
!
!           num_lns = the total number of lines to be stored in the
!                     array.
!
!           line#n = the line numbers to be stored in the array.  The lines
!                    will be stored in the order in which they are entered.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! LN_ARRAY, num_lns, line#1, line#2, line#3,......, line#18
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_lns=arg1
!
*dim,ln,array,num_lns
!
*do,ii,2,(num_lns+1),1
    jj=ii-1
    *if,ii,lt,10,then
        ln(jj,1)=arg%ii%
    *else
        ln(jj,1)=ar%ii%
    *endif
*enddo
!
*do,ii,1,num_lns,1
    *if,ii,eq,1,then
        lsel,s,line,,ln(ii,1)
    *else
        lsel,a,line,,ln(ii,1)
    *endif
*enddo
!
cm,lnarset,line


w:\ansys\mac\tools\depth.mac.html

!   TITLE:  depth.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  04/18/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates an array of axial dimensions, where each
!   element of the array corresponds to a specific radial point in the
!   array macro RADIUS.MAC. The array can be input up to 18 elements.
!   These axial distances are the distances to each point in the volume
!   profile defined by the user as input into PROFILE_BORE.MAC. This
!   allows for the user to specify a special shaped profile volume at the
!   angular intervals defined by ANG_ARRAY.MAC.
!
!   num_pnt = # of keypoints to create profile at the varying radii.
!
!   z#n = axial distance (z distance) of point n, which is the bore depth
!         of each point.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! DEPTH, num_pnt, z#1, z#2, z#3,......, z#18
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_pnt=arg1
!
*dim,z_,array,num_pnt
!
*do,ii,2,(num_pnt+1),1
    jj=ii-1
    *if,ii,lt,10,then
        z_(jj,1)=arg%ii%
    *else
        z_(jj,1)=ar%ii%
    *endif
*enddo
!
*set,ii,
*set,jj,


w:\ansys\mac\tools\radius.mac.html

!   TITLE:  radius.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/18/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates an array of radial dimensions, where each
!   element of the array corresponds to a specific radius in the array.
!   The array can be input up to 18 elements.  These radii are the
!   distances to each point in the volume profile defined by the user as
!   input into PROFILE_BORE.MAC. This allows for the user to specify a
!   special shaped profile volume at the angular intervals defined by
!   ANG_ARRAY.MAC.
!
!   num_rad = # of radii values to create the profile. The number of these
!             radii is always 1 less than the 'num_pnt' value specified
!             in DEPTH.MAC when used for PROFILE_BORE.MAC. This is due to
!             the last point in DEPTH.MAC being along the axis of rotation,
!             and therefore has a 0 (zero) radius.
!
!   radius#n = (non-zero) radial distance of point n.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! RADIUS, num_rad, radius#1, radius#2, radius#3,......, radius#18
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_rad=arg1
!
*dim,rad,array,num_rad
!
*do,ijk_,2,(num_rad+1),1
    !
    jkl_=ijk_-1
    !
    *if,ijk_,lt,10,then
        rad(jkl_,1)=arg%ijk_%
    *else
        rad(jkl_,1)=ar%ijk_%
    *endif
*enddo
!
*set,ijk_,
*set,jkl_,


w:\ansys\mac\tools\surf_shape_cut.mac.html

!   TITLE:  surf_shape_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      11/28/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates an array of angular dimensions, where each
!   element of the array corresponds to a specific angle in the array.
!   The array can be input up to 18 elements.  These angles are the
!   volume interval distances around a circle that the user defines for
!   input into PROFILE_BORE.MAC. This allows for the user to specify a
!   special shaped profile volume at the angular intervals of this array.
!   All angles must be placed in a clockwise order for correct execution
!   in ANG_DIFF.MAC.
!
!
!------------------------ COMMAND SYNTAX / OPTION 1 ------------------------
!
!                 (1)   (2)    (3)    (4)    (5)     (6)     (7)
! SURF_SHAPE_CUT, opt, xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc,
!
!                 dia_cut
!                      (8)    (9)    (10) (11) (12) (13)    (14)    (15)
!
!-------------------------------- OPTION 2 ---------------------------------
!
!                 (1)   (2)  (3)  (4)   (5)    (6)    (7)
! SURF_SHAPE_CUT, opt,  p1,  p2,  p3, dia_cut
!
!-------------------------------- OPTION 3 ---------------------------------
!
!                    (1)  (2)     (3)    (4)    (5)    (6)    (7)
! SURF_SHAPE_CUT, opt, acs1, dia_cut
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*get,_acs_,active,,csys
!
cm,v2bcut,volu          ! selected volume to be (2b) cut
!
opt=arg1
!
*if,opt,eq,1,then
    xcutc=arg2
    ycutc=arg3
    zcutc=arg4
    !
    rotxyc=arg5
    rotyzc=arg6
    rotzxc=arg7
    !
    dia_cut=arg8
    dcut_=arg9
    phibev=ar10
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
*if,opt,eq,2,then
    p1=arg2
    p2=arg3
    p3=arg4
    !
    dia_cut=arg5
    dcut_=arg6
    phibev=arg7
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
*if,opt,eq,3,then
    acs1=arg2
    !
    dia_cut=arg3
    dcut_=arg4
    phibev=arg5
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
init_entity_num
!


w:\ansys\mac\tools\wall_dimn.mac.html

!   TITLE:  wall_dimn.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     04/17/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates an array of wall thickness dimensions, where
!   each element of the array corresponds to the line number in LN_ARRAY.MAC
!   The array can be input up to 18 elements.  These dimensions are the
!   perpendicular distances from each corresponding line in LN_ARRAY.MAC
!   This allows for the user to specify custom pocket cuts of varying wall
!   thickness from each of the specified lines in the macro, U_SPE_POC_CUT.MAC.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! WALL_DIMN, num_lns, wallthk#1, wallthk#2, wallthk#3,......, wallthk#18
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

num_lns=arg1
!
*dim,wall,array,num_lns
!
*do,i,2,(num_lns+1),1
    j=i-1
    *if,i,lt,10,then
        wall(j,1)=arg%i%
    *else
        wall(j,1)=ar%i%
    *endif
*enddo


l:\ansys\mac\tools\ln_fillet.mac.html

!   TITLE:  ln_fillet.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/27/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     01/14/2002    J. Rinaldi
!
!           Made provision for filleting all newly created and/or unattached
!           lines that may be selected by the 'isolate_lines' command.
!---------------------------------------------------------------------------
!       Rev B     03/27/2002    J. Rinaldi
!
!           Made provision for creating a KP at the fillet arc center.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a line fillet(s) at the specified junction key-
!   point(s).
!
!
!   COMMAND SYNTAX:
!
!                   (1)   (2)      (3)
!        LN_FILLET, jkp, radius, kp@cntr
!
!
!   ARGUMENTS:
!
!       (1) jkp = the keypoint number adjoining 2 lines to be filleted. This
!                 is a specific keypoint number (an integer value > or = to 0).
!
!               Otherwise:
!
!                   0 (or blank) = all selected keypoints adjoining two
!                                  lines will be filleted
!
!                   -1 = all keypoints adjoining two lines will be filleted,
!                        where the lines to be filleted are newly created and/or
!                        unattached (to areas and/or volumes) lines. (these
!                        lines may be selected by the 'isolate_lines' command).
!
!
!       (2) radius = the radius of the fillet.
!
!       (3) kp@cntr = generates KP at the center point of the fillet radii:
!
!                   0 (or blank) = no center keypoint is generated.
!
!                   km + N = generates a KP at fillet arc center, assigning
!                            this arguments value as the KP number. This arg-
!                            ument must be specified as the maximum KP number,
!                            km, plus some offset value, N, which must be greater
!                            than 2.
!
!
!   DESCRIPTION:
!
!   This macro creates a fillet between 2 lines sharing the keypoint specified
!   in argument 1, 'jkp', with the fillet radius specified in argument 2.
!
!   If it is desired to create more than 1 fillet with the same radii, then
!   select all keypoints at the junction of the lines that are desired to be
!   filleted, and leave argument 1 blank. Fillets will be created at these
!   selected keypoints.
!
!   If any of the selected keypoints, or the specified keypoint 'jkp', are
!   not attached to only 2 lines, the algorithm will abort the fillet creation
!   at that keypoint, and proceed to the next junction keypoint in the selected
!   set, if more than 1 keypoint is selected.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr
!
jkp_=arg1
rad_=arg2
cntrkp_=arg3
!
*if,jkp_,le,0,then
    *if,jkp_,eq,-1,then
        isolate_lines
        ksll,s
    *endif
    !
    entity_array,'k','filkp_','array'
    numkps_=ecount
    !
    *do,abc_,1,numkps_,1
        ksel,s,kp,,filkp_(abc_,1)
        lslk,s,0
        !
        *get,lcnt_,line,,count
        get_max_entity
        get_min_entity
        !
        *if,lcnt_,eq,2,then
            *if,cntrkp_,gt,0,then
                *if,abc_,eq,1,then
                    kpoffst_=cntrkp_-km
                *else
                    cntrkp_=cntrkp_+kpoffst_
                *endif
            *endif
            !
            lfillt,l_min,lm,rad_,cntrkp_
        *endif
    *enddo
    !
    *set,filkp_(1),
    *set,abc_,
    *set,numkps_,
    *set,ecount,
*elseif,jkp_,gt,0,then
    ksel,s,kp,,jkp_
    lslk,s,0
    !
    *get,lcnt_,line,,count
    get_max_entity
    get_min_entity
    !
    *if,lcnt_,eq,2,then
        lfillt,l_min,lm,rad_,cntrkp_
    *endif
*endif
!
init_entity_num
!
lplot
!
*set,jkp_,
*set,rad_,
*set,lcnt_,
*set,cntrkp_,
!


w:\ansys\mac\tools\ln_filletA.mac.html

!   TITLE:  ln_fillet.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      08/27/2001      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     01/14/2002    J. Rinaldi
!
!           Made provision for filleting all newly created and/or unattached
!           lines that may be selected by the 'isolate_lines' command.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates a line fillet(s) at the specified junction key-
!   point(s).
!
!
!   COMMAND SYNTAX:
!
!                   (1)   (2)
!        LN_FILLET, jkp, radius
!
!
!   ARGUMENTS:
!
!       (1) jkp = the keypoint number adjoining 2 lines to be filleted. This
!                 is a specific keypoint number (an integer value > or = to 0).
!
!               Otherwise:
!
!                   0 (or blank) = all selected keypoints adjoining two
!                                  lines will be filleted
!
!                   -1 = all keypoints adjoining two lines will be filleted,
!                        where the lines to be filleted are newly created and/or
!                        unattached (to areas and/or volumes) lines. (these
!                        lines may be selected by the 'isolate_lines' command).
!
!
!       (2) radius = the radius of the fillet.
!
!
!   DESCRIPTION:
!
!   This macro creates a fillet between 2 lines sharing the keypoint specified
!   in argument 1, 'jkp', with the fillet radius specified in argument 2.
!
!   If it is desired to create more than 1 fillet with the same radii, then
!   select all keypoints at the junction of the lines that are desired to be
!   filleted, and leave argument 1 blank. Fillets will be created at these
!   selected keypoints.
!
!   If any of the selected keypoints, or the specified keypoint 'jkp', are
!   not attached to only 2 lines, the algorithm will abort the fillet creation
!   at that keypoint, and proceed to the next junction keypoint in the selected
!   set, if more than 1 keypoint is selected.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
jkp_=arg1
rad_=arg2
!
*if,jkp_,le,0,then
    *if,jkp_,eq,-1,then
        isolate_lines
        ksll,s
    *endif
    !
    entity_array,'k','filkp_','array'
    numkps_=ecount
    !
    *do,abc_,1,numkps_,1
        ksel,s,kp,,filkp_(abc_,1)
        lslk,s,0
        !
        *get,lcnt_,line,,count
        get_max_entity
        get_min_entity
        !
        *if,lcnt_,eq,2,then
            lfillt,l_min,lm,rad_
        *endif
    *enddo
    !
    *set,filkp_(1),
    *set,abc_,
    *set,numkps_,
    *set,ecount,
*elseif,jkp_,gt,0,then
    ksel,s,kp,,jkp_
    lslk,s,0
    !
    *get,lcnt_,line,,count
    get_max_entity
    get_min_entity
    !
    *if,lcnt_,eq,2,then
        lfillt,l_min,lm,rad_
    *endif
*endif
!
init_entity_num
!
lplot
!
*set,jkp_,
*set,rad_,
*set,lcnt_,


w:\ansys\mac\tools\or.mac.html

!   TITLE:  or.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   03/28/2001  D. Edwards
!---------------------------------------------------------------------------
!
!   Boolean OR two arguments together.
!
!   If one argument is nonzero, return 1, otherwise return 0.
!
!---------------------------------------------------------------------------
!
!   Usage:  or,parm,a,b
!
!   Arguments:
!
!       parm    =   The result parameter.
!
!       a       =   A boolean expression or value.
!
!       b       =   A boolean expression or value.
!
!---------------------------------------------------------------------------
!
!   Example:    or,z,fl>0,fh<0
!
!               If (fl > 0) or (fh < 0) then return z=1, return z=0
!               otherwise.
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

*if,arg2,ne,0,then
    %arg1%=1
*elseif,arg3,ne,0,then
    %arg1%=1
*else
    %arg1%=0


w:\ansys\mac\tools\par_array-.mac.html

!   TITLE:  par_array.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   07/22/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro creates a character array containing all active parameters
!   in the database, and a scalar array containing their corresponding values.
!   The only input necessary is a user specified array character name. This
!   name is the name of the array that will store all parameters of a given
!   parameter file.  The input name must be 5 characters or less, and will
!   also be used for the parameter value array.
!
!               pararnam = parameter file array name.  This name must be 5
!                          characters or less.
!
!   Both arrays will start with the character name as specidied in 'pararnam'.
!   However, the parameter value array name will end with a 'v' (-----v).
!   Therefore, the value array is just the parameter name array with a 'v'
!   attached to the end.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! PAR_ARRAY, pararnam
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

pararnam=arg1
!
!
*get,zzzparmx,parm,,max
*get,zzzzsclp,parm,,basic
zzzzsclp=zzzzsclp-1
!
*dim,zzzzparm,char,zzzzsclp+_indxoff
*dim,zzzzparv,array,zzzzsclp+_indxoff
!
zzzparof=0
!
*do,zzzzzzz1,1,zzzparmx-2,1     ! Store all scalar parameters in character
    !                           ! array, and their corresponding values in
    *if,zzzparof,eq,0,then      ! a scalar array.
        zzzzzzz2=zzzzzzz1
    *else
        zzzzzzz2=zzzzzzz1-zzzparof
    *endif
    !
    *get,zzzzpar,parm,,loc,zzzzzzz1
    *get,zzpartyp,parm,%zzzzpar%,type
    !
    *if,zzzzzzz1,eq,zzzparmx-2,then
        *if,zzpartyp,ne,0,then
            *exit
        *else
            zzzzparm(zzzzzzz2,1)=zzzzpar
        *endif
    *else
        zzzzparm(zzzzzzz2,1)=zzzzpar
    *endif
    !
    *if,zzpartyp,eq,0,then
        zzzzparv(zzzzzzz2,1)=%zzzzpar%
    *else
        zzzparof=zzzparof+1
    *endif
    !
*enddo
!
zzzzparm(zzzzsclp+1,1)='%pararnam%mxi'  ! store array maximum index parameter
zzzzparv(zzzzsclp+1,1)=zzzzsclp+1       ! store array maximum index
%pararnam%mxi=zzzzsclp+1                ! initiate parameter array file max. index
!
!--------------------------------------------------------------------------------
!
*dim,%pararnam%,char,zzzzsclp+1         ! rename character storage array
*dim,%pararnam%v,array,zzzzsclp+1       ! rename scalar storage array
!
*do,zijkl,1,zzzzsclp+1,1
    %pararnam%(zijkl,1)=zzzzparm(zijkl,1)
    %pararnam%v(zijkl,1)=zzzzparv(zijkl,1)
*enddo
!
!--------------------------------------------------------------------------------
!
*do,zijkl,1,%pararnam%mxi-1,1           ! remove all parameters that are not
    *do,zijkm,1,assmpmxi,1              ! elements of array ASSM_PAR.
        par1=%pararnam%(zijkl,1)
        par2=assm_par(zijkm,1)
        *if,par1,eq,par2,then
            *exit
        *else
            *if,zijkm,eq,assmpmxi,then
                    *set,%par1%,
            *endif
        *endif
    *enddo
*enddo
!
!--------------------------------------------------------------------------------
!
*set,zzpartyp,
!
*dim,buff,char,%pararnam%mxi    ! create buffer arrays to eliminate all parameters
*dim,buffv,array,%pararnam%mxi  ! from character array that are elements of array
!                               ! ASSM_PAR.
!
parof=0                         ! parameter offset value
!
*do,zijkl,1,%pararnam%mxi,1
    parcheck=0                  ! parameter check variable
    *do,zijkm,1,assmpmxi,1
        par1=%pararnam%(zijkl,1)
        par2=assm_par(zijkm,1)
        *if,par1,eq,par2,then
            parof=parof+1
            parcheck=1
        *endif
        !
        *if,zijkm,eq,assmpmxi,then
            *if,parcheck,eq,0,then
                index=zijkl-parof
                buff(index,1)=%pararnam%(zijkl,1)
                buffv(index,1)=%pararnam%v(zijkl,1)
            *endif
        *endif
    *enddo
*enddo
!
*set,%pararnam%(1),
*set,%pararnam%v(1),
!
*dim,%pararnam%,char,%pararnam%mxi-parof
*dim,%pararnam%v,array,%pararnam%mxi-parof
!
!--------------------------------------------------------------------------------
!
*do,zijkl,1,%pararnam%mxi-parof,1       ! reset parameter & value arrays from
    %pararnam%(zijkl,1)=buff(zijkl,1)   ! buffer arrays
    %pararnam%v(zijkl,1)=buffv(zijkl,1)
*enddo
!
%pararnam%v(%pararnam%mxi-parof,1)=%pararnam%mxi-parof
!
!--------------------------------------------------------------------------------
!
!
!---------- Store parameter file array name in parameter name file array --------
!
*if,modl_num,eq,1,then
    par_file(modl_num,1)=pararnam
*else
    *do,mnz,1,modl_num-1,1
        parfbuff(mnz,1)=par_file(mnz,1)
    *enddo
    !
    parfbuff(modl_num,1)=pararnam
    !
    *set,par_file(1),
    *dim,par_file,char,modl_num
    !
    *do,mnz,1,modl_num,1
        par_file(mnz,1)=parfbuff(mnz,1)
    *enddo
    !
    *set,parfbuff(1),
    *dim,parfbuff,char,modl_num+1
*endif
!
!--------------------------------------------------------------------------------
!
!
!
!--- Store parameter file array maximum index in parameter file maximum array ---
!
*if,modl_num,eq,1,then
    parfmxi(modl_num,1)=%pararnam%mxi-parof
*else
    *do,mnz,1,modl_num-1,1
        pfmxibuf(mnz,1)=parfmxi(mnz,1)
    *enddo
    !
    pfmxibuf(modl_num,1)=%pararnam%mxi-parof
    !
    *set,parfmxi(1),
    *dim,parfmxi,array,modl_num
    !
    *do,mnz,1,modl_num,1
        parfmxi(mnz,1)=pfmxibuf(mnz,1)
    *enddo
    !
    *set,pfmxibuf(1),
    *dim,pfmxibuf,array,modl_num+1
*endif
!
!--------------------------------------------------------------------------------
!
*set,%pararnam%mxi,
*set,zijkl,
*set,zijkm,
*set,par1,
*set,par2,
*set,index,
*set,pararnam,
*set,zzzzparm(1),
*set,zzzzparv(1),
*set,zzzzsclp,
*set,zzzzpar,
*set,zzzparmx,
*set,zzzparof,
*set,zzzzzzz1,
*set,zzzzzzz2,
*set,parcheck,
*set,buff(1),
*set,buffv(1),
*set,parof,
*set,mnz,
*set,_indxoff,


w:\ansys\mac\tools\parm_valB.mac.html

!   TITLE:  parm_val.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/02/2000      J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   05/12/2001      J. Rinaldi
!
!               Modified code to check if a model is built.  If it exists
!               it retrieves the parameter value; if not it aborts. Also
!               added default assignment parameter.
!---------------------------------------------------------------------------
!       Rev B   07/06/2001      J. Rinaldi
!
!               Modified code to use the default value if a parameter
!               array is found but the parameter is not defined.
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro initializes/retrieves a parameter value from a previously
!   stored array of parameter values.
!
!
!   COMMAND SYNTAX:
!
!                   (1)      (2)     (3)       (4)
!       PARM_VAL, mod_name, param, new_parm, def_val
!
!
!   ARGUMENTS:
!
!       (1) mod_name = model name using the parameter file which has
!                      the desired user value.  This may be retrieved
!                      from the array 'MODEL'.
!
!       (2) param = desired parameter within the parameter file to be
!                   queried.
!
!       (3) new_parm = new parameter character name to assign the value to
!
!       (4) def_val = parameter assignment default value.  If ALL of the
!                     following conditions are met:
!
!                   a.) the parameter array for a model does not exist
!
!                   b.) the parameter NEW_PARM is not previously defined
!
!                   c.) DEF_VAL is not equal to 0
!
!               then DEF_VAL is assigned to the new specified parameter.
!
!           In the event that a given model, and therefore the parameter
!           array, does not exist for retrieval, these conditions will insure
!           that a previously defined value for a parameter holding the name
!           of NEW_PARM is not overwritten when this macro is executed. Also,
!           if the parameter NEW_PARM is not previously defined, it will not
!           be initialized with a value of 0 when DEF_VAL is left blank.
!
!
!   DESCRIPTION:
!
!   These parameter values may be used to link separate models together whose
!   surfaces may interface. This will keep the surfaces contingent by using the
!   same dimensional values to interface the parts (e.g., outer diameter of one
!   part mating with the inner diameter of a second part, therefore same diame-
!   ter value must be used for the two mating surfaces from a given axis of rot-
!   ation). This prevents the user from searching for a specific parameter value
!   manually, and keeps the parts linked if a specific paramter value is changed.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr
!
mod_name=arg1
param_=arg2
newparm_=arg3
defval_=arg4
!
!
param_=upcase(param_)
!
*get,parftyp_,parm,par_file,type
!
*if,parftyp_,eq,4,then
    !
    *get,modlim_,parm,par_file,dim,x
    !
    *do,iiii_,1,modlim_,1
        *if,mod_name,eq,model(iiii_,1),then
            mod_indx=iiii_
            abrtget_=0
            *exit
        *else
            *if,iiii_,eq,modlim_,then
                abrtget_=1
            *endif
        *endif
    *enddo
    !
    *if,abrtget_,eq,0,then
        parm_arr=par_file(mod_indx,1)
        !
        max_indx=parfmxi(mod_indx,1)
        !
        *do,iiii_,1,max_indx,1
            *if,param_,eq,%parm_arr%(iiii_,1),then
                %newparm_%=%parm_arr%v(iiii_,1)
                *exit
            *else
                *if,iiii_,eq,max_indx,then
                    *get,ptyp_,parm,%newparm_%,type
                    !
                    *if,ptyp_,eq,-1,then
                        *if,defval_,ne,0,then
                            %newparm_%=defval_
                        *endif
                    *endif
                *endif
            *endif
        *enddo
    *else
        *get,ptyp_,parm,%newparm_%,type
        !
        *if,ptyp_,eq,-1,then
            *if,defval_,ne,0,then
                %newparm_%=defval_
            *endif
        *endif
    *endif
*else
    *get,ptyp_,parm,%newparm_%,type
    !
    *if,ptyp_,eq,-1,then
        *if,defval_,ne,0,then
            %newparm_%=defval_
        *endif
    *endif
*endif
!
*set,mod_name,
*set,param_,
*set,newparm_,
*set,defval_,
*set,iiii_,
*set,max_indx,
*set,mod_indx,
*set,parm_arr,
*set,abrtget_,
*set,ptyp_,
*set,parftyp_,
*set,modlim_,


w:\ansys\mac\tools\profile.mac.html

!
!   TITLE:  profile.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   05/05/2001  D. Edwards
!---------------------------------------------------------------------------
!
! Used for profiling macros for speed.
!
! This macro is used to measure the time duration it takes ANSYS to do
! a block of commands.  It is inserted at desired locations througout
! the macro to be profiled.
!
! The first usage of this macro should be without an argument to get
! things initialized.  Each subsequent call of this macro should include
! a numeric argument.  The numeric argument is used to track the call
! number within the profiled macro to the output written to "profile.out".
! Generally the numeric argument supplied should increase with each
! call, but it is arbitrary.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! profile
! profile,num
!
!   where num = An integer value (I2) or floating point (F5.1).
!
!---------------------------------------------------------------------------
*get,prkey_,active,0,prkey
/nopr

*if,arg1,ne,0,then

*get,stopc_,active,0,time,cpu
sec_=stopc_-_startc_

/out,profile,out,,append
*vwrite,arg1,sec_*1000.0
(F5.1,': ',F10.3,' msec')
/out

*else

/out,profile,out
*msg
Times from profile.mac:
*msg

/out

*endif

*get,_startc_,active,0,time,cpu


w:\ansys\mac\tools\stator_lam.mac.html

!   TITLE:  stator_lam.mac (PART_LIB)
!
!---------------------------------------------------------------------------
!       Rev -   06/07/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   This macro creates a stator lamination stack / coil wire assembly:
!
!               P/N XXXXXXXXXXXX
!
!       UPPER ASSEMBLY:     XXXXXXXXXXXXX
!
!   ctslcs:         Cartesian Stator Lamination Coordinate System
!   cylslcs:        Cylindrical Stator Lamination Coordinate System
!   sphslcs:        Spherical Stator Lamination Coordinate System
!
!
!******************************* TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   2.  Material and Element Type
!   4.  Solid Model
!   5.  FE model
!
!
!************************** Model Assembly Preparation **********************
!
!
!
mod_assemb_prep                 ! prepare database for assembly
!
!
/title,XXXXXXXX
!
!
/units,bin                      ! British/inch units
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>

        r1=1.225/2-0.1
        r2=1.800/2+0.1

        r3=1.225/2              ! wire inner radius
        r4=1.800/2              ! wire outer radius

        l1=0.600                ! lam. axial length
        l2=0.350                ! wire bundle width

        w_stat=0.29176          ! stator lamination assembly weight

!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
!
mod_coord_system,cthscs,0.00,0.00,0.00,0,0,0
!
!
!<<<<<<<<<<<<<<<<<<<< 3.  Material and Element Type >>>>>>>>>>>>>>>>>>>
!
!
!---------------------- Material Properties --------------------
!
UIMP,3,EX, , ,28.5E6,       ! Material:  ASTM A582 TYPE 416 COND A
UIMP,3,DENS, , ,.28/386.4,
UIMP,3,NUXY, , ,0.27,
!alpha=5.9E-6 in/in/F
!
!------------------------- Element Type ------------------------
!
ET,1,SOLID95
ET,2,SHELL93
!
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!------------------------ 4.1  Lamination Stack -----------------------
!
csys,ctslcs
!
k,,0,0,0        ! create axis rotation points
k,,0,0,1
!
init_entity_num
!
axp1=km-1
axp2=km
!
k,,0,r1,l1      ! points 1 thru 4
k,,0,r1,0
k,,0,r2,0
k,,0,r2,l1
!
create_area
!
lplot
!
!--------------------------- 4.2  Stator Wire -------------------------
!
csys,ctslcs
!
k,,0,r3,l1      ! points 1 thru 4
k,,0,r4,l1
k,,0,r4,l1+l2
k,,0,r3,l1+l2
!
create_lines
!
lfillt,lm-2,lm-1,0.2*((r2-r3)-(r2-r4))
lfillt,lm-1,lm,0.2*((r2-r3)-(r2-r4))
!
create_area-lines
!
k,,0,r4,0       ! points 5 thru 8
k,,0,r3,0
k,,0,r3,-l2
k,,0,r4,-l2
!
create_lines
!
lfillt,lm-2,lm-1,0.2*((r2-r3)-(r2-r4))
lfillt,lm-1,lm,0.2*((r2-r3)-(r2-r4))
!
create_area-lines
!
aglue,am-2,am-1,am
!
init_entity_num
!
lplot
!
!------------------------- 4.3  Create Volumes ------------------------
!
revolve_aset,axp1,axp2,4*rtangle,4
!
kdele,axp1,axp2
!
init_entity_num
!
lplot
!
!---------------------- 5.  Density Calculations ----------------------
!
vsum
!
*get,v_stat,volu,,volu      ! total volume of assembly
!
rho_stat=w_stat/v_stat      ! density of assembly material
!
!----------------------------------------------------------------------
!
finalize_model_data


w:\ansys\mac\tools\featr_set.mac.html

!   TITLE:  featr_set.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/14/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro selects a specified solid model entity feature(s) and all
!   associated lower solid model entities for the display.
!
!
!   COMMAND SYNTAX:
!
!                     (1)      (2)
!        FEATR_SET, ftr_typ, ftr_num
!
!
!   ARGUMENTS:
!
!       (1) ftr_typ = the solid model entity feature type:
!
!                   1 (or blank) = volume(s)
!
!                   2 = area(s)
!
!                   3 = line(s)
!
!       (2) ftr_num = the number or component group name of the feature(s).
!
!
!   DESCRIPTION:
!
!   This macro is used if it is desired to display only a particular volume,
!   area or line, and all associated lower solid model entities. The default
!   solid model entity type is volumes. Therefore, by default, a specified
!   volume, and associated areas, lines and keypoints comprising the volume,
!   is selected and displayed. The solid model entity maximum parameters is
!   unaffected, and may be used for implementing parameterized solid model
!   operations.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

ftrtyp_=arg1
ftrnum_=arg2
!
*if,ftrtyp_,eq,0,then
    ftrtyp_=1
*endif
!
*if,ftrnum_,ne,0,then
    *if,ftrtyp_,eq,1,then
        vsel,s,volu,,ftrnum_
        aslv,s
        lsla,s
        ksll,s
    *elseif,ftrtyp_,eq,2,then
        asel,s,area,,ftrnum_
        lsla,s
        ksll,s
    *elseif,ftrtyp_,eq,3,then
        lsel,s,line,,ftrnum_
        ksll,s
    *endif
    !
    /AUTO, 1
    /REP
    !
    lplot
*endif
!
*set,ftrtyp_,
*set,ftrnum_,


w:\ansys\mac\tools\cpl_nodes-.mac.html

!   TITLE:  cpl_nodes.mac (LOADS)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      12/11/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro couples a user specified set of degrees of freedom (DOF)
!   of two sets of surface nodes from two separate parts.  The surfaces must
!   be coplanar, coincident or separated by a given distance within a specified
!   tolerance.
!
!   This macro may be used to couple the DOF of nodes from two separate and
!   different mesh layout patterns on any 2 given surfaces, allowing coupling
!   of non-coincident nodes.  This is achieved by specifying a cubical tol-
!   erance band around each node, with each node located at the center of
!   the cube. The tolerance band width argument, TOL, is defined as the
!   total width of the band around a node, as measured from a cartesian c.s.
!   centered at the node location.  This is depicted in figure 1.
!
!                            ___________________
!                           |       TOL         | TOL/2
!                           |                   |
!                           |       y ^         |
!                           |         |         |
!                           |         |         |
!                           |         *---> x   | TOL
!                           |      source       |
!                           |       node        |
!                           |                   |
!                           |                   |
!                           |___________________| -TOL/2
!                        -TOL/2               TOL/2
!
!                       FIGURE 1.  Tolerance band
!
!   Of the two surfaces, one surface (set of areas) is specified as the source
!   area(s), and the other set target area(s).  The area(s) of each surface are
!   stored in a component group, and those names are entered in as arguments
!   as specified below.  The algorithm then takes each node of the source
!   area and checks for the nearest node in the target area within the tolerance
!   band. Any nodes from the target area that are within the tolerance region
!   in figure 1 will be considered for coupling.  If there is more than 1 node
!   in this region, the algorithm will couple the source node with a target node
!   that is the least distance from it.
!
!   The input for this command macro must be carefully defined SOURCE and TARGET
!   area sets.  These area sets must be component groups with distinct user de-
!   fined names. Once the area sets are defined, then the input arguments to be
!   supplied to this macro may be input as follows:
!
!
!       (1) source_aset = component group character name of area(s) com-
!                         prising the source area.
!
!       (2) target_aset = component group character name of area(s) com-
!                         prising the target area.
!
!       (3) node_cs = the coordinate system in which the nodal coordinates
!                     are to be measured from. The local coordinate system
!                     created at each node is a cartesian coordinate sys-
!                     tem from which the tolerance band is created, and
!                     is created from NODE_CS.
!
!       (4) tol = the total width of the tolerance bands for considering a
!                 node for coupling.
!
!       (5) dof_lab = the DOF label for the coupling. (e.g., UX, UY, UZ,
!                     ROTX, ALL, ....) See the CP command help for all
!                     options.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
!                (1)          (2)        (3)    (4)    (5)
! CPL_NODES, source_aset, target_aset, node_cs, tol, dof_lab
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

s_aset=arg1
t_aset=arg2
n_cs=arg3
tol_=arg4
dof_lab=arg5
!
!
csys,n_cs
!
cmsel,s,%s_aset%
nsla,s,1
nrotat,all
cm,s_nset,node
!
cmsel,s,%t_aset%
nsla,s,1
nrotat,all
cm,t_nset,node
!
nsel,s,node,,s_nset
entity_array,'n','s_set','array'
s_cnt=ecount
!
*do,qrs_,1,s_cnt,1
    !
    csys,n_cs
    !
    x_=nx(s_set(qrs_,1))
    y_=ny(s_set(qrs_,1))
    z_=nz(s_set(qrs_,1))
    !
    create_cs,0,,0,x_,y_,z_,0,0,0
    !
    nsel,s,node,,t_nset
    nsel,r,loc,x,-tol_/2,tol_/2
    nsel,r,loc,y,-tol_/2,tol_/2
    nsel,r,loc,z,-tol_/2,tol_/2
    !
    nsel,a,node,,s_set(qrs_,1)      ! select source node
    s_node=s_set(qrs_,1)
    !
    *get,ncnt_,node,,count          ! node count parameter
    !
    *if,ncnt_,ge,2,then
        !
        nsel,u,node,,s_node
        !
        *if,qrs_,eq,1,then
            entity_array,'n','msr_set','array'
        *else
            *get,arr_chk1,parm,msr_set,type
            !
            *if,arr_chk1,eq,1,then
                *set,msr_set(1),
            *endif
            !
            entity_array,'n','msr_set','array'
        *endif
        !
        msr_cnt=ecount
        !
        nsel,a,node,,s_node
        !
        *if,qrs_,eq,1,then
            *dim,dist_,array,msr_cnt
        *else
            *get,arr_chk2,parm,dist_,type
            !
            *if,arr_chk2,eq,1,then
                *set,dist_(1),
            *endif
            !
            *dim,dist_,array,msr_cnt
        *endif
        !
        *do,ijk_,1,msr_cnt,1
            dist_(ijk_,1)=distnd(s_node,msr_set(ijk_,1))
        *enddo
        !
        min_value,'dist_',msr_cnt
        !
        nsel,s,node,,msr_set(min_indx,1)
        nsel,a,node,,s_node
        !
        cp,next,%dof_lab%,all
        !
        nsel,s,node,,t_nset
        nsel,u,node,,msr_set(min_indx,1)
        cm,t_nset,node
    *endif
*enddo
!
allsel,all
!
*set,qrs_,
*set,arr_chk1,
*set,arr_chk2,
*set,s_cnt,
*set,msrcnt,
*set,s_node,
*set,n_cs,
*set,dof_lab,
*set,x_,
*set,y_,
*set,z_,
*set,s_set(1),
*set,msr_set(1),
*set,dist_(1),
cmdele,%s_aset%
cmdele,%t_aset%
*set,s_aset,
*set,t_aset,
*set,s_nset,
*set,t_nset,


w:\ansys\mac\tools\extend.mac.html

!   TITLE:  extend.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/03/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro extends the length of a line.
!
!
!   COMMAND SYNTAX:
!
!                        (1)   (2)     (3)
!               EXTEND, line#, kp#, ext_leng
!
!
!   ARGUMENTS:
!
!       (1) line# = number of the line to extend
!
!       (2) kp# = end keypoint number to extend from
!
!       (3) ext_leng = the amount of length to extend line
!
!
!   DESCRIPTION:
!
!   The line is extended from the specified end keypoint side.  The original
!   length of the line is extended in length by the amount specified in arg-
!   ument 3, 'ext_leng'.
!
!   If the end keypoint is attached to only 1 line, then the line number
!   need not be specified; only arguments 2 and 3. In this case, the line
!   is extended and combined with the original line to make 1 longer line.
!
!   If the end keypoint is attached to more than 1 line, then the line number
!   to be extended must be specified. When this line is extended, it is not
!   combined with the original line, and therefore the extension is an add-
!   itional line.
!
!   This command is valid for straight lines only.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

!
baseln_=arg1
endkp_=arg2
extl_=arg3
!
init_entity_num
!
ksel,s,kp,,endkp_
lslk,s,0
get_max_entity
lhold_=lm
*get,numlns_,line,,count
!
init_entity_num
!
*if,numlns_,eq,1,then
    baseln_=lhold_
*endif
!
*get,kp1_,line,baseln_,kp,1
*get,kp2_,line,baseln_,kp,2
!
*if,kp1_,eq,endkp_,then
    kxp_=kp2_
*else
    kxp_=kp1_
*endif
!
*get,acs1_,active,,csys
!
clocal,csn+5,1,kx(endkp_),ky(endkp_),kz(endkp_),0,0,0
kxpang_=ky(kxp_)
clocal,csn+6,0,0,0,0,kxpang_,0,0
!
k,,0,1,0
init_entity_num
kpln_=km
!
cskp,csn+7,0,endkp_,kxp_,kpln_
!
kdele,kpln_
init_entity_num
!
*if,extl_,gt,0,then
    k,,-extl_,0,0
    !
    init_entity_num
    !
    lstr,endkp_,km
    !
    init_entity_num
    !
    *if,numlns_,eq,1,then
        lcomb,baseln_,lm
        init_entity_num
    *endif
*endif
!
csdele,csn+5,csn+7,1
csys,acs1_
!
lplot
!
*set,baseln_,
*set,endkp_,
*set,kpln_,
*set,kp1_,
*set,kp2_,
*set,acs1_,
*set,extl_,
*set,lhold_,
*set,numlns_,
*set,kxp_,
*set,kxpang_,


w:\ansys\mac\tools\vol_part_area.mac.html

!   TITLE:  vol_part_area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    03/22/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   This sub-macro is used to partition a selected set of volumes by using
!   a cutting area, ACUT.  It then restores the selected set to the full
!   model set that is currently under construction.
!
!   In the case that the cutting area ACUT is a component group of areas,
!   then simply place the component group name in single quotes in the
!   first argument.
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! VOL_PART_AREA, acut
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

_acut=arg1
!
*get,_vlow,volu,,num,min
*get,_vhigh,volu,,num,max
!
*do,_iii,_vlow,_vhigh,1
    *if,_vlow,eq,_vhigh,then
        _kdv='delete'
    *else
        *if,_iii,ne,_vhigh,then
            _kdv='keep'             ! keep/delete decision variable
        *else
            _kdv='delete'
        *endif
    *endif
    !
    *if,vsel(_iii),ne,0,then
        vsba,_iii,_acut,,delete,_kdv
    *endif
*enddo
!
*get,_ptyp,parm,_acut,type
!
*if,_ptyp,eq,3,then
    adele,_acut,,,1
*endif
!
*if,asel(_acut),ne,0,then
    adele,_acut,,,1
*endif
!
init_entity_num
!
*set,_kdv,
*set,_vlow,
*set,_vhigh,
*set,_acut,
*set,_iii,
*set,_ptyp,


l:\ansys\mac\verification\array_copy_test.mac.html

! TITLE:  array_copy_test.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!   Rev -   03/04/02    J. Judd
!---------------------------------------------------------------------------
!
! OBJECTIVE:
!
!   tests [array_copy.mac] for various inputs
!
! COMMAND SYNTAX:
!
!   array_copy_test
!
! ARGUMENTS:
!
!   none
!
! DESCRIPTION:
!
! WARNINGS:
!
!  - Error trapping will not work in ANSYS ED
!
!---------------------------------------------------------------------------
!
fini
/clear,start
!---
*ASK,stop,Need to look at output window for STAT outputs,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!---
array_copy,X,'Y'
*ASK,stop,(array_copy,X,'Y') Abort. Array names not in single quotes?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!---
array_copy,'X','Y'
*stat,X
*ASK,stop,Abort. X not defined?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!---
E=1
array_copy,'E','F'
*stat,E
*ASK,stop,E=%E%. Abort because E is scalar?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!---
G='junk'
array_copy,'G','H'
*stat,G
*ASK,stop,G=%G%. Abort because G is character scalar?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!----
*DIM,A,array,3
A(1)=1,2,3
array_copy,'A','B'
*stat,A
*stat,B
*ASK,stop,A=B?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!----
*DIM,model,char,5
model(1)='nut','bolt','boltlock','hand','arm'
array_copy,'model','part'
*stat,model
*stat,part
*ASK,stop,model=part?,0
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!-----
*DIM,C,array,5,5
C(1,1)=11,21,31,41,51
C(1,2)=12,22,32,42,52
C(1,3)=13,23,33,43,53
C(1,4)=14,24,34,44,54
C(1,5)=15,25,35,45,55
array_copy,'C','D'
*stat,C
*stat,D
*ASK,stop,C=D?,1
*IF,stop,EQ,1,THEN
   *go,:stop
*ENDIF
!-----
:stop
!-----


l:\ansys\mac\verification\cyl_area_test.mac.html

! TITLE:  cyl_area_test.mac  (VERIFICATION)
!
!---------------------------------------------------------------------------
!   Rev -     3/15/02   J. Judd
!---------------------------------------------------------------------------
!
! OBJECTIVE:
!
!   Test [cyl_area.mac] revision B
!
! COMMAND SYNTAX:
!
!   Cut and paste into command line
!
! ARGUMENTS:
!
!   none
!
! DESCRIPTION:
!
!   Test [cyl_area.mac] revision B
!
! WARNING:
!
! EXAMPLES:
!
! TO BE DONE:
!
!---------------------------------------------------------------------------

mod_assemb_prep               !changes to iso view

cyl_area,1,1,2,0.5,0,360,3    !Creates full cylinder (area 3 and 4)
                              !Note: still in iso view
!Set view, line size, & selected entities to see if retain after next command.
lesize,all,0.2,,,4,1          !Size = 0.2; spacing ratio =4
lplo
/pnum,kp,1
/pnum,line,1
asel,s,area,,3                !unselect area 4 to see if stays unselected.
 aplo
lsel,s,line,,1                !select line 1, should stay selected
 lplo
ksel,s,kp,,1                  !select kp 2, should stay selected
 kplo
/view,1,1,0,0                 !change view to YZ plane to see if it retains
 aplo

cyl_area,2,1,2,0.5,45,240,3   !Creates pie cylinder (area 7,8,9)
                              !Note: entities selected, line divisons show
                              !  and still in YZ plane view. GOOD.
/view,1,1,1,1
aplo
lplo
kplo


w:\ansys\mac\tools\and.mac.html

!   TITLE:  and.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   03/28/2001  D. Edwards
!---------------------------------------------------------------------------
!
!   Boolean AND two arguments together.
!
!   Return 1 if both arguments are nonzero and return 0 otherwise.
!
!---------------------------------------------------------------------------
!
!   Usage:  and,parm,a,b
!
!   Arguments:
!
!       parm    =   The result parameter.
!
!       a       =   A boolean expression or value.
!
!       b       =   A boolean expression or value.
!
!---------------------------------------------------------------------------
!
!   Example:    and,z,fl>0,fh<0
!
!               If (fl > 0) and (fh < 0) then return z=1, return z=0
!               otherwise.
!
!---------------------------------------------------------------------------

*get,prkey_,active,0,prkey
/nopr

*if,arg2,ne,0,then
    *if,arg3,ne,0,then
        %arg1%=1
    *endif
*else
    %arg1%=0


w:\ansys\mac\tools\tv_cir_bore.mac.html

!   TITLE:  tv_cir_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/15/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a circular cylinder shaped volume
!   which is to be subtracted out, thereby creating a cylindrical
!   shaped cavity in the selected volume. This volume may be a right
!   circular cylinder (phibev = 0), or an angled (0 < phibev < 90) conic
!   section.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume
!
!       opt = input options: 1,2,3,4,5 and 6
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       dcut = the depth or thickness of the volume
!       phibev = angle of bevel as measured from the normal
!            to the circular surfaces (from volume cut
!            coordinate system z axis)
!       acs1= pre-existing Active Coordinate System
!       dia_cut = diameter of cut/volume (along local c.s. x axis) on
!             penetrating surface
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for options 1 and 4 (See below). From
!   this c.s., the local coordinate system building this volume is placed.
!   Options 2 and 5 allow construction of the cut volume from a c.s. de-
!   fined by 3 KP's. Lastly, options 3 and 6 allow construction from
!   a pre-existing c.s.  Options 4 thru 6 correspond to the same input as
!   1 thru 3, except that these options are used when the dimensions of the
!   base circle are specified.
!
!
!   The 6 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of circle at the surface, input:
!               dia_cut
!
!       2.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of circle at the surface, input:
!               dia_cut
!
!       3.  Use pre-existing c.s., input: acs1
!
!           Dimensions of circle at the surface, input:
!               dia_cut
!
!       4.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of circle at the base, input:
!               dia_cut
!
!       5.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of circle at the base, input:
!               dia_cut
!
!       6.  Use pre-existing c.s., input: acs1
!
!           Dimensions of circle at the base, input:
!               dia_cut
!
!---------------------- COMMAND SYNTAX / OPTION 1 & 4 ------------------------
!
! CIR_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc,dia_cut,dcut,phibev
!
!------------------------------- OPTION 2 & 5 --------------------------------
!
! CIR_BORE,opt,p1,p2,p3,dia_cut,dcut,phibev
!
!------------------------------- OPTION 3 & 6 --------------------------------
!
! CIR_BORE,opt,acs1,dia_cut,dcut,phibev
!
!-----------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*get,_acs_,active,,csys
!
cm,v2bcut,volu      ! selected volume to be (2b) cut
!
*ask,opt,OPTION,1
!
!------------------------ Create Input By Option ----------------------
!
*if,opt,eq,1,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,dia_cut,Surface Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
*if,opt,eq,2,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,dia_cut,Surface Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
*if,opt,eq,3,then
    *ask,acs1,Active C.S.,0
    !
    *ask,dia_cut,Surface Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
*endif
!
*if,opt,eq,4,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,dia_cut,Base Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
    !
    dia_cut=dia_cut+2*x
*endif
!
*if,opt,eq,5,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,dia_cut,Base Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
    !
    dia_cut=dia_cut+2*x
*endif
!
*if,opt,eq,6,then
    *ask,acs1,Active C.S.,0
    !
    *ask,dia_cut,Base Diameter,1
    *ask,dcut_,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut_*tan(phibev*rconv)
    !
    dia_cut=dia_cut+2*x
*endif
!
!----------------------- Create Coordinate System ---------------------
!
*if,opt,eq,1,then
    create_cs,0,'circutcs',1,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    create_cs,1,'circutcs',1,p1,p2,p3
*endif
!
*if,opt,eq,3,then
    csys,acs1
*endif
!
*if,opt,eq,4,then
    create_cs,0,'circutcs',1,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,5,then
    create_cs,1,'circutcs',1,p1,p2,p3
*endif
!
*if,opt,eq,6,then
    csys,acs1
*endif
!
!----------------------------- Create Volume --------------------------
!
*do,ii,0,3*rtangle,rtangle
    k,,dia_cut/2,ii,0
*enddo
!
*if,dcut_,ne,0,then
    *if,(dia_cut/2-x),ge,0,then
        !
        *do,ii,0,3*rtangle,rtangle
            k,,(dia_cut/2-x),ii,-dcut_
        *enddo
        !
        init_entity_num
        !
        v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
        !
        init_entity_num
        !
        vsbv,v2bcut,vm,,delete,delete
        !
        init_entity_num
        !
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        !
        init_entity_num
    *endif
*else
    create_area,1
*endif
!
lplot
!
csys,_acs_
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,phibev,
*set,dcut_,
*set,dia_cut,
*set,x,
*set,ii,
*set,_acs_,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_creat_lines.mac.html

!   TITLE:  tv_creat_lines.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/06/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro creates lines between newly created keypoints.  The
!   lines may be created in a loop, or in sequence from lowest to high-
!   est keypoint values. This command is preceeded and followed by
!   the command INIT_ENTITY_NUM. Therefore, it may be used directly
!   after the keypoint commands (k,,XX,YY,ZZ); and directly before all
!   other commands. The retrieval of the maximum entities before and
!   after the lines are created is built in.
!
!   When creating lines, be sure that the proper coordinate system is
!   active; i.e., if arced lines are desired, then the active coordinate
!   system must be a cylindrical coordinate system; if spherical lines
!   are desired, then the active c.s. must be a spherical c.s.; etc.
!
!   The input data necessary to run this macro:
!
!       c_acs = boolean operator to create lines in active coordinate
!           system:
!
!           0 (or blank) = creates straight lines between KP's,
!                      regardless of active c.s.
!
!           1 = creates lines in active c.s.
!
!       seqnce = boolean operator to create lines in a closed loop,
!            or lines in sequence from lowest to highest keypoint
!            order.
!
!           0 (or blank) = creates lines between KP's, forming a
!                      closed loop.
!
!           1 = creates lines between keypoints in sequence, but
!               not forming a closed loop.
!
!   Therefore, if straight lines in a closed loop is the desired objective,
!   no arguments need to be specified.  Only the macro title needs specified.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! TV_CREATE_LINES, c_acs, seqnce
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

init_entity_num
!
*ask,cacs_,straight(0) or active cs(1),0
*ask,seqnce_,close loop(0) or sequence(1),0
!
newkps_=km-km_prev      ! number of new keypoints
!
*if,seqnce_,eq,0,then
    *if,cacs_,eq,0,then
        *do,iii_,1,newkps_,1
            *if,iii_,ne,newkps_,then
                lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *else
                lstr,km,km-(newkps_-1)
            *endif
        *enddo
    *endif
    !
    *if,cacs_,eq,1,then
        *do,iii_,1,newkps_,1
            *if,iii_,ne,newkps_,then
                l,km-(newkps_-iii_),km-(newkps_-iii_-1)
            *else
                l,km,km-(newkps_-1)
            *endif
        *enddo
    *endif
*endif
!
!
*if,seqnce_,eq,1,then
    *if,cacs_,eq,0,then
        *do,iii_,1,newkps_-1,1
            lstr,km-(newkps_-iii_),km-(newkps_-iii_-1)
        *enddo
    *endif
    !
    *if,cacs_,eq,1,then
        *do,iii_,1,newkps_-1,1
            l,km-(newkps_-iii_),km-(newkps_-iii_-1)
        *enddo
    *endif
*endif
!
init_entity_num
!
*set,iii_,
*set,newkps_,
*set,seqnce_,
*set,cacs_,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_create_area.mac.html

!   TITLE:  tv_create_area.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  07/11/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION:
!
!   This sub-macro creates areas from newly created keypoints.  This is
!   acheived by using the macro command CREATE_LINES.  From these keypoints
!   the lines are first created, then the area from the lines. Therefore,
!   this macro serves as a replacement step for the series of steps in creating
!   lines and then creating areas.  The argument used here is the same as
!   CREATE_LINES, and its values is transferred directly to CREATE_LINES.
!   See CREATE_LINES for the options on this argument:
!
!           c_acs = boolean operator to create lines in the active
!                   coordinate system.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! CREATE_AREAS, c_acs
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*ask,c_acs,straight(0) or active cs(1),0
!
create_lines,c_acs,0
!
isolate_lines
al,all
!
init_entity_num
!
lplot
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_create_image.mac.html

!   TITLE:  tv_create_image.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      06/06/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This sub-macro creates a graphics image file of the currently displayed
!   ANSYS graphics window.
!
!
!   ARGUMENTS:
!
!       (1) imgtyp = image format type: Valid inputs are:
!
!               'pscr' - encapsulated postscript (EPS)
!
!               'tiff' - tagged image file format (default)
!
!               'epsi' - encapsulated postscript with TIFF preview
!
!               'bmp' - bitmap ( PC only )
!
!               'wmf' - windows metafile format ( PC only )
!
!               'emf' - enhanced metafile format ( PC only )
!
!               'jpeg' - Joint Photographic Expert Group format
!
!       (2) orient = image orientation on the page
!
!               0 = landscape (default)
!
!               1 = portrait
!
!       (3) revrs = reverse video background ( print background )
!
!               0 = reverse video background ( white vackground ) (default)
!
!               1 = normal ( black background )
!
!       (4) colr = color of image
!
!               0 = color print ( at specified color depth ) (default)
!
!               1 = black and white
!
!               2 = greyscale
!
!
!   DESCRIPTION:
!
!   This macro creates a graphics file of the current output window in the
!   specified graphics format. If the image is a TIFF or EPS format, then
!   it compresses the file. The ANSYS /UI commmand is used to perform this
!   function.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

multipro,'start',4
    *cset,1,3,imgtyp_,'Image Type',2
    *cset,4,6,orient_,'0=Landscape, 1=Portrait',0
    *cset,7,9,revrs_,'0=White, 1=Black Background',0
    *cset,10,12,colr_,'0=Color, 1=Black/White, 2=GryScl',0
    *cset,61,62,'Creates a graphics file. Image',' types: 1=PSCR, 2=TIFF,'
    *cset,63,64,'3=EPSI, 4=BMP, 5=WMF, 6=EMF, 7=','JPEG. Enter data.'
multipro,'end'
!
*if,imgtyp_,eq,1,then
    imgtyp_='pscr'
*elseif,imgtyp_,eq,2,then
    imgtyp_='tiff'
*elseif,imgtyp_,eq,3,then
    imgtyp_='epsi'
*elseif,imgtyp_,eq,4,then
    imgtyp_='bmp'
*elseif,imgtyp_,eq,5,then
    imgtyp_='wmf'
*elseif,imgtyp_,eq,6,then
    imgtyp_='emf'
*elseif,imgtyp_,eq,7,then
    imgtyp_='jpeg'
*endif
!
*if,orient_,eq,0,then
    orient_='landscape'
*elseif,orient_,eq,1,then
    orient_='portrait'
*endif
!
*if,revrs_,eq,0,then
    revrs_='reverse'
*elseif,revrs_,eq,1,then
    revrs_='norm'
*endif
!
*if,colr_,eq,1,then
    colr_='mono'
*elseif,colr_,eq,2,then
    colr_='grey'
*elseif,colr_,eq,0,then
    colr_='color'
*endif
!
/ui,copy,save,%imgtyp_%,graph,%colr_%,%revrs_%,%orient_%,yes
!
*set,imgtyp_,
*set,orient_,
*set,revrs_,
*set,colr_,


w:\ansys\mac\tools\tv_create_volume.mac.html

!   TITLE:  tv_create_volume.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED  08/20/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR  VERSION
!
!   This sub-macro creates a volume, from a newly created area, by extrusion.
!   This is achieved by using the macro command CREATE_AREA, and extruding
!   a given distance, D_EXT.  The arguments used here are the same as in
!   CREATE_LINES, except for SEQNCE which is not used since the lines must
!   form a closed loop in order to create an area. Therefroe, option zero (0)
!   is always specified. The value of C_ACS is transferred directly to
!   CREATE_LINES, along with the 0 value of SEQNCE. The argument D_EXT is
!   transferred to the ANSYS command VOFFST. (See CREATE_LINES for the option
!   on the C_ACS argument)
!
!           c_acs = boolean operator to create lines in the active
!                   coordinate system.
!
!           d_ext = extrusion distance of area that forms the new volume.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! CREATE_VOLUME, c_acs, d_ext
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,c_acs,Straight or Active C.S.,0
*ask,d_ext,Extrude Distance,1
!
create_area,c_acs
!
voffst,am,d_ext
!
init_entity_num
!
lplot
!
*set,d_ext,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_extrude_aset.mac.html

!   TITLE:  tv_extrude_aset.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/02/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro extrudes a selected set of areas by a given
!   distance, dext.  It then restores the selected set to the full
!   model set that is currently under construction. The only input
!   necessary is:
!
!       A selected set of areas (each to be extruded)
!
!       dext = extrusion distance.  A 0 (zero) will abort the
!              operation.
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,_dext,Extrusion Distance,1
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*if,_dext,ne,0,then
    !
    *do,_i,_alow,_ahigh,1
        *if,asel(_i),eq,1,then
            voffst,_i,_dext
        *endif
    *enddo
*endif
!
init_entity_num
!
*set,_dext,
*set,_alow,
*set,_ahigh,
*set,_i,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_featr_set_select.mac.html

!   TITLE:  tv_featr_set_select.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     RELEASED      09/14/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This sub-macro creates an array of angular dimensions, where each
!   element of the array corresponds to a specific angle in the array.
!
!
!   COMMAND SYNTAX:
!
!                            (1)      (2)
!        FEATR_SET_SELECT, ftr_typ, ftr_num
!
!
!   ARGUMENTS:
!
!           ftr_typ = the number of angle dimensions.
!
!           ftr_num = the nth anglular dimension.
!
!
!   DESCRIPTION:
!
!   The array can be input up to 18 elements.  These angles are the
!   volume interval distances around a circle that the user defines for
!   input into PROFILE_BORE.MAC. This allows for the user to specify a
!   special shaped profile volume at the angular intervals of this array.
!   All angles must be placed in a clockwise order for correct execution
!   in ANG_DIFF.MAC.
!
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

multipro,'start',2
    *cset,1,3,ftrtyp_,'Solid Model Entity Feature Type',1
    *cset,4,6,ftrnum_,'Solid Model Entity Feature #',0
    *cset,61,62,'Selects the specified solid mod','el feature, and all associated'
    *cset,63,64,'solid model entities. Solid mod','el types: (v=1, a=2, l=3).'
multipro,'end'
!
*if,ftrnum_,ne,0,then
    *if,ftrtyp_,eq,1,then
        vsel,s,volu,,ftrnum_
        aslv,s
        lsla,s
        ksll,s
    *elseif,ftrtyp_,eq,2,then
        asel,s,area,,ftrnum_
        lsla,s
        ksll,s
    *elseif,ftrtyp_,eq,3,then
        lsel,s,line,,ftrnum_
        ksll,s
    *endif
    !
    /AUTO, 1
    /REP
    !
    lplot
*endif
!
*set,ftrtyp_,
*set,ftrnum_,


w:\ansys\mac\tools\tv_isolate_areas.mac.html

!   TITLE:  tv_isolate_areas.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  04/07/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro is used to isolate (select out) a set of areas (and
!   associated lines and keypoints) that are to be used in the creation
!   of a new volume (e.g., using the 'VA' command). These lines are
!   unattached to any volumes that may already exist. The remaining solid
!   model entities are maintained unselected and therefore do not inter-
!   fere with these areas to be operated on to create new volumes.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*if,kp_pssof,gt,0,then      ! unselects all previous model entities
    ksel,u,kp,,_kset_
*endif
!
*if,ln_pssof,gt,0,then
    lsel,u,line,,_lset_
*endif
!
*if,ar_pssof,gt,0,then
    asel,u,area,,_aset_
*endif
!
*if,vl_pssof,gt,0,then
    vsel,u,volu,,_vset_
*endif
!
*if,el_pssof,gt,0,then
    esel,u,elem,,_eset_
*endif
!
*if,nd_pssof,gt,0,then
    nsel,u,node,,_ndset_
*endif
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then              ! decision: 'There exists new volumes?'
    !
    cm,vset_100,volu            ! store new volumes in a group
    !
    aslv,selv                   ! store all existing entities associated with
        cm,aset_100,area        ! all existing new volumes in groups
    lsla,selv
        cm,lset_100,line
    ksll,selv
        cm,kset_100,kp
    !
    allsel,all                  ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    vsel,u,volu,,vset_100       ! unselects all existing solid model entities
    asel,u,area,,aset_100       ! associated with new volumes
    lsel,u,line,,lset_100
    ksel,u,kp,,kset_100
*endif
!
*get,am,area,,num,max           ! store maximum area # in 'am'
*get,lm,line,,num,max           ! store maximum line # in 'lm'
*get,km,kp,,num,max             ! store maximum keypoint # in 'km'
!
*if,am,ne,0,then
    _usecntr=1
    ar_tog_=1
    /PNUM,AREA,ar_tog_
    aplot
*else
    _usecntr=1
    ln_tog_=1
    /PNUM,LINE,ln_tog_
    lplot
*endif
!
cmdele,vset_100
cmdele,aset_100
cmdele,lset_100
cmdele,kset_100


w:\ansys\mac\tools\tv_isolate_lines.mac.html

!   TITLE:  tv_isolate_lines.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED  03/29/2000    J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro is used to isolate (select out) a set of lines (and
!   associated keypoints) that are to be used in the creation of a new
!   area and/or volume (e.g., using the 'AL' command). The remaining solid
!   model entities are maintained unselected and therefore do not interfere
!   with the line set to be operated on to create new areas and/or volumes.
!
!   Macro code portions are separate sub-sections of a macro as designated
!   in the table of contents.  These sub-sections are stand-alone sections
!   of code that may operate independently.  However, some parameters in a
!   sub-section may be dependent upon pre-existing solid model entities,
!   forcing a sub-section of code to be used in a particular order.
!
!
*get,prkey_,active,0,prkey
/nopr

allsel,all                  ! selects all existing entities
!
*if,kp_pssof,gt,0,then      ! unselects all previous model entities
    ksel,u,kp,,_kset_
*endif
!
*if,ln_pssof,gt,0,then
    lsel,u,line,,_lset_
*endif
!
*if,ar_pssof,gt,0,then
    asel,u,area,,_aset_
*endif
!
*if,vl_pssof,gt,0,then
    vsel,u,volu,,_vset_
*endif
!
*if,el_pssof,gt,0,then
    esel,u,elem,,_eset_
*endif
!
*if,nd_pssof,gt,0,then
    nsel,u,node,,_ndset_
*endif
!
*get,vm,volu,,num,max
!
*if,vm,ne,vmu,then          ! decision: 'There exists new volumes?'
    !
    cm,vset_10,volu         ! store new volumes in a group
    !
    aslv,selv               ! store all existing entities associated with
        cm,aset_10,area     ! all existing new volumes in groups
    lsla,selv
        cm,lset_10,line
    ksll,selv
        cm,kset_10,kp
        !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
    !
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*get,am,area,,num,max
!
*if,am,ne,amu,then          ! decision: 'There exists new areas?'
    !
    cm,aset_20,area         ! store new volumes in a group
    !
    lsla,r                  ! store all existing entities associated
        cm,lset_20,line     ! with all existing new areas in groups
    ksll,r
        cm,kset_20,kp
        !
    asel,u,area,,aset_20
    lsel,u,line,,lset_20    ! unselects all existing solid model
    ksel,u,kp,,kset_20      ! entities associated with new areas
    !
    allsel,all              ! selects all existing entities
    !
    *if,kp_pssof,gt,0,then      ! unselects all previous model entities
        ksel,u,kp,,_kset_
    *endif
    !
    *if,ln_pssof,gt,0,then
        lsel,u,line,,_lset_
    *endif
    !
    *if,ar_pssof,gt,0,then
        asel,u,area,,_aset_
    *endif
    !
    *if,vl_pssof,gt,0,then
        vsel,u,volu,,_vset_
    *endif
    !
    *if,el_pssof,gt,0,then
        esel,u,elem,,_eset_
    *endif
    !
    *if,nd_pssof,gt,0,then
        nsel,u,node,,_ndset_
    *endif
*endif
!
*if,vm,ne,vmu,then
    vsel,u,volu,,vset_10        ! unselects all existing solid model entities
    asel,u,area,,aset_10        ! associated with new volumes
    lsel,u,line,,lset_10
    ksel,u,kp,,kset_10
*endif
!
*if,am,ne,amu,then
    asel,u,area,,aset_20        ! unselects all existing solid model
    lsel,u,line,,lset_20        ! entities associated with new areas
    ksel,u,kp,,kset_20
*endif
!
*get,lm,line,,num,max       ! store maximum line # in 'lm'
*get,km,kp,,num,max         ! store maximum keypoint # in 'km'
!
*if,lm,ne,0,then
    _usecntr=1
    ln_tog_=1
    /PNUM,LINE,ln_tog_
    lplot
*else
    _usecntr=1
    kp_tog_=1
    /PNUM,KP,kp_tog_
    kplot
*endif
!
cmdele,vset_10
cmdele,aset_10
cmdele,lset_10
cmdele,kset_10
!
cmdele,aset_20
cmdele,lset_20
cmdele,kset_20


w:\ansys\mac\tools\tv_kp_path_ln.mac.html

!   TITLE:  tv_kp_path_ln.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/18/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This GUI command macro calculates the linear distance between a keypoint
!   and a line along the path of the crossing line. (The crossing path line
!   is attached to the keypoint)
!
!
!   ARGUMENTS:
!
!           1st prompt: Keypoint number & Line number to measure distance
!                       between:
!
!                                   KP# and LN#
!
!           2nd prompt: If specified keypoint is attached to mor than 1 line,
!                       then the particular line attached to the keypoint must
!                       be specified in the 3rd argument:
!
!
!   DESCRIPTION:
!
!   This macro calculates the linear distance between a keypoint and a line
!   along a line attached to the keypoint, and crossing the specified line.
!   This distance is to the point where the 2 lines cross (intersect), but
!   do not share a keypoint at the point of intersection. Therefore, this
!   macro is valid only for lines that cross/overlap each other, but are not
!   attached; and the input lines are straight. This allows the user to calc-
!   ulate the distance of any of the 4 endpoints of the 2 crossing lines from
!   the point of crossing of the lines.
!
!   If the specified keypoint is attached to more than 1 line, then the par-
!   ticular line whose path crosses the line specified in the 1st prompt must
!   be specified in 2nd prompt.
!
!   The output is to a screen dialog box.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

multipro,'start',2
    *cset,1,3,kpt_,'Enter KP #',0
    *cset,4,6,ln_,'Enter Line #',0
    *cset,61,62,'Calculates the distance bet','ween a KP and a line, along'
    *cset,63,64,'the path of a line attach','ed to the KP.'
multipro,'end'
!
tol_=0.0001
prec_=4
!
cm,kset_,kp
cm,lset_,line
!
ksel,s,kp,,kpt_
lslk,s,0
*get,numlns_,line,,count
!
*if,numlns_,gt,1,then
    multipro,'start',1
        *cset,1,3,pthln_,'Line #',0
        *cset,61,62,'The number of lines attached',' to the KP is > 1.'
        *cset,63,64,'Enter the line # of the path.'
    multipro,'end'
*elseif,numlns_,eq,1,then
    get_max_entity
    pthln_=lm
*endif
!
cmsel,s,kset_
cmsel,s,lset_
!
*if,pthln_,ne,0,then
    *get,kppath1_,line,pthln_,kp,1
    *get,kppath2_,line,pthln_,kp,2
    !
    *if,kppath1_,eq,kpt_,then
        endkp_=kppath2_
    *else
        endkp_=kppath1_
    *endif
    !
    *get,kpLn1_,line,ln_,kp,1
    *get,kpLn2_,line,ln_,kp,2
    !
    alpha_=anglek(kpt_,endkp_,kpLn1_)
    beta_=anglek(kpLn1_,kpLn2_,kpt_)
    gamma_=(180-((alpha_*dconv)+(beta_*dconv)))*rconv
    !
    s_=distkp(kpt_,kpLn1_)
    !
    dpath_=s_*(sin(beta_))/(sin(gamma_))
    !
    *if,abs(dpath_),lt,tol_,then
        dpath_=0
    *else
        round_num,dpath_,prec_
        dpath_=num_
    *endif
    !
!-------------------------------------------------------
*msg,ui,%kpt_%,%ln_%,%pthln_%,%dpath_%
Distance Between ( KP %i , L %i, along path L %i ) = %g
!-------------------------------------------------------
!
*endif
!
init_entity_num
cmsel,s,kset_
cmsel,s,lset_
!
lplot
!
*set,tol_,
*set,prec_,
*set,ln_,
*set,kpt_,
*set,dpath_,
*set,kpLn1_,
*set,kpLn2_,
*set,pthln_,
*set,s_,
*set,alpha_,
*set,beta_,
*set,gamma_,
*set,kppath1_,
*set,kppath2_,
*set,num_,
*set,endkp_,
*set,numlns_,
cmdele,kset_,
cmdele,lset_,


w:\ansys\mac\tools\tv_mark_cg.mac.html

!   TITLE:  tv_mark_cg.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    09/12/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This macro creates a keypoint at, and marks the position of, the center
!   of gravity (CG) of a volume or set of volumes and outputs the coordinates
!   and total volume to a dialogue box, and a set of parameters.
!
!
!   ARGUMENTS:
!
!       (1) c_or_d = create or delete CG marker/keypoint parameter:
!
!               0 (or blank) = create CG marker/keypoint
!
!               1 = delete CG marker/keypoint
!
!       (2) rcs = relative coordinate system
!
!
!   DESCRIPTION:
!
!   The selected volume(s) CG is visually marked with a set of axes. A keypoint
!   is placed at the CG location for information/measurement query. The key-
!   point number parameter is called 'cgkp_'.
!
!       OUTPUT @ DIALOGUE BOX:
!
!           C.S.= ... --- X_cg = ... , Y_cg = ... , Z_cg = ... --- V = ...
!
!       OUTPUT PARAMETERS:
!
!               XCG%RCS% = X (or R) coordinate of CG
!               YCG%RCS% = Y (or THETA) coordinate of CG
!               ZCG%RCS% = Z (or PHI) coordinate of CG
!               VCG = total volume of selected (CG) volumes
!
!           where %RCS% is simply the integer number of the relative C.S.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*get,acs1_,active,,csys
!
multipro,'start',3
    *cset,1,3,cord_,'Create(0) or Delete(1) C.G.',0
    *cset,4,6,rcs_,'C.S. to mark C.G. relative to',acs1_
    *cset,7,9,prec_,'Enter Decimal Precision',4
    *cset,61,62,'Creates a C.G. keypoint and',' marker relative to a'
    *cset,63,64,'specified coordinate system.'
multipro,'end'
!
cm,vset1_,volu
!
init_entity_num
cmsel,s,vset1_
!
*if,cord_,eq,0,then
    *get,cgkptyp_,parm,cgkp_,type
    !
    *if,cgkptyp_,ne,-1,then
        ksel,s,kp,,cgkp_
        lslk,s,0
        ldele,all,,,1
        kdele,cgkp_
        !
        get_max_entity
        !
        *set,cgkp_,
    *endif
    !
    *if,prec_,le,0,then
        prec_=4
    *endif
    !
    tol_=10**(-prec_-1)
    !
    csys,0
    vsum
    !
    *get,v_,volu,,volu
    !
    *get,vcgx_,volu,,cent,x
    *get,vcgy_,volu,,cent,y
    *get,vcgz_,volu,,cent,z
    !
    k,,vcgx_,vcgy_,vcgz_
    !
    get_max_entity
    !
    cgkp_=km
    !
    csys,rcs_
    !
    *get,racs_,active,,csys
    *get,racstyp_,cdsy,racs_,attr,kcs
    !
    *if,racstyp_,ne,0,then
        clocal,csn+5,0,0,0,0,0,0,0
    *endif
    !
    k,,kx(cgkp_)+1,ky(cgkp_),kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_),kz(cgkp_)-1
    k,,kx(cgkp_)-1,ky(cgkp_),kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_),kz(cgkp_)+1
    k,,kx(cgkp_),ky(cgkp_)+1,kz(cgkp_)
    k,,kx(cgkp_),ky(cgkp_)-1,kz(cgkp_)
    !
    get_max_entity
    !
    *do,yz_,1,6,1
        lstr,cgkp_,km-(6-yz_)
    *enddo
    !
    get_max_entity
    !
    csys,rcs_
    !
    xcg%rcs_%=kx(cgkp_)
    ycg%rcs_%=ky(cgkp_)
    zcg%rcs_%=kz(cgkp_)
    !
    x_=kx(cgkp_)
    !
    *if,abs(x_),lt,tol_,then
        x_=0
    *else
        *if,abs(x_),ge,(10*tol_),then
            round_num,x_,prec_
        *else
            round_num,x_,prec_+1
        *endif
        !
        x_=num_
    *endif
    !
    y_=ky(cgkp_)
    !
    *if,abs(y_),lt,tol_,then
        y_=0
    *else
        *if,abs(y_),ge,(10*tol_),then
            round_num,y_,prec_
        *else
            round_num,y_,prec_+1
        *endif
        !
        y_=num_
    *endif
    !
    z_=kz(cgkp_)
    !
    *if,abs(z_),lt,tol_,then
        z_=0
    *else
        *if,abs(z_),ge,(10*tol_),then
            round_num,z_,prec_
        *else
            round_num,z_,prec_+1
        *endif
        !
        z_=num_
    *endif
    !
    *if,v_,lt,tol_,then
        v_=0
    *else
        *if,v_,ge,(10*tol_),then
            round_num,v_,prec_
        *else
            round_num,v_,prec_+1
        *endif
        !
        v_=num_
        vcg=num_
    *endif
    !
    *if,racstyp_,eq,0,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- X_cg = %g , Y_cg = %g , Z_cg = %g --- V = %g
!--------------------------------------------------------------
    *else
        *if,racstyp_,eq,1,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- R_cg = %g , THETA_cg = %g , Z_cg = %g --- V = %g
!--------------------------------------------------------------
        *elseif,racstyp_,eq,2,then
!--------------------------------------------------------------
*msg,ui,%rcs_%,%x_%,%y_%,%z_%,%v_%
C.S.= %i --- R_cg = %g , THETA_cg = %g , PHI_cg = %g --- V = %g
!--------------------------------------------------------------
        *endif
    *endif
    !
    *if,racstyp_,ne,0,then
        csdele,csn+5
    *endif
    !
    *set,x_,
    *set,y_,
    *set,z_,
    *set,tol_,
    *set,num_,
    *set,racs_,
    *set,racstyp_,
    *set,yz_,
    *set,vcgx_,
    *set,vcgy_,
    *set,vcgz_,
    *set,cgkptyp_,
    *set,v_,
*elseif,cord_,eq,1,then
    ksel,s,kp,,cgkp_
    lslk,s,0
    ldele,all,,,1
    kdele,cgkp_
    !
    *set,cgkp_,
*endif
!
csys,acs1_
init_entity_num
isolate_lines
cmsel,s,vset1_
aslv,s
lsla,a
!
lplot
!
*set,cord_,
*set,rcs_,
*set,acs1_,
*set,prec_,
cmdele,vset1_


w:\ansys\mac\tools\tv_max_ent_dim.mac.html

!   TITLE:  tv_max_ent_dim.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   04/07/2000      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR  VERSION
!
!   This sub-macro is used to retrieve the maximum value, within a selected
!   set, of the dimension of a specified entity:
!
!           ENTITY      DIMENSION
!          --------    -----------
!           line         length
!           area         area
!           volume       volume
!
!   Input data necessary to run this macro:
!
!       A selected set of specified entities
!
!       entity = 'l' for line entities
!                'a' for area entities
!                'v' for volume entities
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! MAX_ENTY_DIM, entity
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,entity,l(length) a(area) v(vol),'l'
!
*if,entity,eq,'l',then          ! assignment of entity variable, 'ev'
    ev='line'
*elseif,entity,eq,'a',then
    ev='area'
    asum
*elseif,entity,eq,'v',then
    ev='volu'
    vsum
*else
    ev='z'
*endif
!
*if,ev,ne,'z',then              ! If ev is assigned 'z', then abort
    !
    *get,emax,ev,,num,max       ! retrieve MIN and MAX entity numbers
    *get,emin,ev,,num,min
    !
    *get,ecount,ev,,count       ! number of specified entities in the
    !                           ! selected entity set
    *do,ii,1,ecount,1
        *if,ii,eq,1,then
            e%ii%=emin
        *else
            jj=ii-1
            *get,xx,ev,e%jj%,nxth
            e%ii%=xx
        *endif
    *enddo
*endif
!
*do,ii,1,ecount,1
    !
    *if,entity,eq,'l',then
        *get,ec%ii%,line,e%ii%,leng
    *elseif,entity,eq,'a',then
        *get,ec%ii%,area,e%ii%,area
    *elseif,entity,eq,'v',then
        *get,ec%ii%,volu,e%ii%,volu
    *endif
*enddo
!
*do,iij_,1,ecount,1
    !
    *if,iij_,eq,1,then
        xx=ec1
        yy=e1
    *else
        *if,xx,gt,ec%iij_%,then
            xx=xx
            yy=yy
        *else
            xx=ec%iij_%
            yy=e%iij_%
        *endif
    *endif
*enddo
!
*if,entity,eq,'l',then
    max_leng=xx
    max_lnum=yy
    *msg,ui,%yy%,%xx%
    Longest Line = %i ------ Length = %g
*elseif,entity,eq,'a',then
    max_area=xx
    max_anum=yy
    *msg,ui,%yy%,%xx%
    Largest Area = %i ------ Area = %g
*elseif,entity,eq,'v',then
    max_vol=xx
    max_vnum=yy
    *msg,ui,%yy%,%xx%
    Largest Volume = %i ------ Volume = %g
*endif
!
*do,ijk_,1,ecount,1
    *set,e%ii%,
    *set,ec%ii%
    *set,xx,
    *set,yy,
    *set,ev,
    *set,entity,
    *set,emax,
    *set,emin,
*enddo
!
*set,ijk_,
*set,iij_,


w:\ansys\mac\tools\tv_norm_cut_pln_ct.mac.html

!   TITLE:  tv_norm_cut_pln_ct.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -   05/08/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR  VERSION
!
!   This sub-macro creates a cutting plane for partitioning volumes.
!   The cutting plane must be created in a CARTESIAN coordinate system.
!   The orientation of the cutting plane is normal to the specified
!   coordinate direction. The size of the cutting plane is determined by
!   the maximum line length in the the model.
!
!
!       cdir = coordinate direction that the cutting plane is perpen-
!              dicular to. This designates the orientation of the plane
!              a such that it is a speified distance from the origin of
!              the specified coordinate system. The coordinate direction
!              designations are 'x', 'y' and 'z' for cartesian; and 'x',
!              'y' and 'z' for r, theta and z coordinates in cylindrical
!              coordinates.
!
!       cd = The distance along the coordinate direction from the origin
!            of the coordinate system to the cutting plane surface,
!            measured along the coordinate direction as specified in
!            'cdir'.
!
!
!------------------------------ COMMAND SYNTAX -----------------------------
!
! NORM_CUT_PLN_CT, cdir, cd
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,_cdir,Normal Coordinate Direction,'x'
*ask,_cd,Normal Distance,0
!
cm,_vset1,volu
!
init_entity_num
!
max_enty_dim,'l'
_lpln=10*max_leng       ! cutting plane length
!
*if,_lpln,ne,0,then
    *if,_cdir,eq,'x',then
        !
        k,,_cd,-_lpln,_lpln
        k,,_cd,-_lpln,-_lpln
        k,,_cd,_lpln,-_lpln
        k,,_cd,_lpln,_lpln
        !
        create_area
        !
    *elseif,_cdir,eq,'y',then
        !
        k,,_lpln,_cd,_lpln
        k,,_lpln,_cd,-_lpln
        k,,-_lpln,_cd,-_lpln
        k,,-_lpln,_cd,_lpln
        !
        create_area
        !
    *elseif,_cdir,eq,'z',then
        !
        k,,-_lpln,-_lpln,_cd
        k,,_lpln,-_lpln,_cd
        k,,_lpln,_lpln,_cd
        k,,-_lpln,_lpln,_cd
        !
        create_area
        !
    *endif
    !
    vsel,s,volu,,_vset1
    !
    vol_part_area,am
    !
    init_entity_num
    !
    cmdele,_vset1
*endif
!
*set,_lpln,
*set,_cd,
*set,_cdir,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_parallel_lines.mac.html

!   TITLE:  tv_parallel_lines.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/28/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This macro creates a series of lines parallel to a set of selected lines.
!
!
!   ARGUMENTS:
!
!       (1) plncs = the coordinate system whose XY plane is parallel to
!                   the plane which wiil contain the parrallel lines. Default
!                   is active coordinate system.
!
!       (2) side = the side to the selected line to create the parallel line.
!
!                       't' = top
!                       'b' = bottom
!                       'l' = left
!                       'r' = right
!
!               *** NOTE: For vertical and horizontal lines, it is safest to
!                         specify the sides as follows:
!
!                           vertical - left ('l') or right ('r')
!                           horizontal - top ('t') or bottom ('b')
!
!
!       (3) dist =  the distance between parallel lines
!
!       (4) sfact = new line length scaling factor (default = 2)
!
!
!   DESCRIPTION:
!
!   The parrallel line(s) area created in the plane parallel to the XY plane
!   of the plane coordinate system specified in argument 1, 'plncs'.
!
!   This macro creates the parallel line(s) a normal distance 'dist' from
!   the selected lines.  The lines are created on the side specified by
!   argument 2.  TOP, BOTTOM, LEFT and RIGHT are relative positions, and
!   rae based on the perspective of the user.  This 'perspective' is deter-
!   mined from the plane coordinate system specified in argument 1. From,
!   this coordinate system, TOP is the region in the +Y direction; BOTTOM is
!   the region in the -Y direction; LEFT is the region in the -X direction
!   and RIGHT is the region in the +X direction.  Therefore, the perspective
!   of the user is the XY plane with the +Z axis pointing out of the graphics
!   window.
!
!   The length of the new lines are determined by the scaling factor, 'sfact',
!   specified in argument 4.  If left blank, the default value is 2.
!
!   The length of the new line is determined by the following formula:
!
!                       L_new = L_orig + 2*(sfact * dist)
!
!   where  L_new = length of the new line
!          L_orig = length of the original (selected) line
!
!   This line is centered parallel with the original line, with each end
!   greater in length by the amount (sfact * dist). Argument 4 allows the
!   user to adjust the resulting lengths of the new lines if desired.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*get,acs1__,active,,csys
!
*ask,plncs_,'Enter Plane C.S. #',acs1__
!
multipro,'start',4
    *cset,1,3,origln_,'Enter Line #',0
    *cset,4,6,sid_,'Side 1=L, 2=R, 3=T, 4=B',2
    *cset,7,9,dist_,'Enter Line Distance(s)',0
    *cset,10,12,sfact_,'Enter Scaling Factor For Length',2
    *cset,61,62,'Creates a set of lines parallel',' to a selected set of lines,'
    *cset,63,64,'offset by a specified distance.',' Enter pertinent information.'
multipro,'end'
!
*if,sid_,eq,1,then
    side_='l'
*elseif,sid_,eq,2,then
    side_='r'
*elseif,sid_,eq,3,then
    side_='t'
*elseif,sid_,eq,4,then
    side_='b'
*endif
!
*get,plncstyp,cdsy,plncs_,attr,kcs
!
*if,plncstyp,ne,0,then
    plncs_=csn+5
    clocal,plncs_,0,0,0,0,0,0,0
*endif
!
*if,origln_,eq,0,then
    cm,origlns_,line
    entity_array,'l','parln_','array'
    lnmax_=ecount
*else
    lsel,s,line,,origln_
    cm,origlns_,line
    entity_array,'l','parln_','array'
    lnmax_=ecount
*endif
!
*do,aaa_,1,lnmax_,1
    csys,plncs_
    !
    *get,lnl_,line,parln_(aaa_,1),leng
    !
    *get,kp11_,line,parln_(aaa_,1),kp,1
    *get,kp12_,line,parln_(aaa_,1),kp,2
    !
    clocal,csn+6,1,kx(kp11_),ky(kp11_),kz(kp11_),0,0,0
    !
    kpang_=ky(kp12_)
    ang_convert,'kpang_',0
    !
    *if,kpang_,le,89,then
        k,,1,90,0
    *elseif,kpang_,le,179,then
        k,,1,180,0
    *elseif,kpang_,le,269,then
        k,,1,270,0
    *elseif,kpang_,le,359,then
        k,,1,0,0
    *elseif,kpang_,gt,359,then
        k,,1,90,0
    *endif
    !
    init_entity_num
    thrdkp_=km
    !
    cskp,csn+7,0,kp11_,kp12_,thrdkp_
    !
    *if,kpang_,le,90,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,180,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=1
        *elseif,side_,eq,'r',then
            sign_=-1
        *endif
    *elseif,kpang_,le,270,then
        *if,side_,eq,'t',then
            sign_=-1
        *elseif,side_,eq,'b',then
            sign_=1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *elseif,kpang_,le,360,then
        *if,side_,eq,'t',then
            sign_=1
        *elseif,side_,eq,'b',then
            sign_=-1
        *elseif,side_,eq,'l',then
            sign_=-1
        *elseif,side_,eq,'r',then
            sign_=1
        *endif
    *endif
    !
    k,,-sfact_*dist_,sign_*dist_,0
    k,,lnl_+(sfact_*dist_),sign_*dist_,0
    !
    create_lines,,1
    !
    kdele,thrdkp_
    init_entity_num
    !
    lplot
*enddo
!
lsel,s,line,,lm-(aaa_-1),lm,1
cm,newlns,line
!
init_entity_num
!
csdele,csn+5,csn+7,1
csys,acs1__
!
wpcsys,1,plncs_
/AUTO, 1
!
lplot
!
*msg,ui,%plncs_%
Working Plane Location: PLANE C.S. = %g
!
*set,plncs_,
*set,acs1__,
*set,origln_,
*set,plncstyp,
*set,lnmax_,
*set,parln_(1),
*set,kpang_,
*set,sign_,
*set,sfact_,
*set,lnl_,
*set,thrdkp_,
*set,dist_,
*set,aaa_,
*set,sid_,
*set,side_,
*set,kp11_,
*set,kp12_,


w:\ansys\mac\tools\tv_pocket_cut.mac.html

!   TITLE:  tv_pocket_cut.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    04/10/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!
!   This sub-macro is used to create a pocket cut into a volume, where
!   the pocket shape is inscribed within the selected area profile on the
!   volume, and whose lines are parallel to the selected area lines. The
!   distance between the parallel lines is 'wall_thk', which is the thick-
!   ness of the remaining wall after the operation is completed. This
!   results in a "hollwed-out" volume of constant wall thickness. The
!   lines must be straight lines, i.e., no arc or splined lines.
!
!   For automatic extrusion, the program will choose the correct direc-
!   tion of extrusion if ALL REMAINING keypoints (all keypoints exclud-
!   ing the keypoints of the selected area) in the volume lie on one
!   side of the z axis.  For the case of a complex volume where key-
!   points in the volume lie on both the positive and negative side,
!   the over-ride direction option should be used. This is done by spec-
!   ifying a KP number for p1od.  If p1od is specified, then the pro-
!   gram will relinquish direction control to the user.
!
!   NOTE:   The centroid of the selected area profile is assumed to be
!       at or near the center of the selected area, and therefore
!       within the confines of the area line loop. There can be an
!       ill-formed area profile that WILL violate the intended ex-
!       ecution of this macro. If the centroid is located outside
!       of the loop, or any such location that will cause the dir-
!       ection of any of the KP c.s.'s to be reversed, the boolean
!       operation will fail to execute properly or at all.
!
!       A general 'rule-of-thumb' is to choose areas that are close
!       to a symmetric form around the centroid of area such that
!       the centroid lies within the line loop.
!
!   Input data necessary to run this macro:
!
!       A selected area
!
!       wall_thk = desired wall thickness
!
!       dcut_n = depth of cut into volume (distance along a path
!            normal to the surface)
!
!       offset = boolean variable to choose either normal extrude
!            or skewed extrude. Valid arguments:
!
!               offset='normal'
!               offset='skew'
!
!   The following arguments are valid only when offset='skew'. If
!   offset='normal', they need not be specified:
!
!       dcut_s = depth of cut into volume (distance along the skew
!            path)
!
!            *NOTE: If dcut_s is left blank or 0, dcut_n will be
!                   used to calculate the skew path length.
!
!       phi_xz = skew angle as measured from the -z axis, in the
!            xz plane:
!
!               phixz < 0: skew toward - x axis direction
!               phixz > 0: skew toward + x axis direction
!
!       phi_elev = skew angle as measured from xz plane to a line
!              that connects the origin of p1cs to a point in
!              space (y coordinate of point is not 0):
!
!               phi_elev < 0: skew toward - y direction
!               phi_elev > 0: skew toward + y direction
!
!           The skew line direction is measured form p1cs. This
!           is the active c.s. that is used to measure phi_xz
!           and phi_elev from. Therefore, phi_xz is measured
!           from the p1cs -z axis, and phi_elev is measured from
!           the p1cs xz plane.  Note that p1cs has its origin
!           located at the minimum keypoint number of the selected
!           area keypoints, kset1.
!
!   A case for complex shaped volumes may exist where the user may
!   want to over-ride the extrude direction. For this case, set the
!   parameters:
!           p1od = origin keypoint of 1st c.s.
!           p2od = x axis keypoint, which establishes
!                  the extrude direction
!
!   If these parameters are not specified, then the program will
!   will choose the direction of extrusion, which may be incorrect.
!
!
!----------------------------- COMMAND SYNTAX ---------------------------
!
!  pocket_cut, wall_thk, p1od, p2od, offset, phi_xz, phi_elev, dcut_n, dcut_s
!
!------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*ask,wall_thk,wall thickness,1
*ask,p1od,origin KP (over-ride),
*ask,p2od,X axis KP (over-ride),
*ask,offset,normal or skew extrude,'normal'
!
*ask,phi_xz,skew angle IN XZ plane,30
*ask,phi_elev,skew angle FROM XZ plane,45
*ask,dcut_n,normal extrude distance,1
*ask,dcut_s,skew extrude distance,
!
!-------------------------------------------------------------------------
!- A. - Create Volume, Area, Line, and Keypoint Sets for Operations ------
!-------------------------------------------------------------------------
!
get_max_entity
!
a2bcut=am       ! area surface to be (2b) cut into (selected)
!
csys,0
!
asum,default
!
*get,pcx,area,,cent,x   ! x, y and z location of area centroid
*get,pcy,area,,cent,y
*get,pcz,area,,cent,z
!
k,,pcx,pcy,pcz      ! place keypoint at centroid
!
*get,pc,kp,,num,max ! assign parameter to centroid KP number
!
lsla,selv   `   ! select lines associated with a2bcut
cm,lset1,line
!
ksll,selv       ! select keypoints associated with lines of a2bcut
ksel,a,kp,,pc       ! plus area centroid KP.
cm,kset1,kp
!
vsla,selv,0     ! select volume associated with a2bcut
cm,vset1,volu
!
aslv,s          ! select all areas of volume excluding a2bcut
asel,u,area,,a2bcut
!
vsel,s,volu,,vset1
aslv,s
lsla,s          ! select all keypoints of volume excluding the
ksll,s          ! keypoints of a2bcut
ksel,u,kp,,kset1
cm,kset2,kp
!
!----------------------------------------------------------------------
!-- B. --- Check Path Direction for Correct Extrude Direction ---------
!----------------------------------------------------------------------
!
*if,p1od,eq,0,then
    !
    init_entity_num
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
    *get,kmin,kp,,num,min       ! retrieve MIN keypoint number in a2bcut
    !
    ksel,r,kp,,kmin         ! select first kp to set up c.s. on
    lslk,r,0            ! select lines attached to kmin
    *get,ln1,line,,num,min      ! retieve lines ln1 and ln2
    *get,ln2,line,,num,max
    !
    *get,k1,line,ln1,kp,1       ! check that 2nd KP of line 1 is not kmin
    *if,k1,eq,kmin,then     ! and assign k1 that KP number
        *get,k1,line,ln1,kp,2
    *endif
    !
    *get,k2,line,ln2,kp,1       ! check that 2nd KP of line 2 is not kmin
    *if,k2,eq,kmin,then     ! and assign k2 that KP number
        *get,k2,line,ln2,kp,2
    *endif
    !
    ksel,selv,kp,,kset1
    !
    csn=csn+1           ! create 1st c.s. using k1 for x direction,
    p1cs=csn
    cskp,p1cs,0,kmin,k1,pc
    !
    ksel,s,kp,,kset2        ! select KP's of kset2
    *get,k2max,kp,,num,max      ! retrieve MAX KP number in kset2
    ksel,a,kp,,k1           ! reselect k1 and k2
    ksel,a,kp,,k2
    !
    ksel,selv,kp,,kset1
    !
    *if,kz(k2max),gt,0,then     ! if z position of k2max is positive, then
        cskp,p1cs,0,kmin,k2,pc  ! recreate c.s. using k2 for x direction
    *endif
*else
    init_entity_num
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
    csn=csn+1
    p1cs=csn
    cskp,p1cs,0,p1od,p2od,pc
    !
*endif
!
!----------------------------------------------------------------------
!-- C. ------------------- Create Keypoint C.S.'s ---------------------
!----------------------------------------------------------------------
!
init_entity_num
!
asel,selv,area,,a2bcut      ! select all entities of a2bcut
lsel,selv,line,,lset1
ksel,selv,kp,,kset1
!
*get,kcount,kp,,count       ! number of keypoints in a2bcut
!
max_enty_dim,'l'        ! retrieve MAX line length
!
*do,i,1,kcount,1
    !
    j=i+1
    m=i+2
    !
    csys,p%i%cs
    !
    ksel,r,loc,x,0          ! retrieve KP at c.s. origin
    ksel,r,loc,y,0
    ksel,r,loc,z,0
    *get,k%i%,kp,,num,max
    !
    ksel,s,kp,,kset1        ! reselect KP's of kset1
    !
    lsel,r,loc,x,0,1.2*max_leng ! select line along x axis of p%i%cs
    lsel,r,loc,y,0
    !
    *get,lnum,line,,num,max
    !
    lsel,s,line,,lset1      ! reselect lines of lset1
    !
    *get,k%j%,line,lnum,kp,1    ! check that 2nd KP of line 2 is
    *if,k%j%,eq,k%i%,then       ! not kmin and assign k2 that KP
        *get,k%j%,line,lnum,kp,2    ! number
    *endif
    !
    ksel,r,kp,,k%j%         ! select 2nd kp to set up c.s. on
    lslk,r,0            ! select lines attached to kmin
    *get,ln1,line,,num,min      ! retieve lines ln1 and ln2
    *get,ln2,line,,num,max
    !
    *if,ln1,ne,lnum,then        ! assign to 'lnum' the line 'ln1' or 'ln2'
        lnum=ln1        ! that is not equal to 'lnum'
    *else
        lnum=ln2
    *endif
    !
    ksel,selv,kp,,kset1     ! reselect KP's of kset1
    !
    lsel,r,line,,lnum       ! select keypoints associated with 'lnum
    ksll,r
    *get,k1lnum,kp,,num,min
    *get,k2lnum,kp,,num,max
    !
    *if,k1lnum,ne,k%j%,then     ! assign to 'k%m%' the KP 'k1lnum'
        k%m%=k1lnum     ! or 'k2lnum' that is not equal to 'k%j%'
    *else
        k%m%=k2lnum
    *endif
    !
    ksel,selv,kp,,kset1     ! reselect KP's of kset1
    !
    csn=csn+1           ! create next c.s.
    p%j%cs=csn
    cskp,p%j%cs,0,k%j%,k%m%,pc
    !
    asel,selv,area,,a2bcut      ! select all entities of a2bcut
    lsel,selv,line,,lset1
    ksel,selv,kp,,kset1
    !
*enddo
!
asel,selv,area,,a2bcut      ! select all entities of a2bcut
lsel,selv,line,,lset1
ksel,selv,kp,,kset1
!
!----------------------------------------------------------------------
!-- D. --------------------- Create Area Profile ----------------------
!----------------------------------------------------------------------
!
*do,i,1,kcount,1
    !
    j=i+1
    m=i-1
    !
    csys,p%i%cs
    !
    k,,-0.5*max_leng,wall_thk,0
    k,,1.5*max_leng,wall_thk,0
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    csys,p%j%cs
    !
    k,,-0.5*max_leng,wall_thk,0
    k,,1.5*max_leng,wall_thk,0
    !
    *get,km,kp,,num,max
    !
    lstr,km,km-1
    !
    init_entity_num
    !
    lsbl,lm-1,lm,,delete,delete
    !
    init_entity_num
    !
    p%i%=km
    !
    ldele,lm-1,lm,1
    !
    init_entity_num
    !
    *if,i,gt,1,then
        lstr,p%m%,p%i%
    *endif
    !
*enddo
!
pdrgl=%p1%      ! point of origin for the drag line
!
init_entity_num
!
lsel,selv,line,,lm-(kcount-2),lm
ksll,selv
!
nummrg,kp,.001,.001
!
al,all
!
init_entity_num
!
!----------------------------------------------------------------------
!-- E. ------------------ Perform Boolean Operation -------------------
!----------------------------------------------------------------------
!
*if,offset,eq,'normal',then
    !
    voffst,am,-dcut_n
    !
    init_entity_num
    !
    vsbv,vset1,vm,,delete,delete
    !
    init_entity_num
    !
    lplot
    !
*elseif,offset,eq,'skew',then
    !
    *if,dcut_s,eq,0,then
        !
        x=dcut_n*tan(phi_xz*rconv)
        c=sqrt((dcut_n**2)+(x**2))
        y=c*tan(phi_elev*rconv)
        z=dcut_n
        !
        csys,p1cs
        !
        csn=csn+1
        clocal,csn,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *else
        y=dcut_s*sin(phi_elev*rconv)
        c=dcut_s*cos(phi_elev*rconv)
        x=c*sin(phi_xz*rconv)
        z=c*cos(phi_xz*rconv)
        !
        csys,p1cs
        !
        csn=csn+1
        clocal,csn,0,kx(pdrgl),ky(pdrgl),kz(pdrgl),0,0,0
        !
        k,,x,y,-z
        !
        init_entity_num
        !
        lstr,pdrgl,km
        !
        init_entity_num
        !
        vdrag,am,,,,,,lm
        ldele,lm
        !
        init_entity_num
        !
        vsbv,vset1,vm,,delete,delete
        !
        init_entity_num
        !
        lplot
    *endif
*endif
!
!----------------------------------------------------------------------
!-- E. ---------------------- Undefine Parameters ---------------------
!----------------------------------------------------------------------
!
*do,i,2,(kcount+1),1
    csdele,p%i%cs
    *set,p%i%,
    *set,p%i%cs,
*enddo
!
*set,wall_thk,
*set,offset,        ! undefine parameters that may be used in
*set,dcut_s,        ! future macro calls
*set,dcut_n,
*set,phi_xz,
*set,phi_elev,
*set,ovr_dir,
*set,pdrgl,
*set,p1od,
*set,p2od,
*set,kcount,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_profile_coords.mac.html

!   TITLE:  tv_profile_coords.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    08/09/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This macro creates an output file of keypoint coordinates of a selected
!   set of lines.
!
!
!   ARGUMENTS:
!
!       (1) cs = the coordinate system number to measure KP coordinates relative
!                to. If desired C.S. is the active C.S., then simply input:
!
!                                       cs = 'a'
!
!       (2) strt_kp = the 1st keypoint in the line profile to begin tabulation
!                     of coordinates.
!
!       (3) prec = the desired decimal precision of the coordinates. Must be
!                  an integer value of 1 through 8.  If left blank, defaults
!                  to 3.
!
!       (4) prm = create keypoint structured file or parameter structured file.
!
!                   0 (or blank) = keypoint structured file
!                   1 = parameter structured file
!
!
!   DESCRIPTION:
!
!   Each line in the selected set must be connected in a continuous chain. The
!   line set may be open-ended or may form a closed loop.  However, the line
!   set cannot have any branching keypoints.
!
!   The coordinate system may be any type.  Whatever type the C.S., the X, Y
!   and Z components correspond to that ype of coordinate (e.g., X,Y,Z are
!   X,Y,Z in cartesian; X,Y,Z are R, THETA, Z in cylindrical; etc.) If the
!   active C.S. is desired, then the 1st argument is the character scalar 'a'.
!
!   The coordinates are full-precision real numbers.  A desired decimal may
!   be specified for argument 3, 'prec', and must be an integer value of 1
!   through 8. If this argument is left blank, the precision defaults to 3
!   decimal places of accuracy.
!
!   The output file has the following name:     pf_coord.mac
!
!   This file has 2 options for output:
!
!           1.) keypoint (numbered) structure file. This sets the numerical
!               value of the coordinates in the keypoint command, allowing
!               for cut-and-paste useage.
!
!           2.) parameter structured file. This creates the parameters for
!               the dimensions of each point in a profile, and the keypoint
!               commands in parameter form.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

cm,lnset_,line
*get,numlns_,line,,count
ksll,s
*get,kpcnt_,kp,,count
!
*get,acs1_,active,,csys
!
multipro,'start',4
    *cset,1,3,csnum_,'Enter C.S. to Measure In',acs1_
    *cset,4,6,skp_,'Enter 1st Keypoint of Profile',0
    *cset,7,9,prec_,'Enter Decimal Precision',3
    *cset,10,12,prm_,'Parameters (1) or KP (0)',0
    *cset,61,62,'Calculates the X,Y,Z and abs','olute (linear) distance'
    *cset,63,64,'between 2 keypoints. Enter',' the keypoint numbers.'
multipro,'end'
!
tol_=10**(-(prec_+1))
!
csys,csnum_
!
!------------------------- Create Coordinate File -------------------------
!
/output,pf_coord,mac
!
*msg,info

/output
*if,prm_,eq,0,then
    /output,pf_coord,mac,,append
!----------------------------------------------
*msg,info,%csnum_%
Keypoint Coordinates Measured From:  C.S. = %i
!----------------------------------------------
    /output
*elseif,prm_,eq,1,then
    /output,pf_coord,mac,,append
!--------------------------------------------------------
*msg,info,%csnum_%
Keypoint Coordinate Parameters Measured From:  C.S. = %i
!--------------------------------------------------------
    /output
*endif
!
/output,pf_coord,mac,,append
!
*msg,info

*msg,info
KP#     X       Y       Z
!
*msg,info

/output
!
*set,kp_1st_,
!
*do,aaa_,1,numlns_,1
    ksel,s,kp,,skp_
    !
    dx__=kx(skp_)
    !
    *if,abs(dx__),lt,tol_,then
        dx__=0
    *else
        round_num,dx__,prec_
        dx__=num_
    *endif
    !
    dy__=ky(skp_)
    !
    *if,abs(dy__),lt,tol_,then
        dy__=0
    *else
        round_num,dy__,prec_
        dy__=num_
    *endif
    !
    dz__=kz(skp_)
    !
    *if,abs(dz__),lt,tol_,then
        dz__=0
    *else
        round_num,dz__,prec_
        dz__=num_
    *endif
    !
    *if,skp_,ne,kp_1st_,then
        *if,prm_,eq,0,then
            /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_,%dx__%,%dy__%,%dz__%
%i ---  k,,%g, %g, %g
!------------------------------------
            /output
        *elseif,prm_,eq,1,then
            /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_
Keypoint # %i
*msg,info,%dx__%
Dx0 =%g
*msg,info,%dy__%
Dy0 =%g
*msg,info,%dz__%
Dz0 =%g
*msg,info
!
!------------------------------------
            /output
        *endif
    *endif
    !
    ln_skip=mod(aaa_,5)
    !
    *if,ln_skip,eq,0,then
        *if,aaa_,ne,1,then
            /output,pf_coord,mac,,append
!----------------------------------------------------------------
*msg,info
!
!----------------------------------------------------------------
            /output
        *endif
    *endif
    !
    cmsel,s,lnset_
    lslk,r,0
    !
    *if,aaa_,eq,1,then
        kp_1st_=skp_
        get_max_entity
        prfln_=lm
    *else
        lsel,u,line,,prfln_
        get_max_entity
        prfln_=lm
    *endif
    !
    *get,kp11_,line,prfln_,kp,1
    *get,kp12_,line,prfln_,kp,2
    !
    *if,skp_,eq,kp11_,then
        juncpt_=kp12_
    *else
        juncpt_=kp11_
    *endif
    !
    skp_=juncpt_
    !
    *set,juncpt_
    !
    *if,aaa_,eq,numlns_,then
        *if,skp_,ne,kp_1st_,then
            !
            dx__=kx(skp_)
            !
            *if,abs(dx__),lt,tol_,then
                dx__=0
            *else
                round_num,dx__,prec_
                dx__=num_
            *endif
            !
            dy__=ky(skp_)
            !
            *if,abs(dy__),lt,tol_,then
                dy__=0
            *else
                round_num,dy__,prec_
                dy__=num_
            *endif
            !
            dz__=kz(skp_)
            !
            *if,abs(dz__),lt,tol_,then
                dz__=0
            *else
                round_num,dz__,prec_
                dz__=num_
            *endif
            !
            *if,prm_,eq,0,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_,%dx__%,%dy__%,%dz__%
%i ---  k,,%g, %g, %g
!------------------------------------
                /output
            *elseif,prm_,eq,1,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info,skp_
Keypoint # %i
*msg,info,%dx__%
Dx0 =%g
*msg,info,%dy__%
Dy0 =%g
*msg,info,%dz__%
Dz0 =%g
*msg,info
!
!------------------------------------
                /output
            *endif
        *endif
    *endif
*enddo
!
init_entity_num
!
*if,prm_,eq,1,then
    /output,pf_coord,mac,,append
!------------------------------------
*msg,info
!
!------------------------------------
    /output
    !
    *do,aaa_,1,kpcnt_,1
        /output,pf_coord,mac,,append
!------------------------------------
*msg,info
k,,Dx0 ,Dy0 ,Dz0
!------------------------------------
        /output
        !
        ln_skip=mod(aaa_,5)
        !
        *if,ln_skip,eq,0,then
            *if,aaa_,ne,1,then
                /output,pf_coord,mac,,append
!------------------------------------
*msg,info
!
!------------------------------------
                /output
            *endif
        *endif
        !
    *enddo
*endif
!
cmsel,s,lnset_
!
csys,acs1_
!
lplot
!
!-------------------------------------------------------------------------
!
!
*set,csnum_,
*set,acs1_,
*set,skp_,
*set,prfln_,
*set,juncpt_,
*set,aaa_,
*set,kp11_,
*set,kp12_,
*set,kp_1st_,
*set,dx__,
*set,dy__,
*set,dz__,
*set,num_,
*set,tol_,
*set,prec_,
*set,numlns_,
*set,prm_,
*set,ln_skip,
*set,kpcnt_,
cmdele,lnset_


w:\ansys\mac\tools\tv_profile_lines.mac.html

!   TITLE:  tv_profile_lines.mac (CALCULATION)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    07/29/2001      J. Rinaldi
!---------------------------------------------------------------------------
!
!   OBJECTIVE:
!
!   This macro creates a continuous line profile from a set of selected lines.
!
!
!   ARGUMENTS:
!
!       (1) strt_pt = the first or starting keypoint in the line profile.
!
!       (2) fin_pt = the last or finish keypoint in the line profile.
!
!
!   DESCRIPTION:
!
!   A set of independent, overlapping lines with no intersection points is
!   transformed into a connected chain profile.  The lines should not form
!   ANY closed path, and must overlap other lines at only 1 point for each
!   overlapping line.
!
!   The desired profile is determined from a start keypoint in the chain, and
!   terminate at a finish keypoint.  After execution, the resulting path is
!   a set of lines that share common keypoints, and form a continuous path
!   from the specified start and finish keypoints.  The extraneous line seg-
!   ments resulting from the line overlap operation (LOVLAP) are 'cleaned'
!   from the new path.
!
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

multipro,'start',2
    *cset,1,3,skp_,'Enter Start Keypoint #',1
    *cset,4,6,fkp_,'Enter Finish Keypoint #',2
    *cset,61,62,'Creates a continuous line',' profile from a selected set'
    *cset,63,64,'of unconnected lines. Enter',' the end keypoint numbers.'
multipro,'end'
!
!------------------------ Combine / Overlap Lines ------------------------
!
*get,origtyp_,comp,origlns_,type
!
*if,origtyp_,eq,7,then
    cmsel,u,origlns_
*endif
!
*get,numlns_,line,,count
!
lovlap,all
init_entity_num
!
isolate_lines
!
*if,origtyp_,eq,7,then
    cmsel,u,origlns_
*endif
!
lplot
!
!-------------------------- Create Line Profile --------------------------
!
*do,aaa_,1,numlns_,1
    ksel,s,kp,,skp_
    !
    lslk,s,0
    !
    *if,aaa_,eq,1,then
        get_max_entity
        prfln_=lm
    *else
        lsel,u,line,,prfln_
        get_max_entity
        prfln_=lm
    *endif
    !
    *get,kp11_,line,prfln_,kp,1
    *get,kp12_,line,prfln_,kp,2
    !
    *if,skp_,eq,kp11_,then
        juncpt_=kp12_
    *else
        juncpt_=kp11_
    *endif
    !
    *if,juncpt_,eq,fkp_,then
        *exit
    *else
        ksel,s,kp,,juncpt_
        !
        lslk,s,0
        lsel,u,line,,prfln_
        !
        *get,ptyp__,parm,lnset_,type
        !
        *if,ptyp__,ne,-1,then
            *set,lnset_(1),
        *endif
        !
        entity_array,'l','lnset_','array'
        nchkln_=ecount
        !
        *if,nchkln_,gt,0,then
            !
            *set,drlns_,
            !
            *do,bbb_,1,nchkln_,1
                *if,drlns_,eq,0,then
                    lsel,s,line,,lnset_(bbb_,1)
                    !
                    *get,kpls1_,line,lnset_(bbb_,1),kp,1
                    *get,kpls2_,line,lnset_(bbb_,1),kp,2
                    !
                    *if,kpls1_,eq,juncpt_,then
                        juncpt2_=kpls2_
                    *else
                        juncpt2_=kpls1_
                    *endif
                    !
                    ksel,s,kp,,juncpt2_
                    !
                    lslk,s,0
                    lsel,u,line,,lnset_(bbb_,1)
                    !
                    *get,numcl_,line,,count
                    !
                    *if,juncpt2_,ne,fkp_,then
                        *if,numcl_,eq,0,then
                            lsel,s,line,,lnset_(bbb_,1)
                            ldele,all,,,1
                        *else
                            drlns_=1
                        *endif
                    *else
                        drlns_=1
                    *endif
                *else
                    lsel,s,line,,lnset_(bbb_,1)
                    ldele,all,,,1
                *endif
            *enddo
        *else
            *exit
        *endif
    *endif
    !
    skp_=juncpt_
    !
    *set,juncpt_
    *set,juncpt2_
    !
    init_entity_num
    !
    lplot
*enddo
!
init_entity_num
!
lplot
!
!-------------------------------------------------------------------------
!
!
*set,skp_,
*set,fkp_,
*set,lnset_(1),
*set,prfln_,
*set,drlns_,
*set,numcl_,
*set,juncpt_,
*set,juncpt2_,
*set,bbb_,
*set,aaa_,
*set,kp11_,
*set,kp12_,
*set,kpls1_,
*set,kpls2_,
*set,origtyp_,
cmdele,origlns_
cmdele,conln_


w:\ansys\mac\tools\tv_rec_bore.mac.html

!   TITLE:  tv_rec_bore.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   03/31/2000  J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A   04/15/2000  J. Rinaldi
!
!       Expanded macro to include CSKP and pre-existing c.s.;
!       and for explicit input for each KP coordinate.
!---------------------------------------------------------------------------
!
!
!   This sub-macro creates a hexahedral shaped volume which is to be sub-
!   tracted out, thereby creating a rectangular shaped cavity either within
!   or on the surface of the selected volume. This volume may have right
!   angled corners (phibev = 0), or angled (0 < phibev < 90) corners.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume
!
!       opt = input options: 1,2,3,4,5,6,7,8,9,10,11 or 12
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       dcut = the depth or thickness of the volume
!       phibev = angle of bevel as measured from the normal
!                to the rectangular surfaces (from volume cut
!                coordinate system z axis)
!       xwcut = width of cut/volume (along local c.s. x axis)
!       yhcut = height of cut/volume (along local c.s. y axis)
!       x23 = x coordinate value for KP's in quadrants 2 and 3
!       x14 = x coordinate value for KP's in quadrants 1 and 4
!       y12 = y coordinate value for KP's in quadrants 1 and 2
!       y34 = y coordinate value for KP's in quadrants 3 and 4
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for options 1,2,7 and 8 (See below). From
!   this c.s., the local coordinate system building this volume is placed.
!   Options 3,4,9 and 10 allow construction of the cut volume from a c.s.
!   defined by 3 KP's. Lastly, options 5,6,11 and 12 allow construction from
!   a pre-existing c.s.  Options 7 thru 12 correspond to the same input as
!   1 thru 6, except that these options are used when the dimensions of the
!   base rectangle are specified.
!
!
!   The 12 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       2.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       3.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       4.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       5.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       6.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       7.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       8.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       9.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       10. Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       11. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       12. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!
!----------------------- COMMAND SYNTAX / OPTION 1 & 7 -----------------------
!
! REC_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc,x23,x14,y12,y34,dcut,phibev
!
!-------------------------------- OPTION 2 & 8 -------------------------------
!
! REC_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc,xwcut,yhcut,dcut,phibev
!
!-------------------------------- OPTION 3 & 9 -------------------------------
!
! REC_BORE,opt,p1,p2,p3,x23,x14,y12,y34,dcut,phibev
!
!-------------------------------- OPTION 4 & 10 ------------------------------
!
! REC_BORE,opt,p1,p2,p3,xwcut,yhcut,dcut,phibev
!
!-------------------------------- OPTION 5 & 11 ------------------------------
!
! REC_BORE,opt,acs1,x23,x14,y12,y34,dcut,phibev
!
!-------------------------------- OPTION 6 & 12 -------------------------------
!
! REC_BORE,opt,acs1,xwcut,yhcut,dcut,phibev
!
!-----------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*ask,opt,OPTION,1
!
*if,opt,eq,1,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,2,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,3,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,4,then
    *ask,p1,origin KP of C.S.,
    *ask,p2,+X axis KP of C.S.,
    *ask,p3,+Y axis KP of C.S.,
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,5,then
    *ask,acs1,Active C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,6,then
    *ask,acs1,Active C.S.,0
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,7,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,8,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,9,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,10,then
    *ask,p1,origin KP of C.S.,
    *ask,p2,+X axis KP of C.S.,
    *ask,p3,+Y axis KP of C.S.,
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,11,then
    *ask,acs1,Active C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,12,then
    *ask,acs1,Active C.S.,0
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
get_max_entity
!
v2bcut=vm   ! selected volume to be (2b) cut
!
*if,opt,eq,1,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,3,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,4,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,5,then
    csys,acs1
*endif
!
*if,opt,eq,6,then
    csys,acs1
*endif
!
*if,opt,eq,7,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,8,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,9,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,10,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,11,then
    csys,acs1
*endif
!
*if,opt,eq,12,then
    csys,acs1
*endif
!
*if,opt,eq,2,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,4,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,6,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,1,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,3,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,5,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,8,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,10,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,12,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,7,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,9,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,11,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
x=dcut*tan(phibev*rconv)
!
*if,opt,eq,2,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,4,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,6,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,1,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,3,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,5,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,8,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,10,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,12,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,7,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,9,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,11,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,x23,
*set,x14,
*set,y12,
*set,y34,
*set,phibev,
*set,dcut
*set,xwcut
*set,yhcut
*set,x,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_reverse_video.mac.html

!  TITLE:   tv_reverse_video.mac (MANAGEMENT)
!
!-----------------------------------------------------------------------------
!       Rev -    RELEASED   03/22/2001      J. Rinaldi
!------------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro toggles the video background between black and white.
!
!------------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

/color,pbak,off,blac
!
*get,vustat_,parm,vuscntr_,type
!
*if,vustat_,eq,-1,then
    vuscntr_=1
    vidtog_=0
    *set,vustat_,
*endif
!
*if,vidtog_,eq,0,then
    vidtog_=1
   /RGB,INDEX,100,100,100, 0
   /RGB,INDEX, 80, 80, 80,13
   /RGB,INDEX, 60, 60, 60,14
   /RGB,INDEX,  0,  0,  0,15
*else
    vidtog_=0
   /RGB,INDEX,  0,  0,  0, 0
   /RGB,INDEX, 60, 60, 60,13
   /RGB,INDEX, 80, 80, 80,14
   /RGB,INDEX,100,100,100,15
 *endif
!
/replot
!
*set,vustat_,
!
toolbar


w:\ansys\mac\tools\tv_revolve_aset.mac.html

!   TITLE:  tv_revolve_aset.mac (SM_TOOL)
!
!---------------------------------------------------------------------------
!       Rev -   RELEASED    06/14/2000  J. Rinaldi
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   This sub-macro revolves a selected set of areas around an axis
!   defined by 2 keypoints, AXP1 and AXP2. The total angle of revolve
!   is defined by REVANG; and the number of volume segments in the
!   revolve are specified by NUMSEG. Input necessary are:
!
!       A selected set of areas (each to be extruded)
!
!       axp1 = 1st axis point of revolution
!
!       axp2 = 2nd axis point of revolution
!
!       revang = angle of revolve
!
!       numseg = number of volume segments
!
!
!--------------------------------- COMMAND SYNTAX --------------------------
!
! REVOLVE_ASET, axp1, axp2, revang, numseg
!
!---------------------------------------------------------------------------
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,axp1,Axis Point 1,
*ask,axp2,Axis Point 2,
*ask,revang,Revolve Angle,360
*ask,numseg,# Volume segments,4
!
*get,alow,area,,num,min
*get,ahigh,area,,num,max
!
*do,iiii_,alow,ahigh,1
    *if,asel(iiii_),ne,0,then
        vrotat,iiii_,,,,,,axp1,axp2,revang,numseg
    *endif
*enddo
!
init_entity_num
!
lplot
!
*set,axp1,
*set,axp2,
*set,iiii_,
*set,revang,
*set,numseg,
*set,alow,
*set,ahigh,
!
abbres,new,tools,mac


w:\ansys\mac\tools\tv_select_part.mac.html

!   TITLE:  tv_select_part.mac (MANAGEMENT)
!
!---------------------------------------------------------------------------
!       Rev -     04/12/2000    J. Rinaldi
!---------------------------------------------------------------------------
!       Rev A     02/13/2001    J. Judd
!
!       Added error check and warning for input parameter = scalar.
!       Changed internal variables to end in underscore (e.g. _).
!---------------------------------------------------------------------------
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This sub-macro selects all solid and FE model entities associated
!   with the named part volume.  The only input necessary is the model
!   name for the part.
!
!   COMMAND SYNTAX:
!
!       SELECT_PART, pnam
!
!---------------------------------------------------------------------------
!
*get,prkey_,active,0,prkey
/nopr

*ask,pname_,Part Name,
!
*get,ptyp_,parm,pname_,type
!
*if,ptyp_,eq,3,then
    allsel,all
    !
    *get,vcount_,volu,,count
    !
    *if,vcount_,gt,0,then
        vsel,s,volu,,pname_
        !
        aslv,selv
        lsla,selv
        ksll,selv
        eslv,selv
        nsle,selv,all
        !
    *else
        asel,s,area,,pname_
        !
        lsla,selv
        ksll,selv
        eslv,selv
        nsle,selv,all
        !
    *endif
*endif
!
lplot
!
*set,pname_,
*set,ptyp_,