Author Topic: AutoCAD XREF Lisp  (Read 14234 times)

0 Members and 1 Guest are viewing this topic.

zride91

  • Guest
AutoCAD XREF Lisp
« on: September 26, 2013, 04:17:31 PM »
Hello, 
I have a nightmare of a project that we are trying to bind and send to the client.  This project has a lot of their XREFs attached with many layers of nested references.  A lot of the nested references are unloaded, and it seems AutoCAD wants all the nested XREFs to be loaded prior to binding.

I was curious if anyone has seen any lisp that would look at the file, note which reference files are unloaded, then reload all to allow AutoCAD to bind all.  After the bind, the lisp would delete any block references named the same as teh XREFs noted to be unloaded.

I'm not even sure what would be involved creating a lisp to do this.

Thanks

owenwengerd

  • Bull Frog
  • Posts: 451
Re: AutoCAD XREF Lisp
« Reply #1 on: September 26, 2013, 04:52:24 PM »
Is it possible to simply detach the unloaded xrefs prior to binding?

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: AutoCAD XREF Lisp
« Reply #2 on: September 26, 2013, 04:54:58 PM »
Have you tried etransmit with the bind option?  The bind option will ignore unloaded xrefs.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

zride91

  • Guest
Re: AutoCAD XREF Lisp
« Reply #3 on: September 26, 2013, 05:24:13 PM »
Hi!  Thank you very much for the quick responses.

Yeah, I've been working with this trying to do something with in native AutoCAD the good part of the day.  Unfortunately, the nested references can not be detached, we would have to go throught 200+ files change xref types from attachments to overlays, then go back trough and re-attach XREFs as needed.  I have tried eTransmit, it doesn't bind the files, I have also tried -EXPORTTOAUTOCAD, as this usually works when having problems as well.  These unloaded nested files are really hanging me up.  I've done -RECOVERALL to make sure there are no lingering errors in one of the XREFs, I've exploded all te AEC content in XREFs, nothing has been helping.  I believe it is just due to the overly complex web of XREFs, which is why I want to try to simply reload all, then go back and deleted the bound files that were not previously shown.

I appreciate the suggestions, I am at wit's end.if there are any other suggestions, I am all ears.

Thank you!

zride91

  • Guest
Re: AutoCAD XREF Lisp
« Reply #4 on: September 26, 2013, 05:26:15 PM »
Oh, btw, I am using AutoCAD 2011 on this project, I don't have the option to ignore unloaded XREFs.  I appreciate you pointing this out though, as I may try this in 2013 to see if it works any better.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: AutoCAD XREF Lisp
« Reply #5 on: September 26, 2013, 09:06:58 PM »
over in this post is a list common requested or created lisp.  Check to see of any of these can be of use.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

zride91

  • Guest
Re: AutoCAD XREF Lisp
« Reply #6 on: September 26, 2013, 10:24:05 PM »
Oooooo...  Thank you VERY much, these look promising!

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: AutoCAD XREF Lisp
« Reply #7 on: September 27, 2013, 10:14:03 AM »
No problem.  Let us know how it works out for you. 
Ohh BTW:  Welcome to TheSwamp.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

danallen

  • Guest
Re: AutoCAD XREF Lisp
« Reply #8 on: September 27, 2013, 02:34:15 PM »
what is that clever list you have there?

over in this post is a list common requested or created lisp.  Check to see of any of these can be of use.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: AutoCAD XREF Lisp
« Reply #9 on: September 27, 2013, 02:55:21 PM »
what is that clever list you have there?

over in this post is a list common requested or created lisp.  Check to see of any of these can be of use.
It TheSwamp's Thread of Problems and Solutions Links (don't reinvent the wheel ...) 

Basically as the OPs post states ... "it's all been done before" with regards to programming.   ... and the following threads contain links to other threads that have code to commonly sought after solutions.  A lot of good stuff there, check it out. 
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

danallen

  • Guest
Re: AutoCAD XREF Lisp
« Reply #10 on: September 27, 2013, 02:58:43 PM »
Brilliant! I never caught on the CAB had that list. Thanks

zride91

  • Guest
Re: AutoCAD XREF Lisp
« Reply #11 on: September 30, 2013, 12:11:12 PM »
Krushert,

Thanks for the suggestions, I tried out some of the lisps in the thread you sent, they are close, but the reload lisp will not do nested XREFs.  At this point, I'm out of time for finding shortcuts, we're going to have to start manually going through the project files and trying to put the XREFs in order and figure out how to get this file package bound. 

danallen

  • Guest
Re: AutoCAD XREF Lisp
« Reply #12 on: September 30, 2013, 04:36:51 PM »
to bind an xref with unloaded nested xrefs, I repath them to a blank file. Here is my routine, uses doslib but you can easily rewrite to do without

Code - Auto/Visual Lisp: [Select]
  1. (defun c:RepathUnloadedXrefs () (abc_RepathUnloadedXrefs nil)(princ))
  2. (defun c:RepathUnloadedXrefsWithBlank () (abc_RepathUnloadedXrefs "_blank.dwg")(princ))
  3. (defun c:RPUX () (c:RepathUnloadedXrefsWithBlank)(princ))
  4.  
  5. (defun-q abc_RepathUnloadedXrefs ( replacedwg / unlxrefs dwglist$ continue      )
  6.   ;; if preset replacement drawing provided, confirm it existings
  7.   (if replacedwg
  8.     (or ;(setq replacedwg (abc_FindFile_Library replacedwg))
  9.         (setq replacedwg (findfile replacedwg))
  10.     )
  11.   )
  12.   ;; check for unloaded xrefs
  13.   (setq unlxrefs (abc_GetXrefUnLoaded)
  14.         dwglist$ ""
  15.   )
  16.   ;; if they existing, ask to confirm
  17.   (if unlxrefs
  18.     (progn
  19.       (foreach x unlxrefs
  20.         (setq dwglist$ (strcat dwglist$ (car x) "\n"))
  21.       )
  22.       (setq continue (dos_msgbox (strcat "Repath the following unloaded xrefs:\n" dwglist$ (if replacedwg (strcat "\nWith this file: " replacedwg) "")) "Repath Unloaded Xrefs" 2 4))
  23.       ;; if replacement drawings not provided or found, ask for it
  24.       (if (and (not replacedwg)(= 4 continue))
  25.         (setq replacedwg (dos_getfiled
  26.                            "Select a file with which to repath unloaded xrefs"
  27.                            (getvar "dwgprefix")
  28.                            "Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
  29.                          )
  30.         )
  31.       )
  32.       (if (and replacedwg (= 4 continue))
  33.         (progn
  34.           (foreach x unlxrefs
  35.             (command "-xref" "path" (car x) replacedwg)
  36.             (command "-xref" "reload" (car x))
  37.             (princ (strcat "\nRepathed xref " (car x) " with " replacedwg))
  38.           ) ;_foreach
  39.         ) ;_progn
  40.         (princ "\nNo file selected to repath xrefs.")
  41.       ) ;_if
  42.     ) ;_progn
  43.     (princ "\nNo unloaded xrefs to repath.")
  44.   ) ;_if
  45.   (princ)
  46. ) ;_defun
  47.  
  48. (defun-q abc_GetXrefUnLoaded (/ block bname xlist)              ;includes unresolved (unfound)
  49.   (while (setq block (tblnext "block" (not block)))
  50.     (cond ( (and (eq 4 (logand 4 (cdr (assoc 70 block))))               ;is this an xref?
  51.                  (zerop (logand (cdr (assoc 70 block)) 32))             ; and is it not loaded?
  52.             ) ;and
  53.             (setq bname (strcase (cdr (assoc 2 block)) t))
  54.             (setq bc    (cdr (assoc 70 block)))                         ; return actual bitcode
  55.             (setq path  (strcase (cdr (assoc 1 block)) t))
  56.             (setq xlist (cons (list bname bc path) xlist))
  57.           )
  58.     )
  59.   )
  60.   (reverse xlist)
  61. )
  62.  
  63.  
  64.  
« Last Edit: October 02, 2013, 02:46:48 PM by danallen »

zride91

  • Guest
Re: AutoCAD XREF Lisp
« Reply #13 on: September 30, 2013, 04:44:50 PM »
THANK YOU Danallen, I will give this a try!

curmudgeon

  • Newt
  • Posts: 194
Re: AutoCAD XREF Lisp
« Reply #14 on: October 02, 2013, 09:07:45 AM »
Occam's razor?
Could you create empty files with appropriate names so that you could load them long enough to detach them?

For my part, I prefer to RECEIVE files without binding them. It lets me do the sorting myself - and other offices
often seem to misunderstand what it is I need from the file(s).
Never express yourself more clearly than you are able to think.