Making a fresh copy of a file from an existing (not so fresh) file

hi all -

a file has become not very efficient, ghost XREFs, etc. all purges and audit won't improve much.

i want to export it to a new file by WBLOCKing model content, and then import all layouts to the new file (using 'from template' on a layout menu).

this whole procedure is quite easy, except for the fact the VIEWPORTs won't migrate with color/linetype definitions from the original file (VP freeze definitions, for some reason, do migrate).

the workaround i use is exportining each viewport LAYERSTATE, and then importing this LAYERSTATE to the viewport in the layout in the fresh file - and this procedure is a pain in the neck…..

why won't all VIEWPORT definitions migrate, and how to make this an easier task ?

thanx in advance

Comments

  • Hello.
    You could experiment with the Template option of the LAYOUT command.
    https://help.bricsys.com/en-us/document/command-reference/l/layout-command?version=V26&id=165079084948
    Using this option, layouts from other drawings can be imported into the current one.
    Maybe this approach could be helpful to import the original viewports together with their settings.

  • Why not go back to original dwg this was AI Copilot attempt at remove ghost xrefs. Not tested.

    (defun c:RemoveUnlinkedXrefs ( / doc coll item name isxref isloaded)
      (vl-load-com)
    
      (setq doc  (vla-get-ActiveDocument (vlax-get-acad-object))
            coll (vla-get-Blocks doc)
      )
    
      (vlax-for item coll
        (setq name     (vla-get-Name item)
              isxref   (vla-get-IsXRef item)
              isloaded (vla-get-IsLoaded item)
        )
    
        ;; If it's an XREF and NOT loaded → detach it
        (if (and isxref (not isloaded))
          (progn
            (prompt (strcat "\nDetaching XREF: " name))
            (vla-Detach item)
          )
        )
      )
    
      (princ "\nFinished removing non‑linked XREFs.")
      (princ)
    )
    

    What else is a problem in dwg ? Is it a CIV3D dwg ? In CIV3D lots of stuff is locked in a dwg.