Setting bylayer

Discussion in 'AutoCAD' started by ajtruckle, Nov 15, 2004.

  1. ajtruckle

    ajtruckle Guest

    I am doing this for each entity I create:

    Set colour = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
    .TrueColor = colour
    .Linetype = "BYLAYER"
    .Lineweight = acLnWtByLayer

    I would prefer to either:

    a) have a method where i can pass the object in to update it as above. But then each object is different, so is there a base object it can be passed as?

    or

    b) store the current wieght, colour,style settings and update them all to bylayer. This would do away with the solution a and then restore them at the end.

    I can work out how to get active layer and restore. But I can't work out how to get active style,wieght, colour, set them all to bylayer and restore.

    Advice on doing either solution and whichever is most efficient please.

    Thanks.

    Andrew
     
    ajtruckle, Nov 15, 2004
    #1
  2. ajtruckle

    ajtruckle Guest

    I worked it out. This code stores the current values and then sets to BYLAYER and then re-uses originals.

    [pre]
    Dim orgLayer As AcadLayer
    Dim strCOLOR As String
    Dim strLTYPE As String
    Dim strLWEIGHT As Integer

    With ThisDrawing
    ' Get current settings
    Set orgLayer = .ActiveLayer
    strCOLOR = .GetVariable("CECOLOR")
    strLTYPE = .GetVariable("CELTYPE")
    strLWEIGHT = .GetVariable("CELWEIGHT")

    ' Set to BYLAYER
    Call .SetVariable("CECOLOR", "BYLAYER")
    Call .SetVariable("CELTYPE", "BYLAYER")
    Call .SetVariable("CELWEIGHT", acLnWtByLayer)
    End With

    ' Do your stuff here....

    With ThisDrawing
    ' Reset back to original settings
    .ActiveLayer = orgLayer
    Call .SetVariable("CECOLOR", strCOLOR)
    Call .SetVariable("CELTYPE", strLTYPE)
    Call .SetVariable("CELWEIGHT", strLWEIGHT)
    End With
    [/pre]

    I could have used ActiveLineType but I wanted to keep as much of it as consistent as possible. Ideally, I would like to use the variable approach for the layer name too, but could not work out what variable it was...
     
    ajtruckle, Nov 15, 2004
    #2
  3. ajtruckle

    ajtruckle Guest

    Found answer to this aswell:

    [pre]
    dim strLAYER as String

    call strLayer = ThisDrawing.GetVariable("CLAYER")
    [/pre]
     
    ajtruckle, Nov 15, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.