Jump to content

Recommended Posts

katto01

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

Share this post


Link to post
Share on other sites
Hippe013

The following is from Autodesk Help

 

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

Share this post


Link to post
Share on other sites
BIGAL

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×