Jump to content

VBA change layers


katto01
 Share

Recommended Posts

Hello,

 

I am trying unsuccessfuly to switch layers from EXCEL.

This is my code:

Please advise

 

Thanks

 

 
Public Sub MISKO()
Dim ACAD As AcadApplication 
On Error Resume Next 
Set ACAD = GetObject(, "AutoCAD.Application") 
Call ACAD_SELECT_LAYER("BIBI")
End Sub
Public Sub ACAD_SELECT_LAYER(A$)
Dim ACAD As AcadApplication Dim objLayer As AcadLayer
Dim acadDoc As AcadDocument
Set ACAD = GetObject(, "AutoCAD.Application") 'Get a running instance of the class AutoCAD.Application
Set acadDoc = ACAD.ActiveDocument
Set objLayer = acadDoc.Layers(A$) ‘ < supposed to select this layer passed by A$
End Sub

Link to comment
Share on other sites

The following is from Autodesk Help

 

Dim newlayer As AcadLayer
Set newlayer = ThisDrawing.Layers.Add("LAYER1")
ThisDrawing.ActiveLayer = newlayer

Link to comment
Share on other sites

katto01 you may want to look into setting variables using vba there are so many "clayer" "osmode" "style" to mention a few Hippe013 has answered layer there is probably a list somewhere vba v's autocad v's LIsp.

Link to comment
Share on other sites

  • 3 years later...

Still don't have a solution. I need to switch between EXISTING layers. Adding a new layer is not helping

Say I have 3 layers L1,L2,L3

 

I need to select L1 and do something on it, then select L2 and do something on it etc.

 

Thank you

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...