×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB layer question

VB layer question

VB layer question

(OP)
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?

RE: VB layer question

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.

RE: VB layer question

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

RE: VB layer question

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.

"An object at rest can not be stopped."
http://www.EsoxRepublic.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources