Author Topic: Xref Update Reactor  (Read 3340 times)

0 Members and 1 Guest are viewing this topic.

SPDCad

  • Bull Frog
  • Posts: 453
Xref Update Reactor
« on: August 31, 2004, 02:43:09 PM »
Any one have an automatic xref update reactor lisp I can look at?


I am trying to write a reactor that will update the xrefs automatically when I switch drawings in Autocad 2005.  I have a some ideas and some code but nothing substantial yet.

Any help would be greatly appreciated.

:)
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

daron

  • Guest
Xref Update Reactor
« Reply #1 on: September 01, 2004, 08:28:00 AM »
Doesn't autocad 2005 have that ability built-in? I'm sure I was able to do that with 2004.

Columbia

  • Guest
Xref Update Reactor
« Reply #2 on: September 07, 2004, 01:37:50 PM »
Well, what Acad2005 and 2004 had was a reactor that  let you know when a drawing was updated so that you could Reload the XREF if you wanted to - manually.  There was and is no automatic way to do it without using an event or reactor.  At least that I'm aware of.

Now as for code, I wish I could help you SPDcad but I'm fresh out of ideas for the moment.  I'm stuck in the abyssmal land of drawing revisions.  AGGGHHHH!!!  It's almost as bad as Se7en's plight in MicroStation.  Well maybe not that bad.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Xref Update Reactor
« Reply #3 on: September 07, 2004, 02:12:19 PM »
Quote from: Columbia
... It's almost as bad as Se7en's plight in MicroStation.  Well maybe not that bad.


heh! Man, you have NO idea! But here is something that might give you an idea.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Xref Update Reactor
« Reply #4 on: September 08, 2004, 08:27:28 AM »
Yes Columbia, it will let you know that xref's have been updated. Then, you could always throw this little diddy out. It's not reactor driven, but it's a start to not doing it quite as manually.
Code: [Select]
;;;===xref reload===;
;;; allows user to select xref to reload or hit enter to reload all xrefs ;
(defun c:xre ()
     (setq cme (getvar "cmdecho"))
     (setvar "cmdecho" 0)
     (setq xref
      (car (entsel
"\nSelect referenced object to reload or <Enter>: "
   ) ;_ end of entsel
      ) ;_ end of car
     ) ;_ end of setq
     (if (= xref nil)
 (progn
      (command ".xref" "reload" "*")
      (princ "\nAll xref's have been reloaded.")
 ) ;_ end of progn
 (progn
      (setq xreload (cdr (assoc 2 (entget xref))))
      (command ".xref" "reload" xreload)
      (princ (strcat "\n" xreload " reloaded."))
 ) ;_ end of progn
     ) ;_ end of if
     (setvar "cmdecho" cme)
     (princ)
)

Columbia

  • Guest
Xref Update Reactor
« Reply #5 on: September 08, 2004, 09:24:23 AM »
And if you're really a mascohist, or is that a lover of Active-X/VLISP, you could do it this way...

Code: [Select]


(vl-load-com)

(defun c:xre (/ cme block xref xreload) ;; localize variables
   (setq cme (getvar "cmdecho"))
   (setvar "cmdecho" 0)
   (setq xref
        (car (entsel
        "\nSelect referenced object to reload or <Enter>: "
        ) ;_ end of entsel
        ) ;_ end of car
   ) ;_ end of setq
   (if (not xref) ;; <-- changed to use a NOT = more efficient - I think.
     (progn
       (vlax-for block (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-ACAD-Object)))
         (if
            (and
              (vlax-property-available-p block"Path")
              (/= (vlax-get-property block "Path") "")
            )
            (vlax-invoke-method block 'Reload)
          )
        );_ end vlax-for
        (princ "\nAll xref's have been reloaded.")
     ) ;_ end of progn
     (progn
        (setq xreload (cdr (assoc 2 (entget xref))))
        (Reload_Xref xreload) ;;<-- Use of Active-X function below.
        (princ (strcat "\n" xreload " reloaded."))
     ) ;_ end of progn
   ) ;_ end of if
   (setvar "cmdecho" cme)
   (princ)
)

;;; an Active-X function to reload an XREF with a given name.
(defun Reload_Xref (name / blocks xref)
  (setq blocks (vla-get-Blocks
                      (vla-get-ActiveDocument (vlax-get-ACAD-Object))
                    )
  )
  (if
    (not
      (vl-catch-all-error-p
        (setq xref
          (vl-catch-all-apply 'vla-item (list blocks name))
        )
      )
    )
    (if
      (and
        (vlax-property-available-p xref "Path")
        (/= (vlax-get-property xref "Path") "")
      )
      (vlax-invoke-method xref 'Reload)
    )
    (vl-catch-all-error-message xref)
  )
)