!   TITLE:  tv_flag_cs.mac (MISC_PART)
!
!
!   TOOLBAR VERSION
!
!   OBJECTIVE:
!
!   This sub-macro visually flags a specified coordinate system for easy user
!   identificatioon.
!
!
!   COMMAND SYNTAX:
!
!                       (1)       (2)
!        TV_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
!
/prep7
configuration,0
!
multipro,'start',2
    *cset,1,3,cs2id__,'C.S. # (-1 to remove triad)'
    *cset,4,6,scalf__,'Scaling factor of triad size'
    *cset,61,62,'Locates a C.S. and overlays',' an X, Y and Z axis triad'
multipro,'end'
!
*if,_button,eq,0,then
    *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
        !
        aplot
        !
        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
*endif
!
*set,cs2id__,
*set,scalf__,
*set,_button,
!
*if,prkey_,eq,1,then
    /go
*endif