Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB to set SolidWorks layers to visible

Status
Not open for further replies.

jh0401

Computer
Apr 8, 2002
32
Does anyone have a good example for turning SolidWorks layers on and off with Visual Basic?

Thanks

Josh
 
Replies continue below

Recommended for you

Here is a sample that turns off a layer called DIM:
Code:
Option Explicit

Sub TurnOffLayer()
    Dim swApp As Object
    Dim Part As Object
    Dim swLayerMgr As Object
    Dim swLayer As Object
    
    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set swLayerMgr = Part.GetLayerManager
    Set swLayer = swLayerMgr.GetLayer("DIM")
    swLayer.Visible = False

    Set swLayer = Nothing
    Set swLayerMgr = Nothing
    Set Part = Nothing
    Set swApp = Nothing
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Scott:
Yeah, that's the first thing I tried. Unfortunately, it does not record anything on that action. No sense making it easy. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
have you ever peeked at the .swp file? Sometimes you get a little more info out of that one. Just drag it into notepad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor