!   TITLE:  v_sel_entity.mac (CALCULATION)^M
!^M
!^M
!   OBJECTIVE:^M
!^M
!   This macro stores or selects a set of selected volumes by their lower^M
!   solid model entities.^M
!^M
!^M
!   COMMAND SYNTAX:^M
!^M
!                             (1)         (2)^M
!           V_SEL_ENTITY, store/select, sel_typ^M
!^M
!^M
!   ARGUMENTS:^M
!^M
!       (1) store/select = store or retrieval action:^M
!^M
!               0 (or blank) = store selected volumes^M
!^M
!               1 = retrieve (select) the previous stored volumes^M
!^M
!       (2) sel_typ = selection type: [ Must be in single quotes ]^M
!^M
!              [NOTE: This argument is valid only when store/select^M
!                     (argument 1) is in select mode (store/select = 1)]^M
!^M
!                   's' = select a new set (default value if left blank)^M
!^M
!                   'r' = reselect from a currently selected set^M
!^M
!                   'a' = also (additionally) select^M
!^M
!                   'u' = unselect^M
!^M
!^M
!   DESCRIPTION:^M
!^M
!   A predetermined set of volumes, stored in array 'VCG_DATA' by command macro^M
!   'vol_cg.mac', may be subject to a set of boolean operations which alter the^M
!   volume numbers, and the areas comprising those volumes, while the volumes^M
!   themselves are otherwise unaltered (i.e., they contain the same space and^M
!   volume).^M
!^M
!   The selection of each volume in the array allows for one to select (or^M
!   unselect) the volumes based on their centroid locations and/or volumes,^M
!   instead of their volume numbers.^M
!^M
!   If a boolean operation, such as VGLUE (see ANSYS help), changes the volume^M
!   numbers, then those volumes may be selected by centroid locations and/or^M
!   volume, after the boolean operation is performed.^M
!^M
!   The volume(s) stored in the array named 'VCG_DATA' are selected by use of^M
!   their centroid positions and volume in the array.^M
!           ______________________________________________________^M
!^M
!   *** NOTE: Array 'VCG_DATA' contains the following data for each volume:^M
!^M
!       1.) volume number^M
!       2.) volume^M
!       3.) X-coordinate of volume centroid (relative to csys = 0)^M
!       4.) Y-coordinate of volume centroid (relative to csys = 0)^M
!       5.) Z-coordinate of volume centroid (relative to csys = 0)^M
!^M
!   Each piece of data is stored in each column, where each row corresponds to^M
!   a volume. 'VCG_DATA' has the following format:^M
!^M
!                                   COLUMNS^M
!             ROW   |   1    |  2   |   3   |   4   |   5   |^M
!          --------------------------------------------------^M
!              1    | vol_#1 |  V1  |  Xc1  |  Yc1  |  Zc1  |^M
!              2    | vol_#2 |  V2  |  Xc2  |  Yc2  |  Zc2  |^M
!              3    | vol_#3 |  V3  |  Xc3  |  Yc3  |  Xc3  |^M
!              .    |   .    |  .   |   .   |   .   |   .   |^M
!              .    |   .    |  .   |   .   |   .   |   .   |^M
!              N    | vol_#N |  VN  |  XcN  |  YcN  |  ZcN  |^M
!^M
!^M
!^M
*get,prkey_,active,0,prkey^M
/nopr^M
!^M
savretr_=arg1^M
!^M
*if,savretr_,eq,1,then^M
    selctyp_=arg2^M
    !^M
    ! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,^M
    !                 4=character array, -1=undefined^M
    !^M
    *get,arexist_,parm,entstor_,type^M
    *get,argtyp_,parm,selctyp_,type^M
    !^M
    *if,argtyp_,eq,0,then^M
        selctyp_='s'^M
    *endif^M
    !^M
    *set,argtyp_,^M
*elseif,savretr_,eq,0,then^M
    *set,entstor_(1),^M
*endif^M
!^M
*if,savretr_,eq,0,then^M
    aslv,s^M
    lsla,s^M
    ksll,s^M
    cm,vset1__,volu^M
    cm,aset1__,area^M
    cm,lset1__,line^M
    cm,kset1__,kp^M
    !^M
    vol_cg^M
    a_cg^M
    !^M
    entity_array,'v','vgrp_','array'
    vcnt__=ecount
    !^M
    entity_array,'a','agrp_','array'
    acnt__=ecount
    !^M
    entity_array,'l','lgrp_','array'
    lcnt__=ecount
    !^M
    entity_array,'k','kgrp_','array'
    kcnt__=ecount
    !^M
    *dim,dimarry_,array,4^M
    !^M
    dimarry_(1,1)=vcnt__^M
    dimarry_(2,1)=acnt__^M
    dimarry_(3,1)=lcnt__^M
    dimarry_(4,1)=kcnt__^M
    !^M
    arry_max_val,'dimarry_'^M
    !^M
    *dim,entstor_,array,max_val+1,4,1^M
    !^M
    arry_transfer,'vgrp_','entstor_',,,,,,,,1^M
    arry_transfer,'agrp_','entstor_',,,,,,,,2^M
    arry_transfer,'lgrp_','entstor_',,,,,,,,3^M
    arry_transfer,'kgrp_','entstor_',,,,,,,,4^M
    !^M
    entstor_(max_val+1,1)=vcnt__^M
    entstor_(max_val+1,2)=acnt__^M
    entstor_(max_val+1,3)=lcnt__^M
    entstor_(max_val+1,4)=kcnt__^M
    !^M
    *set,vgrp_(1),^M
    *set,agrp_(1),^M
    *set,lgrp_(1),^M
    *set,kgrp_(1),^M
    *set,dimarry_(1),^M
    *set,max_val,^M
    *set,max_ir,^M
    *set,max_ic,^M
    *set,max_ip,^M
*elseif,savretr_,eq,1,then^M
    *if,arexist_,eq,1,then^M
        *get,nrows_,parm,entstor_,dim,x^M
        !^M
        vdcnt_=0^M
        adcnt_=0^M
        ldcnt_=0^M
        kdcnt_=0^M
        !^M
        *do,def_,1,4,1^M
            *do,abc_,1,nrows_,1^M
                !^M
                ! Select status of volume N (vsel(N)):^M
                !   -1=unselected, 0=undefined, 1=selected^M
                !^M
                *if,def_,eq,1,then^M
                    exist_=vsel(entstor_(abc_,1))^M
                    !^M
                    *if,exist_,ne,0,then^M
                        vsel,s,volu,,entstor_(abc_,1)^M
                        *get,volvol_,volu,entstor_(abc_,1),volu^M
                        !^M
                        *if,volvol_,eq,vcg_data(abc_,2),then^M
                            vdele,entstor_(abc_,1),,,1^M
                            init_entity_num,1^M
                            vdcnt_=vdcnt_+1^M
                        *endif^M
                    *endif^M
                    !^M
                    *if,vdcnt_,eq,entstor_(nrows_,1),then^M
                        *exit^M
                    *endif^M
                *endif^M
                !^M
                *if,def_,eq,2,then^M
                    exist_=asel(entstor_(abc_,2))^M
                    !^M
                    *if,exist_,ne,0,then^M
                        *do,ijk_,1,entstor_(nrows_,1),1^M
                            vsel,s,volu,,acg_data(abc_,3)^M
                            vsel,a,volu,,acg_data(abc_,5)^M
                            !^M
                            *if^M
                        ^M
                        ^M
                        *enddo^M
                        ^M
                        ^M
                        ^M
                        ^M
                        ^M
                        !asel,s,area,,entstor_(abc_,2)^M
                        ^M
                        ^M
                        ^M
                        ^M
                        *get,volvol_,volu,entstor_(abc_,1),volu^M
                        !^M
                        *if,volvol_,eq,vcg_data(abc_,2),then^M
                            vdele,entstor_(abc_,1),,,1^M
                            init_entity_num,1^M
                            vdcnt_=vdcnt_+1^M
                        *endif^M
                    *endif^M
                    !^M
                    *if,vdcnt_,eq,entstor_(nrows_,1),then^M
                        *exit^M
                    *endif^M
                *endif^M
                !^M
            ^M
            ^M
            ^M
            ^M
            ^M
            *enddo^M
            !^M
            *if,def_,eq,1,then^M
                *if,vdcnt_,eq,entstor_(nrows_,1),then^M
                    *exit^M
                *endif^M
            *elseif,def_,eq,2,then^M
                *if,adcnt_,eq,entstor_(nrows_,2),then^M
                    *exit^M
                *endif^M
            *elseif,def_,eq,3,then^M
                *if,ldcnt_,eq,entstor_(nrows_,3),then^M
                    *exit^M
                *endif^M
            *elseif,def_,eq,4,then^M
                *if,kdcnt_,eq,entstor_(nrows_,4),then^M
                    *exit^M
                *endif^M
            *endif^M
        *enddo^M
    *endif^M
*endif^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
! Parameter type: 0=scalar, 1=array, 2=table, 3=character scalar,^M
!                 4=character array, -1=undefined^M
!^M
*get,argtyp_,parm,selctyp_,type^M
*get,nvols_,parm,vcg_data,dim,x^M
!^M
*if,argtyp_,eq,0,then^M
    selctyp_='s'^M
*endif^M
!^M
*get,actvs_,active,,csys^M
!^M
^M
^M
^M
^M
^M
^M
^M
^M
!^M
csys,actvs_^M
!^M
*set,volnum__,^M
*set,vcnt___,^M
*set,selctyp_,^M
*set,argtyp_,^M
*set,ab_,^M
*set,bc_,^M
*set,actvs_,^M
^M
^M
^M
^M
^M
^M
^M
^M
^M
!^M
*if,prkey_,eq,1,then^M
    /go^M
*endif^M
^M
*go,:skip1^M
^M
^M
 PARAMETER STATUS- VCG_DATA  ( 427 PARAMETERS DEFINED)^M
                  (INCLUDING    37 INTERNAL PARAMETERS)^M
^M
      LOCATION                VALUE            VALUE      ^M
        1       1       1    147.000000       396.000000  ^M
        2       1       1    148.000000       397.000000  ^M
        3       1       1    149.000000       398.000000  ^M
        4       1       1    150.000000       399.000000  ^M
        1       2       1    5.66755144       5.66755251  ^M
        2       2       1    5.66755144       5.66755251  ^M
        3       2       1    5.66755144       5.66755251  ^M
        4       2       1    5.66755144       5.66755251  ^M
        1       3       1    15.8253608       15.8253608  ^M
        2       3       1    15.8253608       15.8253608  ^M
        3       3       1    15.8253608       15.8253608  ^M
        4       3       1    15.8253608       15.8253608  ^M
        1       4       1   0.907296461      0.907296535  ^M
        2       4       1   0.907296438      0.907296512  ^M
        3       4       1  -0.907296461     -0.907296535  ^M
        4       4       1  -0.907296438     -0.907296512  ^M
        1       5       1  -0.907296438     -0.907296492  ^M
        2       5       1   0.907296461      0.907296514  ^M
        3       5       1   0.907296438      0.907296492  ^M
        4       5       1  -0.907296461     -0.907296514  ^M
^M
^M
PARAMETER STATUS- VCG_DATA  ( 428 PARAMETERS DEFINED)^M
                  (INCLUDING    38 INTERNAL PARAMETERS)^M
^M
      LOCATION                VALUE^M
        1       1       1    396.000000    ^M
        2       1       1    397.000000    ^M
        3       1       1    398.000000    ^M
        4       1       1    399.000000    ^M
        1       2       1    5.66755251    ^M
        2       2       1    5.66755251    ^M
        3       2       1    5.66755251    ^M
        4       2       1    5.66755251    ^M
        1       3       1    15.8253608    ^M
        2       3       1    15.8253608    ^M
        3       3       1    15.8253608    ^M
        4       3       1    15.8253608    ^M
        1       4       1   0.907296535    ^M
        2       4       1   0.907296512    ^M
        3       4       1  -0.907296535    ^M
        4       4       1  -0.907296512    ^M
        1       5       1  -0.907296492    ^M
        2       5       1   0.907296514    ^M
        3       5       1   0.907296492    ^M
        4       5       1  -0.907296514   ^M
        ^M
        ^M
:skip1^M