R2005: I have made 2 reactors persistent in one drawing using the vlr-pers function. When I open the drawing and use the vlr-reactors function, I get a list of the reactors in the drawing: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) But when I re-open the drawing either once or several times, it appears that the number of reactors increases: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) What do I need to know about this? I do not execute any lisps or do anything to fire the reactors. The only lisps I am loading are the call backs for the reactors: Code: (defun set-xyz (reactor-object parameter-list) (if (and Pnt (vlax-write-enabled-p AttObj) ) (vla-put-TextString AttObj Pnt) ) ) ;-----; (defun get-xyz (notifier-object reactor-object parameter-list) (vl-load-com) (cond ((and (= (vlr-current-reaction-name) ':VLR-modified) (vlax-property-available-p notifier-object "InsertionPoint" t) (vlax-read-enabled-p notifier-object) (not (vlax-erased-p notifier-object)) ) (setq AttObj (car (vlax-safearray->list (variant-value (vla-GetAttributes notifier-object)))) Pnt (vlax-safearray->list (variant-value (vla-get-InsertionPoint notifier-object))) Pnt (vl-princ-to-string Pnt) ) ) ;end list. ) ;end cond. ) This is the lisp that I create the reactors with (only once in the original drawing): Code: ;-----; (defun Coord_Display () (vl-load-com) (setvar "pdmode" 34) (setq *acad* (vlax-get-acad-object) *acad_doc* (vla-get-activedocument *acad*) *mspace* (vla-get-modelspace *acad_doc*) ) (if (vlr-reactors :vlr-object-reactor) (vlr-remove-all) ) ;---; (if (and (setq BlkObj (vlax-ename->vla-object (car (entsel "\nSelect block: <pick> "))) ) (eq (vla-get-ObjectName BlkObj) "AcDbBlockReference") (eq (vla-get-HasAttributes BlkObj) :vlax-true) ) (progn (setq AttObj (car (vlax-safearray->list (variant-value (vla-GetAttributes BlkObj)))) ) (setq BlkReactor (vlr-object-reactor (list BlkObj) nil '((:vlr-modified . get-xyz))) CmdReactor (vlr-command-reactor nil '((:vlr-commandEnded . set-xyz))) ) (vlr-pers BlkReactor) (vlr-pers CmdReactor) ) ;progn ) ;end if. (princ) ) TIA Bill
the way you are using/implementing the reactors is one for each time you make a selection of a block. why did you not follow my code sample? anyway.... did you saw that I only use one editor reactor? for the command ended event? but for the form you are following you will require two reactors for each block..... there are other forms to use for each object one reactor only and avoid the multiplicity..... how many blocks where on your test?
Luis, make a selection of a block.<<< I am only picking the block once to create the reactors. Then I saved the drawing. Long story. 8^) use one editor reactor? for the command ended event?<<< I think I am using only one command and one object reactor also. block..... there are other forms to use for each object one reactor only and avoid the multiplicity..... I do not understand, I am only creating one object and one command reactor. I am only executing the Coord_Display.lsp once on the block and saving the drawing. Then I am only moving the block when I re-open the drawing. Only the call backs are being loaded at startup. how many blocks where on your test? I rechecked the drawing and found that I had too many reactors so I re-created the drawing to have only one command reactor and one object reactor. But still I get what looks like a lot of reactors listed with the vlr-reactors function. This is what I see when I use the vlr-pers-list function: Command: (vlr-pers-list) (#<VLR-Command-Reactor> #<VLR-Object-Reactor>) Which seems to be fine. But when I open and close the drawing several times and use the vlr-reactors function, I get this: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) But the vlr-pers-list still is right. Command: (vlr-pers-list) (#<VLR-Command-Reactor> #<VLR-Object-Reactor>) Just wondered if this is normal. Bill
Bill, when you use persistent reactors you must remove the reactor from the list of persistent reactors, the reason you are seeing to many reactors after calling (vlr-reactors) is because of that. you must be using the (coord_display) several times and deleted the blocks, that won't remove the reactors from the list.... check right after you re-open the drawing if you read this: Opening an AutoCAD 2004 format file. Regenerating model. ; warning:erased VLA-object restored to NIL now, save the drawing.... this will (sometimes) redo the list of persistent reactors, that's why when you call (vlr-pers-list) is telling was updated.... also see the in-line comments.... the above you don't needed... you are removing the reactors every time you call the command, you don't have to do this... this reactor call must be created once.... using (if (not reactor_editor) (progn (setq reactor_editor ......) (vlr-pers reactor_editor))) with that, you only have a single editor reactor to handle the command ended event... hth
when you use persistent reactors you must remove the reactor from the list of persistent reactors, the reason you are seeing to many reactors after calling (vlr-reactors) is because of that. you must be using the (coord_display) several times and deleted the blocks, that won't remove the reactors from the list....<<< As I said before; I am using coord_display only once at the creation of the drawing. I use it on only one block. Then I save the drawing. I do not use coord_display any more. I do nojt erase or delete the block. If I check the drawing I get: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor>)) Command: (vlr-pers-list) (#<VLR-Command-Reactor> #<VLR-Object-Reactor>) But then if I re-open the drawing agian I get: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) Command: (vlr-pers-list) (#<VLR-Command-Reactor> #<VLR-Object-Reactor>) If I re-open the drawing a few more times I get: (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) Command: (vlr-pers-list) (#<VLR-Command-Reactor> #<VLR-Object-Reactor>) Maybe I need (vlr-remove-all) somewhere? the above you don't needed..<<< Thanks I figured that out. you are removing the reactors every time you call the command, you don't have to do this... Thanks, I see that was from another program. Removed it. this reactor call must be created once.... (if (not reactor_editor) (progn (setq reactor_editor ......) (vlr-pers reactor_editor))) with that, you only have a single editor reactor to handle the command ended event... This is what I do not understand, I am only creating the command reactor once using coord_display. ????? After that I am only opening the drawing and checking it with vlr-reactors and vlr-pers-list. I am not executing coord_display any more in the drawing. Only the call backs are being loaded. ??? Bill
the drawing. I use it on only one block. Then I save the drawing. well..... what else can I said?..... I tested here... and only got two reactors... vlr-remove-all won't remove them from the pers-list.... are you sure, the other reactors are something else....? what other reactor routines you run? I am just commenting the way to implement just a single reactor once, I know you are doing tests.... and I understand what you are saying....
...are you sure, the other reactors are something else....? <<< I'm not sure what all the reactors are in the list that I'm gettting from the vlr-reactors function are. you run? None. you are doing tests.... and I understand what you are saying.... <<< Oh...Okay thanks... :^) Sorry for any trouble. But I am learning Bill
no problema.... at all.... post the drawing please I want to make sure.... and run your code as you posted.... what do you have in the startup stuff?
I don't get to many reactors... just this: Command: m MOVE Select objects: Specify opposite corner: 1 found Select objects: Specify base point or displacement: Specify second point of displacement or <use first point as displacement>: Command: (vlr-reactors) (VLR-Object-Reactor #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor>)) just two.... no idea what is going on over there......
Bill, is there a chance that you inspect the last item on the list of reactors and verify if match with the first item? what do you read? are the owners the same?
just two.... no idea what is going on over there...... <<< I get just 2 using vlr-reators also until I re-open the drawing from the MRU list. Then the list builds. I'm not sure how to inspect this list as there are no variables with the object or name of the reactor once the drawing is re-opened. I'm new to persistent reactors. How do I find the reactor object or name? Bill
MRU list. Then the list builds. hmm.... what happen if you open the drawing normally? object or name of the reactor once the drawing is re-opened. open vlide editor go to the lisp window type: _$ (vlr-reactors) _$ (VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor> #<VLR-Object-Reactor>) VLR-Command-Reactor #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor> #<VLR-Command-Reactor>)) select the last item on the object reactor list by double-click and right-click and select inspect, what do you get? also do the same on the first item of the list and compare both reactors.... the owner is the same?
hmm.... what happen if you open the drawing normally?<<< Same thing. Sometimes the list shrinks a little. right-click and select inspect, what do you get?<<< nil the owner is the same?<<< Got nil on the first one too. Bill
the owner is the first item on the data you got from the reactor..... or inspect does not return anything? well Bill, I think I cover all the possible bases I know.... might be someone else... knows what is going on..... Luis.
Wait, I was highlighting too much of the string... The object reactor shows: #<SUBR@05cb38e8 VLR-Object-Reactor for both the first & last items. and the command reactor shows: #<SUB@05cb3a00 VLR-Command-Reactor on both first & last. Bill
well Bill, I think I cover all the possible bases I know.... might be someone else... knows what is going on.....<<< I was just worried that there were multiple firings of the reactors when I saw the long list from (vlr-reactors). Since they all read nil, must be some sort of bug.... Thanks for all the help! Bill
ok... also, here is a function I use to check if an object is already part of a reactor, with this you can avoid multiple reactors on a single object. (defun partof (obj / obj_reactors) (if (setq obj_reactors (cdar (vlr-reactors :vlr-object-reactor))) (vl-some (function (lambda (n) (numberp n))) (mapcar (function (lambda (r) (vl-position obj (vlr-owners r)))) obj_reactors)))) have fun. saw the long list from (vlr-reactors).