Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify Main view from Detail or Section through VBA 1

Status
Not open for further replies.

sri91

Mechanical
Aug 29, 2019
42
IN
Hi All,
Can I identify the Main view from which section or Auxiliary or Detail view are taken through VBA. Please help me to solve this.

Thanks
SURYASRI
 
Replies continue below

Recommended for you

Kantoku,

How should I check the "ReferenceView Property"?
Where is ReferenceView Property?
I haven't ever done that.....
Thanks!

CAD 2015
 
I may have misunderstood the meaning of the question.


I made a sample code and tested it.

Code:
'catvba
'DrawingView.ReferenceView sample
Option Explicit

Sub CATMain()

    Dim doc As DrawingDocument
    Set doc = CATIA.ActiveDocument
    
    Dim vis As DrawingViews
    Set vis = doc.Sheets.ActiveSheet.views
    
    Dim vis_info() As Variant
    ReDim vis_info(vis.Count)
    vis_info(0) = Join(Array("-- name -- ", "-- type -- ", "-- refrence --"), " : ")
    
    Dim vi_info(2) As String
    
    Dim i As Long
    For i = 1 To vis.Count
        vi_info(0) = vis.Item(i).Name
        vi_info(1) = GetViewtype(vis.Item(i))
        vi_info(2) = GetRefViewName(vis.Item(i))
        
        vis_info(i) = Join(vi_info, " : ")
    Next
    
    MsgBox Join(vis_info, vbCrLf)
End Sub

Private Function GetRefViewName( _
    ByVal vi As DrawingView) _
    As String
    On Error GoTo ref_nothing

    GetRefViewName = "from_" & vi.ReferenceView.Name
    Exit Function
    
ref_nothing:
    GetRefViewName = "nothing"

End Function

Private Function GetViewtype( _
    ByVal vi As DrawingView) _
    As String
    
    Dim res As String
    Select Case vi.ViewType()
        Case CatDrawingViewType.catViewBackground
            res = "Background"
        Case CatDrawingViewType.catViewFront
            res = "Front"
        Case CatDrawingViewType.catViewLeft
            res = "Left"
        Case CatDrawingViewType.catViewRight
            res = "Right"
        Case CatDrawingViewType.catViewTop
            res = "Top"
        Case CatDrawingViewType.catViewBottom
            res = "Bottom"
        Case CatDrawingViewType.catViewRear
            res = "Rear"
        Case CatDrawingViewType.catViewAuxiliary
            res = "Auxiliary"
        Case CatDrawingViewType.catViewIsom
            res = "Isom"
        Case CatDrawingViewType.catViewSection
            res = "Section"
        Case CatDrawingViewType.catViewSectionCut
            res = "SectionCut"
        Case CatDrawingViewType.catViewDetail
            res = "Detail"
        Case CatDrawingViewType.catViewUntyped
            res = "Untyped"
        Case CatDrawingViewType.catViewMain
            res = "Main"
        Case CatDrawingViewType.catViewPure_Sketch
            res = "Pure_Sketch"
        Case CatDrawingViewType.catViewUnfolded
            res = "Unfolded"
        Case Else
            res = "unknown"
    End Select
    
    GetViewtype = res
End Function

ReferenceView_wutmjn.png


When CatDrawingViewType.catViewDetail,Acquisition of ReferenceView fails.

In addition, there were times when CatDrawingViewType.catViewSection / catViewSection failed.
 
I made a mistake.

DrawingView.GenerativeBehavior.ParentView
I should have confirmed.

Code:
Private Function GetRefViewName( _
    ByVal vi As DrawingView) _
    As String
    
    On Error GoTo ref_nothing

    GetRefViewName = "from_" & vi.ReferenceView.Name
    Exit Function
    
ref_nothing:

    Dim pv As DrawingView
    Set pv = vi.GenerativeBehavior.ParentView 'Section & Detail
    
    If pv Is Nothing Then GoTo parent_nothing
    
    GetRefViewName = "from_" & pv.Name
    Exit Function
    
parent_nothing:

    GetRefViewName = "nothing"
    
End Function
 
I do not get it yet.....
How did you get the window marked in red (see the picture below).
Have you used the MB3?
Did you click on the view in the tree?
Can you place a step-by-step direction, please?
I want to learn this.....

image_tkhl3x.png


CAD 2015
 
Thanks,
Is there another way to access ReferenceView Property, other than using a macro?

CAD 2015
 
I think there is no way to check multiple ReferenceView & ParentView other than macros.

If it is one, you can check this in the context menu of any view.
context_menu_k0a9ba.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top