Copyobjects creates corrupt pviewports?

Discussion in 'AutoCAD' started by Jeff-FRCH, Oct 28, 2004.

  1. Jeff-FRCH

    Jeff-FRCH Guest

    I have looked through a lot of posts on (vla-copyobjects) but I can't seem to find the answer I need.

    I am in DWG1 and want to open DWG2 in the background and then copy objects from DWG1 into DWG2 and then close DWG2. All in paperspace, no check required.

    (setq selset (ssget))
    (setq ssarray (SELECTIONSET->ARRAY selset)) ; this converts the selection set into a safe array - Thanks Frank Oquendo.
    (setq tmpdoc (vla-open (vla-get-documents (vla-get-acad-object)) fullname))
    (setq pspace (vla-get-paperspace tmpdoc))
    (vla-copyobjects (ACTIVE-DOCUMENT) ssarray pspace)

    This copies the objects but some of them are viewports and they come out corrupt or invalid. They appear correct but they list out as inactive, even though they are on. If I try to turn one on or switch to modelspace, AutoCAD crashes. Any ideas?

    I also have tried setting DWG2 current and doing a pasteorig but I don't know how to reset DWG1 current. The program hangs when DWG2 is activated.
     
    Jeff-FRCH, Oct 28, 2004
    #1
  2. Jeff-FRCH

    j.buzbee Guest

    There have also been a number of posts about mixing activex and AutoLISP
    methods (functions). It would be better for you to iterate through the
    block collection selecting objects that way. Remember, Model and Paperspace
    are blocks -.

    jb
     
    j.buzbee, Oct 28, 2004
    #2
  3. Jeff-FRCH

    James Allen Guest

    I'm not sure if I can help with your primary issue, but the hang when
    acitvating dwg2 is what I would expect. See the vlisp help files regarding
    MDI. It specifically addresses vlisp limitations in mdi, even working with
    activex.
    --
    James Allen, EIT
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO

    from DWG1 into DWG2 and then close DWG2. All in paperspace, no check
    required.
    set into a safe array - Thanks Frank Oquendo.
    corrupt or invalid. They appear correct but they list out as inactive, even
    though they are on. If I try to turn one on or switch to modelspace,
    AutoCAD crashes. Any ideas?
    know how to reset DWG1 current. The program hangs when DWG2 is activated.
     
    James Allen, Oct 28, 2004
    #3
  4. Jeff-FRCH

    j.buzbee Guest

    No, he's not trying to "open" another drawing with AutoLISP. He's
    attempting to gain access to a drawing database with the ObjectDBX
    interface. From then he can iterate through the blocks collection selecting
    which objects to copy with the 'CopyObjects method.

    So, if one wants to 'CopyObjects from the *paper_space block of a
    axdbdocument to the 'activedocument you must first know which *paper_space
    tab you want. Much easier with *model_space, there's only one.

    To iterate through the blocks collectionn in an axdbdocument:

    ;assuming axdbdoc is a vla-Object pointer to a databse accessed with
    ObjectDBX
    (vlax-for i (vlax-get axdbdoc 'blocks)
    (if (vl-string-search "*Paper_Space" (vlax-get 'name i)); it's a
    paperspace tab
    (vlax-for int i
    ;Collect objects to copy here
    )))

    The Model Space and Paper Space containers are merely blocks in the document
    object.

    A little more info on what exactly to copy might be helpful . . .

    jb
     
    j.buzbee, Oct 28, 2004
    #4
  5. Jeff-FRCH

    James Allen Guest

    Hi jb (James?), his last statement was all I was addressing.

    James

    know how to reset DWG1 current. The program hangs when DWG2 is activated.
     
    James Allen, Oct 29, 2004
    #5
  6. Jeff-FRCH

    j.buzbee Guest

    Ah, I was understanding "open DWG2 in the background" to mean ObjectDBX.
    Hmm. Maybe the OP will chime in and let us know what he meant?

    jb

    P.S. James B. ;-)
     
    j.buzbee, Oct 29, 2004
    #6
  7. Jeff-FRCH

    Jeff-FRCH Guest

    What I meant by in the background was that the drawing is open in AutoCAD but not active. I didn't think you could add objects to a drawing opened with DBX. I want the user to select the objects to copy from DWG1 using a selection set and then copy those objects into a series of drawings. Can this be done with ObjectDBX?
     
    Jeff-FRCH, Oct 29, 2004
    #7
  8. Jeff-FRCH

    j.buzbee Guest

    Yes, it just gets a little messy when you want to save the drawing opened
    via ObjectDBX: There is only a saveas method - so you would save the
    document "MyDrawing.dwg" to "MyDrawing-saved.dwg" . . . vl-file-delete
    "MyDrawing.dwg" (or better rename to "MyDrawingBAK.dwg") and then
    vl-file-rename "MyDrawing-saved.dwg" . . .. Sounds like a long way around
    but it's really not programatically.

    jb
     
    j.buzbee, Oct 29, 2004
    #8
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.