Layouts in array

Discussion in 'AutoCAD' started by johnsonm, Aug 23, 2004.

  1. johnsonm

    johnsonm Guest

    I am trying to setup an automated batch plot. And I was thinking of using an array to cycle through the layouts. But when I try to add a layout to an array, I get an error, "Object variable or With block variable not set".

    What could I be doing wrong?

    Dim Layout as ACADLayout
    Dim Layoutlist(0 to 3) as ACADLayout
    Dim count as Integer

    count = 0
    For Each Layout In ThisDrawing.Layouts
    Layoutlist(count) = Layout
    count = count + 1
    Next
     
    johnsonm, Aug 23, 2004
    #1
  2. johnsonm

    Jeff Mishler Guest

    Why not just do the plotting as you cycle through the layouts?

    But to answer your question, try this:

    Dim Layout As AcadLayout
    Dim Layoutlist() As AcadLayout
    Dim count As Integer
    ReDim Layoutlist(0 To 500)
    count = 0
    For Each Layout In ThisDrawing.Layouts
    Set Layoutlist(count) = Layout
    count = count + 1
    Next
    ReDim Preserve Layoutlist(0 To count - 1)


    --
    Jeff
    check out www.cadvault.com
    an array to cycle through the layouts. But when I try to add a layout to an
    array, I get an error, "Object variable or With block variable not set".
     
    Jeff Mishler, Aug 23, 2004
    #2
  3. johnsonm

    Matt W Guest

    Here's a snippet of what I wrote for our Batch Plotting program.
    Basically it will plot any tab in a drawing that isn't called "Model" or
    begins with the letters "PDF"...

    Dim x As AcadLayout
    For Each x In ThisDrawing.Layouts
    If x.Name = "Model" Or UCase(x.Name) Like (("PDF") & ("*")) Then
    Debug.Print "Skipping tab"
    Else
    ThisDrawing.ActiveLayout = ThisDrawing.Layouts(x.Name)
    ' Create a plot file of the layout tab and give it a name
    End If

    Hope this helps
    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | I am trying to setup an automated batch plot. And I was thinking of using
    an array to cycle through the layouts. But when I try to add a layout to an
    array, I get an error, "Object variable or With block variable not set".
    |
    | What could I be doing wrong?
    |
    | Dim Layout as ACADLayout
    | Dim Layoutlist(0 to 3) as ACADLayout
    | Dim count as Integer
    |
    | count = 0
    | For Each Layout In ThisDrawing.Layouts
    | Layoutlist(count) = Layout
    | count = count + 1
    | Next
     
    Matt W, Aug 23, 2004
    #3
  4. Layoutlist(count) = Layout
    Should be...Set Layoutlist..
    They are already in a collection...If your not filtering anyting
    you could just use the collection itself.

    Dim Layouts As AcadLayouts
    Dim Layout As AcadLayout

    For Each Layout in Layouts
    'do what you need to...Filter for layers you want to plot maybe..
    'then place in array if necessary
    'better yet place in new collection

    hih
    Paul
    an array to cycle through the layouts. But when I try to add a layout to an
    array, I get an error, "Object variable or With block variable not set".
     
    Paul Richardson, Aug 23, 2004
    #4
  5. I was wondering why no one had posted a reply..till they all showed up at
    once with mine...ha
     
    Paul Richardson, Aug 23, 2004
    #5
  6. Not that you need anymore but... sorry for the sloppy syntax. Assumed call
    to the drawing..but just in case..gl

    With ThisDrawing
    For Each Layout In .Layouts
     
    Paul Richardson, Aug 23, 2004
    #6
  7. johnsonm

    johnsonm Guest

    Actually, I wanted to learn something new, and thats why I asked, I currently have my sub running from the layouts collection and it works fine, what I do to filter out layouts is
    If Not layout.name Like "*Lay*' Then
    Blah Blah Blah

    When I first tried it with the array, I was stumped, so I wanted to see if it was possible, and the best way to learn is to ask.
     
    johnsonm, Aug 24, 2004
    #7
  8. sorry...

    Dim Layout As AcadLayout
    Dim Layouts As AcadLayouts
    Dim Larray() As Variant
    Dim i As Integer: i = 0

    With ThisDrawing
    For Each Layout In .Layouts
    ReDim Preserve Larray(i)
    Set Larray(i) = Layout
    i = i + 1
    Next Layout
    End With



    currently have my sub running from the layouts collection and it works fine,
    what I do to filter out layouts is
    it was possible, and the best way to learn is to ask.
     
    Paul Richardson, Aug 24, 2004
    #8
  9. for anyone that chimed in at the end....the preceding code was just an
    example...not a recommendation...couple layers not bad...adding many objects
    to an array this way would slow things down...cheers..
     
    Paul Richardson, Aug 24, 2004
    #9
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.