!   TITLE:  flag_cs.mac (MISC_PART)
!
!
!   OBJECTIVE:
!
!   This sub-macro flags a specified coordinate system for easy user
!   identificatioon.
!
!
!   COMMAND SYNTAX:
!
!                    (1)       (2)
!        FLAG_CS, cs_number, scal_f
!
!
!   ARGUMENTS:
!
!       (1) cs_number = coordinate system number to be identified. To remove
!                       the triad, execute this macro with this argument
!                       equal to -1.
!
!       (2) scal_f = scaling factor controlling the triad size, where
!                    SCAL_F is an integer number N:
!
!               a.) N = 0: defaults to N = 1, axis lengths are equal to
!                          the maximum line length in the model database.
!
!               b.) N > 0: axis lengths are N x the maximum line length
!                          in the model database.
!
!               c.) N < 0: axis lengths are equal to the numerical (absolute)
!                          value of N.
!
!
!   DESCRIPTION:
!
!   A user may want to identify the spatial position of a known coordinate
!   system (CS), but the CS cannot be seen easily due to other overlapping
!   CS's and solid model entities, and a spatial filed that is inundated with
!   numerous CS's.
!
!   This macro allows for a user to identify the position and axis orientation
!   of a known CS by placing a large triad at the origin of the CS. Upon user
!   confirmation of identifying the CS, the triad is then removed.
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
cs2id__=arg1
scalf_=arg2
!
*if,scalf_,eq,0,then
    scalf_=1
*elseif,scalf_,lt,0,then
    max_leng=2*abs(scalf_)
*endif
!
*if,cs2id__,ne,-1,then
    init_entity_num,1
    !
    *if,scalf_,ge,0,then
        max_enty_dim,'l'
    *elseif,scalf_,lt,0,then
        scalf_=1
    *endif
    !
    *if,max_leng,eq,0,then
        l__=scalf_*1
    *else
        l__=scalf_*(1/2)*max_leng
    *endif
    !
    csys,cs2id__
    clocal,csn+1000,0,0,0,0,0,0,0
    !
    k,,0,0,0                            ! X axis
    k,,0,(1/48)*l__,0
    k,,(5.2/6)*l__,(1/48)*l__,0
    k,,(5/6)*l__,(1/24)*l__,0
    k,,l__,0,0
    !
    create_area
    !
    asel,r,area,,am
    revolve_aset,km,km-4,360,2
    !
    !
    k,,0,0,0                            ! Y axis
    k,,(1/48)*l__,0,0
    k,,(1/48)*l__,(5.2/6)*l__,0
    k,,(1/24)*l__,(5/6)*l__,0
    k,,0,l__,0
    !
    create_area
    !
    asel,r,area,,am
    revolve_aset,km,km-4,360,2
    !
    !
    k,,0,0,0                            ! Z axis
    k,,0,(1/48)*l__,0
    k,,0,(1/48)*l__,(5.2/6)*l__
    k,,0,(1/24)*l__,(5/6)*l__
    k,,0,0,l__
    !
    create_area
    !
    asel,r,area,,am
    revolve_aset,km,km-4,360,2
    !
    side_=2*(3/48)*l__                                          ! Letter X
    !
    k,,(1.1)*l__,-side_/2,-(1/48)*l__
    k,,((1.1)*l__)+side_/3,-side_/2,-(1/48)*l__
    k,,((1.1)*l__)+side_,side_/2,-(1/48)*l__
    k,,((1.1)*l__)+(2/3)*side_,side_/2,-(1/48)*l__
    !
    create_area
    !
    k,,(1.1)*l__,side_/2,-(1/48)*l__
    k,,((1.1)*l__)+(2/3)*side_,-side_/2,-(1/48)*l__
    k,,((1.1)*l__)+side_,-side_/2,-(1/48)*l__
    k,,((1.1)*l__)+side_/3,side_/2,-(1/48)*l__
    !
    create_area
    !
    aadd,am-1,am
    init_entity_num,1
    !
    asel,r,area,,am
    extrude_aset,(2/48)*l__
    !
    !
    k,,-side_/2,((1.1)*l__)+side_,-(1/48)*l__                  ! Letter Y
    k,,-side_/6,((1.1)*l__)+side_/2,-(1/48)*l__
    k,,-side_/6,(1.1)*l__,-(1/48)*l__
    k,,side_/6,(1.1)*l__,-(1/48)*l__
    !
    k,,side_/6,((1.1)*l__)+side_/2,-(1/48)*l__
    k,,side_/2,((1.1)*l__)+side_,-(1/48)*l__
    k,,side_/6,((1.1)*l__)+side_,-(1/48)*l__
    k,,0,((1.1)*l__)+((1/2)+(1/6))*side_,-(1/48)*l__
    !
    k,,-side_/6,((1.1)*l__)+side_,-(1/48)*l__
    !
    create_area
    !
    asel,r,area,,am
    extrude_aset,(2/48)*l__
    !
    !
    k,,-(1/48)*l__,side_/2,(1.1)*l__+side_                  ! Letter Z
    k,,-(1/48)*l__,side_/4,(1.1)*l__+side_
    k,,-(1/48)*l__,side_/4,(1.1)*l__+side_/3
    k,,-(1/48)*l__,-side_/4,(1.1)*l__+side_
    k,,-(1/48)*l__,-side_/2,(1.1)*l__+side_
    !
    k,,-(1/48)*l__,-side_/2,(1.1)*l__
    k,,-(1/48)*l__,-side_/4,(1.1)*l__
    k,,-(1/48)*l__,-side_/4,(1.1)*l__+(2/3)*side_
    k,,-(1/48)*l__,side_/4,(1.1)*l__
    k,,-(1/48)*l__,side_/2,(1.1)*l__
    !
    create_area
    !
    asel,r,area,,am
    extrude_aset,(2/48)*l__
    !
    vsel,s,volu,,vm-8,vm,1
    cm,cs_triad,volu
    !
    configuration,1
    cmsel,a,cs_triad
    aslv,a
    /auto,1
    aplot
    !
    *set,side_,
    *set,l__,
    *set,max_leng,
    *set,max_lnum,
*elseif,cs2id__,eq,-1,then
    cmsel,s,cs_triad
    vdele,all,,,1
    init_entity_num,1
    !
    configuration,1
    !
    /auto,1
    aplot
    !
    cmdele,cs_triad
*endif
!
*set,cs2id__,
*set,scalf_,
!
*if,prkey_,eq,1,then
    /go
*endif