Why
In Sheet Format1
GetFirstView → GetFirstDisplayDimension→ ubound(GetAnnotations)=0
Why
in Sheet1 view
GetFirstView → GetFirstDisplayDimension → ubound(GetAnnotations)>0
In Sheet Format1, GetFirstView → GetFirstDisplayDimension5 → ubound(GetAnnotations)=0
the code is
Private Sub ll()
Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2
Set SwApp = Application.SldWorks
Set SwModel = SwApp.ActiveDoc
Dim SwSelMgr As SelectionMgr
Set SwSelMgr = SwModel.SelectionManager
Dim SwDraw As DrawingDoc, SwView As View
Set SwDraw = SwModel
Set SwView = SwDraw.GetFirstView
Dim SwDispDim As DisplayDimension, SwDim As Dimension
Set SwDispDim = SwView.GetFirstDisplayDimension5
'Debug.Print SwView.GetDimensionCount4
Do While Not SwDispDim Is Nothing
Set SwDim = SwDispDim.GetDimension
Debug.Print SwDim.FullName
Set SwDispDim = SwDispDim.GetNext5
Loop
'
Dim SwAnn As Annotation
ss = SwView.GetAnnotations
For ii = 0 To UBound(ss)
Set SwAnn = ss(ii)
Debug.Print SwAnn.GetName
Next ii
''
'tmp = SwModel.Extension.SelectByID2("Sheet")
Debug.Print SwView.GetName2
End Sub
GetFirstView → GetFirstDisplayDimension → ubound(GetAnnotations)>0
Set SwView = SwDraw.GetFirstView
Dim SwDispDim As DisplayDimension, SwDim As Dimension
Set SwDispDim = SwView.GetFirstDisplayDimension
Dim SwAnn As Annotation
ss = SwView.GetAnnotations
For ii = 0 To UBound(ss)
Set SwAnn = ss(ii)
Debug.Print SwAnn.GetName
Next ii
***************************
''
Private Sub ll1()
Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2
Set SwApp = Application.SldWorks
Set SwModel = SwApp.ActiveDoc
Dim SwSelMgr As SelectionMgr
Set SwSelMgr = SwModel.SelectionManager
Dim SwDraw As DrawingDoc, tmp, SwSheet As Sheet
tmp = SwModel.Extension.SelectByID2("Sheet1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
Stop
tmp = SwModel.Extension.SelectByID2("Sheet Format1", "SHEET", 0, 0, 0, False, 0, Nothing, 0)
tmp = SwModel.Extension.SelectByID2("Sheet1", "SHEET", 0, 0, 0, False, 0, Nothing, 0)
Set SwSheet = SwSelMgr.GetSelectedObject5(1)
Dim S1, S2
With SwSheet
S1 = .GetTemplateName
Debug.Print .GetSheetFormatName
S2 = .CustomPropertyView
Debug.Print .CustomPropertyView
Stop
End With
Debug.Print SwSheet.GetName
Stop
End Sub
SolidworksApi macros