Get COLORREF Values of Standard User-interface Elements (VB.NET)
This example shows how to get the COLORREF values of standard SolidWorks
user-interface elements.
'---------------------------------------------------------
' Preconditions: Open the Immediate window.
'
' Postconditions:
' 1. New part document opened.
' 2. The names of the SolidWorks standard
' user-interface elements (dimensions,
' backgrounds, drawing paper, sketch status,
' annotations, etc.) and their COLORREF
' values are printed to the Immediate window.
'--------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial
Class SolidWorksMacro
Public
Sub Main()
Dim swColorTable
As ColorTable
Dim standardCount
As
Integer
Dim
count As
Integer
Dim
colorName As
String
Dim
colorRef As
Integer
swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SolidWorks
2010\templates\part.prtdot", 0, 0, 0)
swColorTable = swApp.GetColorTable
standardCount = swColorTable.GetStandardCount
Debug.Print("SolidWorks standard
user-interface element and COLORREF value:")
' Iterate through standard colors
For
count = 0 To (standardCount
- 1)
' Get the entry name
colorName = swColorTable.GetNameAtIndex(count)
If colorName <>
""
Then
' Get the
entry's COLORREF
colorRef = swColorTable.GetColorRefAtIndex(count)
Debug.Print(" "
& colorName & " : " &
colorRef)
Else
End
If
Next
count
End
Sub
'''
<summary>
''' The SldWorks swApp
variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End
Class