Hide or Show First Column in Hole Table (VB.NET)
This example shows how to hide or show the first column in a hole table.
'--------------------------------------
' Preconditions:
' 1. Drawing document is open in which a hole
' table
exists.
' 2. The Hole Table feature is selected in
' the
FeatureManager design tree
'
' Postconditions: First column is hidden if shown and
' shown
if hidden.
'--------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
Public
Sub main()
Dim
swModel As ModelDoc2
Dim
swSelMgr As SelectionMgr
Dim
swHoleTableAnnotation As HoleTableAnnotation
Dim
swTableAnnotation As TableAnnotation
Dim
swAnnotation As Annotation
Dim
swHoleTable As HoleTable
swModel
= swApp.ActiveDoc
swSelMgr
= swModel.SelectionManager
If
(swSelMgr.GetSelectedObjectCount
= 0 Or Not (swSelMgr.GetSelectedObjectType(1) = swSelectType_e.swSelHOLETABLEFEATS))
Then
MsgBox("Please
select a Hole Table feature in the FeatureManager design tree.")
Exit
Sub
End
If
swHoleTable
= swSelMgr.GetSelectedObject6(1,
-1)
swHoleTableAnnotation
= swHoleTable.GetTableAnnotations(0)
swTableAnnotation
= swHoleTableAnnotation
swAnnotation
= swTableAnnotation.GetAnnotation
'
If first column hidden, then show it
If
(swTableAnnotation.ColumnHidden(0))
Then
Debug.Print("
First column hidden before API call: " & swTableAnnotation.ColumnHidden(0))
swTableAnnotation.ColumnHidden(0) = False
Debug.Print("
First column hidden after API call: "
& swTableAnnotation.ColumnHidden(0))
Else
'
If first column shown, then hide it
Debug.Print("
First column hidden before API call: " & swTableAnnotation.ColumnHidden(0))
swTableAnnotation.ColumnHidden(0) = True
Debug.Print("
First column hidden after API call: "
& swTableAnnotation.ColumnHidden(0))
End
If
End
Sub
'--------------------------------------
'''
<summary>
'''
The SldWorks swApp variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End Class