!   TITLE:  draw_view.mac (MANAGEMENT)
!
!
!   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
!
!
!
!
*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
!
!
!
!
*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
!
!
!
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
!
!
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
    *endif
*endif


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