Copy Layout Tabs

Discussion in 'AutoCAD' started by Matt W, Jul 6, 2004.

  1. Matt W

    Matt W Guest

    Maybe it's Monday... maybe I'm just being lazy, but how can you copy layouts
    from within a drawing??
    In other words, you start off with Layout1 in a drawing, copy it and now you
    have Layout1 and Layout1 (2).

    I don't want to copy or import from another drawing.
    Thanks in advance!
     
    Matt W, Jul 6, 2004
    #1
  2. Matt W

    Jeff Mishler Guest

    Hi Matt,
    Give this a try:

    Code:
    Sub testLayoutCopy()
    Dim oLayout1 As AcadLayout
    Dim oLayout2 As AcadLayout
    Dim oBlock1 As AcadBlock
    Dim oBlock2 As AcadBlock
    Dim aEnts() As AcadEntity
    Dim oEnt As AcadEntity
    Dim I As Long
    
    With ThisDrawing.Layouts
    Set oLayout1 = .Item(2) 'Layout you want to copy
    Set oLayout2 = .Add("NewLayout") 'New layout name
    End With
    
    Set oBlock1 = oLayout1.Block
    Set oBlock2 = oLayout2.Block
    
    ReDim aEnts(0 To (oBlock1.Count - 1))
    
    For Each oEnt In oBlock1
    Set aEnts(I) = oEnt
    I = I + 1
    Next oEnt
    
    ThisDrawing.CopyObjects aEnts, oBlock2
    
    End Sub
    
    HTH,
    Jeff
     
    Jeff Mishler, Jul 6, 2004
    #2
  3. Matt W

    Matt W Guest

    Yeah... I'm fried... It's *not* Monday. It's Tuesday!

    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | Maybe it's Monday... maybe I'm just being lazy, but how can you copy
    layouts
    | from within a drawing??
    | In other words, you start off with Layout1 in a drawing, copy it and now
    you
    | have Layout1 and Layout1 (2).
    |
    | I don't want to copy or import from another drawing.
    | Thanks in advance!
    |
    |
    | --
    | Matt W
    |
    | The difference between genius and stupidity is that genius has its limits.
    |
    |
     
    Matt W, Jul 6, 2004
    #3
  4. Matt W

    Matt W Guest

    Thanks Jeff!
    I'll have to see how I can incorporate this into my program.

    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | Hi Matt,
    | Give this a try:
    |
    |
    Code:
    | Sub testLayoutCopy()
    | Dim oLayout1 As AcadLayout
    | Dim oLayout2 As AcadLayout
    | Dim oBlock1 As AcadBlock
    | Dim oBlock2 As AcadBlock
    | Dim aEnts() As AcadEntity
    | Dim oEnt As AcadEntity
    | Dim I As Long
    |
    | With ThisDrawing.Layouts
    |     Set oLayout1 = .Item(2) 'Layout you want to copy
    |     Set oLayout2 = .Add("NewLayout") 'New layout name
    | End With
    |
    | Set oBlock1 = oLayout1.Block
    | Set oBlock2 = oLayout2.Block
    |
    | ReDim aEnts(0 To (oBlock1.Count - 1))
    |
    | For Each oEnt In oBlock1
    |     Set aEnts(I) = oEnt
    |     I = I + 1
    | Next oEnt
    |
    | ThisDrawing.CopyObjects aEnts, oBlock2
    |
    | End Sub
    | 
    |
    | HTH,
    | Jeff
    | --
    | For additional help, try out www.cadvault.com
    | remove USES from email address to reply
    |
    |
    | | > Maybe it's Monday... maybe I'm just being lazy, but how can you copy
    | layouts
    | > from within a drawing??
    | > In other words, you start off with Layout1 in a drawing, copy it and now
    | you
    | > have Layout1 and Layout1 (2).
    | >
    | > I don't want to copy or import from another drawing.
    | > Thanks in advance!
    | >
    | >
    | > --
    | > Matt W
    | >
    | > The difference between genius and stupidity is that genius has its
    limits.
    | >
    | >
    |
    |
     
    Matt W, Jul 6, 2004
    #4
  5. Matt W

    Jeff Mishler Guest

    You need to reset lng to 0 before going to the next layout to copy.......
     
    Jeff Mishler, Jul 6, 2004
    #5
  6. Matt W

    Matt W Guest

    Thanks.
    I thought it was something simple like that.


    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | You need to reset lng to 0 before going to the next layout to copy.......
    |
    | --
    | For additional help, try out www.cadvault.com
    | remove USES from email address to reply
    |
    |
    | | > I've run into a snag...
    | > Maybe you can point me in the right direction...
    | >
    | > Here's the file... It will only copy one layout tab. If I select more
    | than
    | > one, it crashes. I get a <subsscript out of range> error message.
    | >
    | > --
    | > Matt W
    | >
    | > The difference between genius and stupidity is that genius has its
    limits.
    | > | > | Hi Matt,
    | > | Give this a try:
    | > |
    | > |
    Code:
    | > | Sub testLayoutCopy()
    | > | Dim oLayout1 As AcadLayout
    | > | Dim oLayout2 As AcadLayout
    | > | Dim oBlock1 As AcadBlock
    | > | Dim oBlock2 As AcadBlock
    | > | Dim aEnts() As AcadEntity
    | > | Dim oEnt As AcadEntity
    | > | Dim I As Long
    | > |
    | > | With ThisDrawing.Layouts
    | > |     Set oLayout1 = .Item(2) 'Layout you want to copy
    | > |     Set oLayout2 = .Add("NewLayout") 'New layout name
    | > | End With
    | > |
    | > | Set oBlock1 = oLayout1.Block
    | > | Set oBlock2 = oLayout2.Block
    | > |
    | > | ReDim aEnts(0 To (oBlock1.Count - 1))
    | > |
    | > | For Each oEnt In oBlock1
    | > |     Set aEnts(I) = oEnt
    | > |     I = I + 1
    | > | Next oEnt
    | > |
    | > | ThisDrawing.CopyObjects aEnts, oBlock2
    | > |
    | > | End Sub
    | > | 
    | > |
    | > | HTH,
    | > | Jeff
    | > | --
    | > | For additional help, try out www.cadvault.com
    | > | remove USES from email address to reply
    | > |
    | > |
    | > | | > | > Maybe it's Monday... maybe I'm just being lazy, but how can you copy
    | > | layouts
    | > | > from within a drawing??
    | > | > In other words, you start off with Layout1 in a drawing, copy it and
    | now
    | > | you
    | > | > have Layout1 and Layout1 (2).
    | > | >
    | > | > I don't want to copy or import from another drawing.
    | > | > Thanks in advance!
    | > | >
    | > | >
    | > | > --
    | > | > Matt W
    | > | >
    | > | > The difference between genius and stupidity is that genius has its
    | > limits.
    | > | >
    | > | >
    | > |
    | > |
    | >
    | >
    | >
    |
    |
     
    Matt W, Jul 6, 2004
    #6
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.