每个工程图视图都会来自某个模型文件,或是转配或是零件。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
本文介绍如何使用API获取工程图中视图所引用的模型文档类型,通过VBA示例代码展示了判断当前视图为装配文档或零件文档的方法。
987

被折叠的 条评论
为什么被折叠?



