Author Topic: How to attach Xref in closed file?  (Read 1411 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to attach Xref in closed file?
« on: May 22, 2018, 09:23:06 AM »
Hi all
I am working on a project, part of it to attach xref in model and another one in layout in a closed file.
I belive it can be done using ODBX.
Lets say
Code: [Select]
(setq f  "C:\\Test\\A100.dwg") ; The file
(setq Xf "C:\\Test\\2.0-GENERAL\\FRAME\\XFrame.dwg") ; Xref to be attach[quote]ed in layout
(setq XA "C:\\Test\\2.0-GENERAL\\FRAME\\File.dwg")   ; Xref to be attached in model


Can some one put me on track.
Any help will be appreciated.
« Last Edit: May 22, 2018, 09:31:15 AM by HasanCAD »

ronjonp

  • Needs a day job
  • Posts: 7531
Re: How to attach Xref in closed file?
« Reply #1 on: May 22, 2018, 11:27:41 AM »
Some info HERE.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to attach Xref in closed file?
« Reply #2 on: May 23, 2018, 02:57:11 AM »

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to attach Xref in closed file?
« Reply #3 on: May 23, 2018, 04:39:20 AM »
Thanks ronjonp
It is working pefect for model.
but I can't figure out how to attach to layout.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to attach Xref in closed file?
« Reply #4 on: May 23, 2018, 06:01:40 AM »
I used Blackbox function as subroutine to insert 2 files as Xref
I noticed that
I can't attach the second function delete previous attachment.

Code - Auto/Visual Lisp: [Select]
  1. (setq Plan    "C:\\Test\\A100.dwg")
  2. (setq Xref_01 "C:\\Test\\Xref-01.dwg")
  3. (setq Xref_02 "C:\\Test\\Xref-02.dwg")
  4.  
  5. (AttchXrf Plan Xref_01)
  6. (AttchXrf Plan Xref_02)

Code - Auto/Visual Lisp: [Select]
  1. (defun AttchXrf (orgn Xrf / dbx master)
  2. ; BlackBox
  3. ; http://www.cadtutor.net/forum/showthread.php?57980-ObjectDBX-Vla-AttachExternalReference
  4.   (vl-load-com)                         ; (AttchXrf orgn Xrf)
  5.                   (vlax-Get-Acad-Object)
  6.                   (strcat "ObjectDBX.AxDbDocument."
  7.                           (substr (getvar 'acadver) 1 2)
  8.                   )
  9.                 )
  10.       )
  11.     (progn
  12.       (vlax-for lay (vla-get-layouts dbx)
  13.         (if (= "MODEL" (strcase (vla-get-name lay)))
  14.                    (vla-get-block lay)
  15.                    Xrf
  16.                    (vl-filename-base Xrf)
  17.                    (vlax-3d-point '(0. 0. 0.))
  18.                    1.
  19.                    1.
  20.                    1.
  21.                    0.
  22.                    :vlax-true
  23.                  )
  24.           )
  25.         )
  26.       )
  27.       (vl-catch-all-apply 'vla-saveas (list dbx orgn))
  28.       (setq dbx (vl-catch-all-apply 'vlax-Release-Object (list dbx)))
  29.     )
  30.   )
  31.   (princ)
  32. )
« Last Edit: May 23, 2018, 06:28:48 AM by HasanCAD »