Friday 28 November 2014

Identify drawing view type

I was looking into identifying the drawing view types so I can add it to the view label and decided to share the code with you guys. I am taking about checking if it's a main, projection, section,detail, etc. type of view.
Lots of places to use this code and one that comes to mind is adding a description to all secondary views (details, sections, projections) of what the main view is called, labelled and on what sheet it is.

Hope it’s self-explanatory (let me know if you need more help with it).
'------------------START CODE--------------- 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

Dim i As Long
i = 1
For Each oSheet In oDrawDoc.Sheets
'For Each oSheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView In oViews
        MessageBox.Show("View No.: " & i & _
        vbLf & "View Name: " & oView.Name, "View ID")

        Select Case oView.ViewType
            Case 10506 ' could use kAssociativeDraftDrawingViewType
                MessageBox.Show("View is associative draft one", "View Type")
            Case 10499 ' could use kAuxiliaryDrawingViewType
                MessageBox.Show("View is associative draft one", "View Type")
            Case 10498 ' could use kCustomDrawingViewType
                MessageBox.Show("View is auxilliary one", "View Type")
            Case 10497 ' could use kDefaultDrawingViewType
                MessageBox.Show("View with customized camera settings", "View Type")
            Case 10502 ' could use kDetailDrawingViewType
                MessageBox.Show("View is a detail of a portion of the document", "View Type")
            Case 10505 ' could use kDraftDrawingViewType
                MessageBox.Show("View is a draft one", "View Type")
            Case 10500 ' could use kOLEAttachmentDrawingViewType
                MessageBox.Show("View is an OLE attachment", "View Type")
            Case 10507 ' could use kOverlayDrawingViewType
                MessageBox.Show("View is an overlay one", "View Type")
            Case 10504 ' could use kProjectedDrawingViewType
                MessageBox.Show("View is a projected one", "View Type")
            Case 10503 ' could use kSectionDrawingViewType
                MessageBox.Show("View is a section", "View Type")
            Case 10501 'could use kStandardDrawingViewType
                MessageBox.Show("View with the camera set to one of the " _
                & vbLf & "standard orthogonal views (Top, Iso, etc.)", "View Type")
            i = i + 1
              End Select
'------------------END CODE--------------- 
Try it out, it will show the view name and type.

No comments:

Post a Comment