Author Topic: Reactor Question (Replacement for 'command')?  (Read 1827 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Reactor Question (Replacement for 'command')?
« on: October 09, 2007, 10:56:23 AM »
I know that you can't use the COMMAND call in a rector, so my question is this: Is there any alternative?

Basically what I want to do is purge a drawing (but not just the regular purge command).  I want to be able to run a LSP prior to saving a drawing.  So how can I call the command if I can't use COMMAND?

LE

  • Guest
Re: Reactor Question (Replacement for 'command')?
« Reply #1 on: October 09, 2007, 11:09:31 AM »
Vla-SendCommand() can be a replace.

Below, it is a code I wrote for a friend Walt Engle APR-04-2006, see if helps.
Code: [Select]
;; save this on your personal.mnl, that is what I normally do...

(vl-load-com)

;; get the active document
(if (not this_dwg)
  (setq this_dwg (vla-get-activedocument (vlax-get-acad-object))))

;; callback function for the beginclose event
(defun beginclose  (reactor params)

  ;; purge all - here do your mojo
  (vla-purgeall this_dwg)

  ;; zoom extents - do more mojo
  (vla-zoomextents acad_obj)

  ;; re-save to keep the last extents - save the mojo
  (vla-save this_dwg))

;; make the reactor once
;; and using the beginclose event
;; and notify the reactor to the active document
(if (not dwg_reactor)
  (setq dwg_reactor
(vlr-pers
   (vlr-set-notification
     (vlr-dwg-reactor
       "drawing reactor"
       '((:vlr-beginclose
  .
  beginclose)))
     'active-document-only))))

(princ)

ASMI

  • Guest
Re: Reactor Question (Replacement for 'command')?
« Reply #2 on: October 09, 2007, 11:20:26 AM »
If you use :vlr-beginClose event and vla-PurgeAll method you must to use vla-Save method. Maybe you don't want to save drawing before closing? It seems to :vlr-beginSave event is better.

Code: [Select]
(defun Save_Reactor_Create()
  (vl-load-com)
  (if
    (not clr:CloseReactor)
    (setq clr:CloseReactor
   (vlr-Editor-Reactor nil
     '((:vlr-beginSave  . PurgeBeforeClose))))
    ); end if
  (princ)
  ); end of Save_Reactor_Create

(Save_Reactor_Create)

(defun PurgeBeforeSave(reac args)
  (setq actDoc
(vla-get-ActiveDocument
   (vlax-get-acad-object)))
  (repeat 3(vla-Purgeall actDoc))
  (princ)
  ); end of PurgeBeforeSave