Hide Table of Contents

Ignore Feature Colors Example (VBA)

This example shows how to change a user preference option so that feature colors are ignored in parts. This option setting, swIgnoreFeatureColors, can be true or false and can be different for each document. It is not a system-level setting; it is a document-level setting. Therefore, you must set this value for each document.

By default, when a document is created, swIgnoreFeatureColors is false.

'----------------------------------------------------------------
' Preconditions: Open a part document.
'
' Postconditions:
' 1. Gets current setting for swIgnoreFeatureColors and
'    pops up a message box. Click OK to close the message
'    box.
' 2. Pops up a message box prior to setting swIgnoreFeatureColors
'    to true. Click OK to close the message box.
' 3. Sets swIgnoreFeatureColors to true and pops up a message
'    box indicating setting swIgnoreFeatureColors to true
'    is successful. Click OK to close the message box.
'----------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim res, val As Boolean
Dim msg1 As String
Sub main()
    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc    
    ' Exit if no model is active
    If Part Is Nothing Then
        swApp.SendMsgToUser "Open a model document and run the macro again."
        Exit Sub
    End If    
    ' Get current setting
    val = Part.GetUserPreferenceToggle(swIgnoreFeatureColors)    
    ' Create message
    msg1 = "swIgnoreFeatureColors is currently set to " & val & "."    
    ' Send message to user
    swApp.SendMsgToUser msg1    
    ' Change setting to true, which indicates to ignore feature colors
    swApp.SendMsgToUser "Setting swIgnoreFeatureColors to True."
    res = Part.SetUserPreferenceToggle(swIgnoreFeatureColors, True)
    
    ' Verify if successful    If (res = True) Then
        swApp.SendMsgToUser "Setting swIgnoreFeatureColors to True successful."
    Else
        swApp.SendMsgToUser "Error! Setting swIgnoreFeatureColors to True not successful."
    End If
End Sub


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Ignore Feature Colors Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2016 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.