Results 1 to 2 of 2

Thread: create xref drawings?

  1. #1
    Member
    Join Date
    2000-12
    Location
    LOS ANGELES
    Posts
    22

    Question create xref drawings?

    Hi everyone.

    Is it possible to create a lisp routine or VBA program that is able to create new drawings with the appropriate xref files and then save them to a specific directory? For example: I want open a new drawing xreference X-101.dwg to it and saveas X-101RL in a different directory. I want to do the same for X-102, x-103.... and so on. So in the end I will have two directories on with all the xref files and another with all the xref files reference to the new drawings with RL at the end of the drawing name.

  2. #2
    100 Club
    Join Date
    2000-12
    Posts
    126

    Default Re: create xref drawings?

    Could be done in a number of ways. Here's maybe a starting point (assuming you need the saveas done while xref'ing drawings). It also assumes you're using 2005 or higher.
    Code:
    (defun saveXRef (fn name / dbx fn_base fn_dir fn_ext newFilename)
      (cond
        ((setq dbx (vlax-create-object "ObjectDBX.AxDbDocument.16"))
         (cond
           ((not
              (vl-catch-all-error-p
                (vl-catch-all-apply 'vlax-invoke-method (list dbx 'Open fn))
              )
            )
            (setq fn_base    (vl-filename-base fn)
                  ;; change directory here if need be
                  fn_dir   (vl-filename-directory fn)
                  fn_ext   (vl-filename-extension fn)
                  newFilename (strcat fn_dir "\\" fn_base "RL" fn_ext)
            )
            (and (not
                   (vl-catch-all-error-p
                     (vl-catch-all-apply 'vlax-invoke-method
                                         (list dbx 'SaveAs newFilename)
                     )
                   )
                 )
                 (princ (strcat "\nXref " name " saved as " newFilename))
            )
           )
         )
         (vlax-release-object dbx)
        )
      )
    )
    
    (defun xAttachSaveAs (/ ent entl lastent path)
      (setq lastent (entlast))
      (and (vl-cmdf "XATTACH")
           (while (> (getvar "CMDACTIVE") 0) (vl-cmdf pause))
           (not (eq lastent (setq ent (entlast))))
           (= (cdr (assoc 0 (setq entl (entget ent)))) "INSERT")
           (setq path (findfile (cdr (assoc 1
                        (tblsearch "BLOCK" (setq name (cdr (assoc 2 entl)))))))
           )
           (saveXRef path name)
      )
    )
    
    (defun C:XSave ()
      (xAttachSaveAs)
      (princ)
    )

Similar Threads

  1. xref slowing down the drawings
    By gerit in forum AutoCAD General
    Replies: 17
    Last Post: 2012-04-18, 05:55 AM
  2. Searching for drawings that contain a Xref
    By john.barton in forum AutoCAD General
    Replies: 2
    Last Post: 2006-03-01, 01:39 PM
  3. Layers of Xref drawings
    By luis.93102 in forum AutoCAD LT - General
    Replies: 7
    Last Post: 2005-09-14, 05:35 PM
  4. xref drawings not updating
    By msanders.85217 in forum AutoCAD General
    Replies: 3
    Last Post: 2005-05-11, 11:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •