每个工程图视图都会来自某个模型文件,或是转配或是零件。API提供的DrawingView.ReferencedDocumentDescriptor 能返回对应的文档。例如:
Private Sub DrawingRefs()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet
Dim oView As DrawingView
Set oView = oSheet.DrawingViews.Item(1)
Dim oRef As DocumentDescriptor
Set oRef = oView.ReferencedDocumentDescriptor
Select Case oRef.ReferencedDocumentType
Case DocumentTypeEnum.kAssemblyDocumentObject
MsgBox "Assembly Document"
Case DocumentTypeEnum.kPartDocumentObject
MsgBox "Part Document"
Case Else
MsgBox "Document - ???"
End Select
End Sub