Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

VB layer question

Status
Not open for further replies.

DHALE1

Mechanical
Jan 8, 2003
61
I am able to turn layers on and off in VB. My question is that I would like to use a checkbox in VB 6 to control the layer. I havn't figured out how to get the checkbox to show a check if the layer is on when the .exe is run. Can anyone help?
 
Replies continue below

Recommended for you

Yes the Solidworks API have an Layer Manager object wich is parent of the object Layer.

The object layer have the following properties:
Layer.Color
Layer.Description
Layer.Name
Layer.Style
Layer.Visible
Layer.Width
and one Method Layer.GetID.

Turn Layer.Visible On and Off to make it happen.

Layer.Visible = False

Remember that you need to access the object Layer from the LayerMgr wich it is a collection of Layers.
 
A little code to explain it better:

Dim swApp As Object

Dim pDrawing As Object

Dim pLayerMgr As Object

Dim pLayer As Object


Sub main()

Set swApp = Application.SldWorks
Set pDrawing = swApp.ActiveDoc
Set pLayerMgr = pDrawing.GetLayerManager
Set pLayer = pLayerMgr.GetLayer("YOURLAYER")
if chkbox.value = 1 then pLayer.Visible = true
if chkbox.value = 0 then pLayer.visible = false
End Sub
 
Basic to any SW API rogramming: you need to sync the SW state with your interface.

Translation:
Check all the layers when the form loads, then adjust checkboxes accordingly. Use the checkbox change events to trigger instantaneous layer toggling.

[bat]"An object at rest can not be stopped."[bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor