Author Topic: vlr-remove how ?  (Read 4583 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
vlr-remove how ?
« on: October 14, 2005, 10:44:08 AM »
how do i use vlr-remove to remove specific reactor ?

I know about vlr-remove-all....
but I don't want to remove all....just a specific reactor command.

any idea ?
Keep smile...

LE

  • Guest
Re: vlr-remove how ?
« Reply #1 on: October 14, 2005, 01:45:18 PM »
If you are using a global variable for your reactor, simple use something like this:

Disable:
Code: [Select]
  (if (and :offset-editor-reactor
   (vlr-added-p :offset-editor-reactor))
    (progn (vlr-remove :offset-editor-reactor)
   (setq :offset-editor-reactor nil)))

Enable:
Code: [Select]
  (if (and :offset-acdb-reactor
   (vlr-added-p :offset-acdb-reactor))
    (progn (vlr-remove :offset-acdb-reactor)
   (setq :offset-acdb-reactor nil)))

HTH

Andrea

  • Water Moccasin
  • Posts: 2372
Re: vlr-remove how ?
« Reply #2 on: October 14, 2005, 02:05:41 PM »
in fact..there is the code..


Code: [Select]
;; ;;
;; LOAD REACTOR ;;
;; ;;
(defun load_Qview_reactor ()
(setq cecolor (getvar "CECOLOR")
        clayer (getvar "CLAYER"))
(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))
(vlr-command-reactor nil '((:vlr-commandFailed . failedCommand)))
)






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun startCommand (calling-reactor startcommandInfo / QVcmds)
  (setq QVcmds (nth 0 startcommandInfo))
  (cond
     
    ((= QVcmds "MVIEW")(progn

(setvar "CLAYER" "DEFPOINTS")
(setvar "CECOLOR" "BYLAYER")
       )
)))






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun endCommand (calling-reactor endcommandInfo / QVcmde)
  (setq QVcmde (nth 0 endcommandInfo))
  (cond
     
    ((= QVcmde "MVIEW")(progn
(setvar "CLAYER" CLAYER)
(setvar "CECOLOR" cecolor)
       )
)))






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun cancelCommand (calling-reactor cancelcommandInfo / QVcmdc)
  (setq QVcmdc (nth 0 cancelcommandInfo))
  (cond
     
    ((= QVcmdc "MVIEW")(progn
(setvar "CLAYER" CLAYER)
(setvar "CECOLOR" cecolor)
       )
)))





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun failedCommand (calling-reactor failedcommandInfo / QVcmdf)
  (setq QVcmdf (nth 0 failedcommandInfo))
  (cond
     
    ((= QVcmdf "MVIEW")(progn
(setvar "CLAYER" CLAYER)
(setvar "CECOLOR" cecolor)
       )
)))

;; ;;
;; Fin du module des réacteurs ;;
;; ;;

so I don't know really how to remove the MVIEW reactor.
any help will be appreciated.

thanks.
Keep smile...

LE

  • Guest
Re: vlr-remove how ?
« Reply #3 on: October 14, 2005, 02:20:42 PM »
Code: [Select]
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))
(vlr-command-reactor nil '((:vlr-commandFailed . failedCommand)))

Ok, first things first:

1. you do not need to have for every event the call of vlr-command-reactor, you simple make a single call and use a list of events calls.... like:

Code: [Select]
(vlr-command-reactor
  nil
  '((:vlr-commandWillStart . startCommand)
    (:vlr-commandEnded . endCommand)
    (:vlr-commandCancelled . cancelCommand)
    (:vlr-commandFailed . failedCommand)))

2. The way you are handling your statement is not a good practice, first the vlr-command-reactor function returns a reactor value, that you can pass into a variable where you can have a control of it, in this case not.

3. The use of NIL argument also in many cases is not good practice, and is worst when someone is in the first tries on reactors, it is better to always pass a different value like a string, where later you can localize it like "My MVIEW reactor made by me!".

4. Read about "VLR-EDITOR-REACTOR", and begin using that instead.

5. Here are some functions that might be useful for you:
Code: [Select]
(defun has-reactor?  (obj)
  (vl-some
    (function (lambda (x) (numberp x)))
    (mapcar (function (lambda (r) (vl-position obj (vlr-owners r))))
    (cdar (vlr-reactors :vlr-object-reactor)))))

(defun what-reactor?  (obj)
  (vl-remove-if-not
    (function (lambda (r)
(if (vl-position obj (vlr-owners r))
  r)))
    (cdar (vlr-reactors :vlr-object-reactor))))

;; (attached-to obj)
;; return a list with the list of reactors or nil
(defun attached-to  (obj)
  (vl-remove
    nil
    (mapcar
      (function
(lambda (reactor-type)
  (vl-remove-if-not
    (function
      (lambda (r)
(cond
  ((and (equal reactor-type :vlr-object-reactor)
(vl-position obj (vlr-owners r)))
   r)
  ((and
     (not (equal reactor-type
:vlr-object-reactor))
     (vl-position obj (vlr-data r)))
   r))))
    (cdar (vlr-reactors reactor-type)))))
      (vlr-types))))
;;; verifies if an object is part of a reactor
;;; note: works only with object reactors type
(defun partOf  (obj / reactors)
  (if (setq reactors (cdar (vlr-reactors :vlr-object-reactor)))
    (vl-some
      (function (lambda (num) (numberp num)))
      (mapcar
(function
  (lambda (reactor) (vl-position obj (vlr-owners reactor))))
reactors))))

;;; obtain a list of matching reactions
;;; (get-match-reaction
;;;     '(:vlr-modified . calloutsym0-poly-modified-reactor)
;;;     :vlr-object-reactor)
(defun get-match-reaction  (reaction reactor_type)
  (vl-remove-if-not
    (function (lambda (reactor)
(vl-position
  reaction
  (vlr-reactions reactor))))
    (cdar (vlr-reactors reactor_type))))

;;; obtain a list of reactions per reactor type
;;; (reactions-perType :vlr-object-reactor)
(defun reactions-perType  (reactor_type)
  (apply
    'append
    (mapcar 'vlr-reactions
    (cdar (vlr-reactors reactor_type)))))

;;; removes an object from the list of owners of an object reactor
(defun remove-obj-from-reactor (obj)
  (foreach reactor  (cdar (vlr-reactors :vlr-object-reactor))
    (vlr-owner-remove reactor obj)))

;;; get all the present reactors
(defun reactors-present ()
  (apply 'append (mapcar 'cdr (vlr-reactors))))

;;; verifies if all the reactors in the list are disabled
(defun are-all-disabled (reactors)
  (vl-every (function (lambda (r) (not (vlr-added-p r))))
    reactors))

;;; enables all reactors in the list
(defun enable-all  (reactors)
  ;; are all disabled?
  (if (and (vl-consp reactors) (are-all-disabled reactors))
    ;; then enables all
    (mapcar 'vlr-add reactors)))

;;; turn a reactor nil
(defun kill-reactor  (reactor)
  ;; only if is a reactor and also is enabled
  (if (isReactor reactor)
    ;;(and (isReactor reactor) (vlr-added-p reactor))
    (progn
      ;; remove the reactor
      (vlr-remove reactor)
      ;; turn it nil or' released
      (setq reactor nil))))

;;; set notification for the reactor in his own protected namespace
(defun set-notification (reactor)
  ;; before the notification make sure is a reactor and is enabled
  (if (and (isReactor reactor) (vlr-added-p reactor))
    ;; now do the notification just in the current active document
    (vlr-set-notification
      reactor
      'active-document-only)))


Have fun!


Andrea

  • Water Moccasin
  • Posts: 2372
Re: vlr-remove how ?
« Reply #4 on: October 14, 2005, 02:49:41 PM »
wow... :?

a lot of work to do...
and a lot of stuff to lurn..

thanks LE...i'll try to make something intelligent.. :kewl:
Keep smile...

LE

  • Guest
Re: vlr-remove how ?
« Reply #5 on: October 14, 2005, 02:55:41 PM »
wow... :?

a lot of work to do...
and a lot of stuff to lurn..

thanks LE...i'll try to make something intelligent.. :kewl:

 :-)

I have more about object reactors on my site.... have a look here:

http://www.theswamp.org/forum/index.php?topic=7250.0

Crank

  • Water Moccasin
  • Posts: 1503
Re: vlr-remove how ?
« Reply #6 on: October 15, 2005, 05:26:06 AM »
4. Read about "VLR-EDITOR-REACTOR", and begin using that instead.
Beginning with AutoCAD 2000, the broad class of Editor reactors is broken down into more specific reactor types. The :VLR-Editor-Reactor type is retained for backward-compatibility.

Vault Professional 2023     +     AEC Collection

LE

  • Guest
Re: vlr-remove how ?
« Reply #7 on: October 15, 2005, 11:34:42 AM »
4. Read about "VLR-EDITOR-REACTOR", and begin using that instead.
Beginning with AutoCAD 2000, the broad class of Editor reactors is broken down into more specific reactor types. The :VLR-Editor-Reactor type is retained for backward-compatibility.



Thanks....

And where do you get that information ?

Crank

  • Water Moccasin
  • Posts: 1503
Re: vlr-remove how ?
« Reply #8 on: October 16, 2005, 07:14:52 AM »
I'm studying reactors, so I did read it some days ago in the help file:
Quote
The :VLR-Editor-Reactor type is retained for backward-compatibility, but any new Editor reactors introduced with AutoCAD 2000 cannot be referenced through :VLR-Editor-Reactor. The following table lists the types of Editor reactors available beginning with AutoCAD 2000.

:VLR-Command-Reactor
 Provides notification of a command event
 
:VLR-DeepClone-Reactor
 Provides notification of a deep clone event
 
:VLR-DWG-Reactor
 Provides notification of a drawing event (for example, opening or closing a drawing file)
 
:VLR-DXF-Reactor
 Provides notification of an event related to reading or writing of a DXF file
 
:VLR-Insert-Reactor
 Provides notification of an event related to block insertion
 
:VLR-Lisp-Reactor
 Provides notification of an AutoLISP event
 
:VLR-Miscellaneous-Reactor
 Does not fall under any of the other editor reactor types
 
:VLR-Mouse-Reactor
 Provides notification of a mouse event (for example, a double-click)
 
:VLR-SysVar-Reactor
 Provides notification of a change to a system variable
 
:VLR-Toolbar-Reactor
 Provides notification of a change to the bitmaps in a toolbar
 
:VLR-Undo-Reactor
 Provides notification of an undo event
 
:VLR-Wblock-Reactor
 Provides notification of an event related to writing a block
 
:VLR-Window-Reactor
 Provides notification of an event related to moving or sizing an AutoCAD window
 
:VLR-XREF-Reactor
 Provides notification of an event related to attaching or modifying xrefs

Question: What is a deep clone event?
Vault Professional 2023     +     AEC Collection

LE

  • Guest
Re: vlr-remove how ?
« Reply #9 on: October 16, 2005, 01:02:50 PM »
OK, thanks...

...

Now about your question if you have a chance have a look at the help documents of the objectarx SDK.
« Last Edit: October 19, 2005, 10:13:09 AM by LE »