Xref'd layers

Discussion in 'AutoCAD' started by Martin Schmid, Sep 13, 2004.

  1. How do I check if a layer is in the drawing, or if it is from an xref? Do I
    just have to check for the '|' character, or is there another way... i.e.,
    some property, i.e., IsDependant().. or some such?

    I.e.: in the for each:

    Sub ListLayers()
    Dim layerColl As AcadLayers
    Set layerColl = ThisDrawing.Layers
    Dim layer As AcadLayer

    For Each layer In layerColl
    ThisDrawing.Utility.Prompt layer.Name ' if layer is 'local' do
    something, if from xref, don't
    Next
    End Sub
     
    Martin Schmid, Sep 13, 2004
    #1
  2. Martin Schmid

    Matt W Guest

    This will get you started...

    Sub Test()
    Dim x As AcadLayer
    Dim varLay As Variant
    For Each x In ThisDrawing.Layers
    ' If the layer name is has a | symbol, then it's a xref layer
    If x.Name Like (("*") & ("|") & ("*")) Then
    Debug.Print x.Name & " is an XREF layer."
    varLay = Split(x.Name, "|", , vbTextCompare)
    ' Since there are only 2 parts to varLay,
    ' send to the Immediate window, just the layer name.
    Debug.Print varLay(1)
    End If
    Next x
    End Sub

    --
    I love deadlines
    I like the whooshing sound they make as they fly by.

    | How do I check if a layer is in the drawing, or if it is from an xref? Do
    I
    | just have to check for the '|' character, or is there another way... i.e.,
    | some property, i.e., IsDependant().. or some such?
    |
    | I.e.: in the for each:
    |
    | Sub ListLayers()
    | Dim layerColl As AcadLayers
    | Set layerColl = ThisDrawing.Layers
    | Dim layer As AcadLayer
    |
    | For Each layer In layerColl
    | ThisDrawing.Utility.Prompt layer.Name ' if layer is 'local' do
    | something, if from xref, don't
    | Next
    | End Sub
    |
    |
    |
    | --
    | Thanks,
    | Martin Schmid, EIT, CCSA, MCDBA, MCSE
    |
    |
     
    Matt W, Sep 14, 2004
    #2
  3. Yup... got that much... I just thought there was an .IsDependant property
    somewhere, but what you propose works...
     
    Martin Schmid, Sep 14, 2004
    #3
  4. There's really no need for pattern matching if all you want to know is
    whether a layer is xref dependent.

    You could simplify this by using the InStr function.
     
    Frank Oquendo, Sep 14, 2004
    #4
  5. You could simplify this by using the InStr function.

    I could, and I did...
     
    Martin Schmid, Sep 15, 2004
    #5
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.