katto01 Posted June 13, 2018 Posted June 13, 2018 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 Quote
Hippe013 Posted June 13, 2018 Posted June 13, 2018 The following is from Autodesk Help Dim newlayer As AcadLayer Set newlayer = ThisDrawing.Layers.Add("LAYER1") ThisDrawing.ActiveLayer = newlayer Quote
BIGAL Posted June 14, 2018 Posted June 14, 2018 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. Quote
katto01 Posted June 10, 2022 Author Posted June 10, 2022 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 Quote
Recommended Posts
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.