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 1

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

You should probably post this in the SolidWorks forum. There are plenty of API discussions there. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
I don't have an example, but it should be accessible with the Layer.Visible property. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
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.
 
dsi,
Thanks for you help.
joshh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor