+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Mar 2008
    Posts
    16

    Default VBA change layers

    Registered forum members do not see this ad.

    Hello,

    I am trying unsuccessfuly to switch layers from EXCEL.
    This is my code:
    Please advise

    Thanks

    Code:
     
    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

  2. #2
    Senior Member
    Discipline
    Civil
    Hippe013's Discipline Details
    Occupation
    Survey Crew Chief / Civil Designer
    Discipline
    Civil
    Details
    Land Survey / Civil Engineering
    Using
    Civil 3D 2017
    Join Date
    Feb 2010
    Location
    North Dakota
    Posts
    385

    Default

    The following is from Autodesk Help

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

  3. #3
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,579

    Default

    Registered forum members do not see this ad.

    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.
    A man who never made mistakes never made anything

Similar Threads

  1. I cannot change the LineType in my layers :(
    By salaxi in forum AutoCAD General
    Replies: 6
    Last Post: 8th Jun 2013, 05:31 pm
  2. Using Layers to change viewports
    By jaredmccullough in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 1st May 2013, 02:55 am
  3. Change layers to blocks
    By NStocks in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 24th Apr 2008, 07:42 pm
  4. change color of layers
    By Tiger in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 23rd Nov 2007, 06:26 pm
  5. Using scripts to change layers?
    By Brendan in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 17th Jul 2007, 05:49 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts