Transferring Plot Configurations

Discussion in 'AutoCAD' started by JFord, Nov 18, 2004.

  1. JFord

    JFord Guest

    I'm trying to transfer all plot configurations from one drawing (Dwg2) to another (Dwg1). I'm using the code below. A boolean (PC_Del) has been previously set to determine if the macro should delete old plot configurations with the same name as the new one. The macro runs OK until I get to the last step where I want the new plot configuration to be added to Dwg1. I get a message "Object doesn't support this property or method". Any ideas?
    For Each PC In AcadApp.Documents(Dwg2).PlotConfigurations
    PC_Skip = False
    For Each PC1 In AcadApp.Documents(Dwg1).PlotConfigurations
    ' Check for Delete or skip of common conigurations
    If PC.Name = PC1.Name And PC_Del Then PC1.Delete
    If PC.Name = PC1.Name And Not PC_Del Then PC_Skip = True
    Next
    If Not PC_Skip Then AcadApp.Documents(Dwg1).PlotConfigurations.Add (PC)
    Next
     
    JFord, Nov 18, 2004
    #1
  2. JFord

    m8shark Guest

    Attached is a text file with a working function with comments. I didn't test it thoroughly, so use at your own risk and all that.

    There are a couple things I saw in your code you should know:

    The error you're getting is because you're trying to add an object to Dwg1 that is 'owned' by Dwg2. That's not allowed. You need to use CopyObjects instead. But you can't use CopyObjects inside a FOR loop. So you need to 'collect' the objects to be copied in an array.

    Also, you will get an error earlier in the code. Look at the two IFs within the inner FOR loop. The second IF needs to read PC1.Name but if PC_Del = True, there's the possibility that PC1 will already have been deleted within the preceding IF block! Nested IFs would be better. You'll see that in the function I wrote.

    Good luck.
     
    m8shark, Nov 20, 2004
    #2
  3. JFord

    JFord Guest

    I appreciate the code and your sense of humor (The comments in the code were great). Your code did exactly what I wanted. I can't thank you enough.
    PS - Sorry for the delay in responding - been out of the office for almost 2 weeks.
     
    JFord, Nov 29, 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.