Author Topic: VIEWCTR reactor  (Read 12381 times)

0 Members and 2 Guests are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
VIEWCTR reactor
« on: April 12, 2012, 11:00:52 AM »
hi all,..

Anyone have an idea on how to manage reactor when the DBMOD variable has changed ?

thanks.

Oops !....I mean VIEWCTR (read-Only) variable...
(Topic subject changed)

to much in my head,..sorry.
« Last Edit: April 12, 2012, 11:30:57 AM by Andrea »
Keep smile...

BlackBox

  • King Gator
  • Posts: 3770
Re: DBMOD reactor
« Reply #1 on: April 12, 2012, 11:04:45 AM »
Consider using vlr-Sysvar-Reactor function.  :-)
"How we think determines what we do, and what we do determines what we get."

Andrea

  • Water Moccasin
  • Posts: 2372
Re: VIEWCTR reactor
« Reply #2 on: April 12, 2012, 11:31:58 AM »
Post subject renammed..
Keep smile...

BlackBox

  • King Gator
  • Posts: 3770
Re: VIEWCTR reactor
« Reply #3 on: April 12, 2012, 12:02:09 PM »
A Sysvar Reactor *should* still do the job, methinks... Pseudo code:

Code - Auto/Visual Lisp: [Select]
  1. (setq *foo_reactor* (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . Foo_Callback))))
  2.  
  3. (defun foo_Callback  (rea lst / newviewctr)
  4.   (if (and
  5.         (= "CVPORT" (car lst))
  6.         (= T (cadr lst))
  7.         (/= (setq newviewctr (getvar 'viewctr))
  8.             (cond (*viewctr*)
  9.                   ((setq *viewctr* (getvar 'viewctr))))))
  10.     (progn
  11.       (setq *viewctr* newviewctr)
  12.       (princ "\n\"VIEWCTR\" has changed: ")
  13.       (princ newviewctr)
  14.       (terpri))
  15.     )
  16.   )
  17.  

HTH
"How we think determines what we do, and what we do determines what we get."

Andrea

  • Water Moccasin
  • Posts: 2372
Re: VIEWCTR reactor
« Reply #4 on: April 12, 2012, 02:13:18 PM »
Thank you RanderMan....

But It seem that it is not working...

I also ommitted to mentionned that I'm trying to use sysVarwillChange against sysVarChanged
Code: [Select]
(defun CheckTheVIEWCTRvar (Rea Arg)
  (alert (vl-princ-to-string (list rea Arg)))
  (princ)
)


(setq MyVIEWCTRreactor
       (VLR-SysVar-Reactor
nil
'((:VLR-sysVarwillChange . CheckTheVIEWCTRvar))
       )
)


so any idea what i'm doing wrong ?
Keep smile...

Pepe

  • Newt
  • Posts: 85
Re: VIEWCTR reactor
« Reply #5 on: April 12, 2012, 05:37:56 PM »
Hi Andrea,

I had the same problem some of years ago, not exactly with VIEWCTR, but it was something concerning to zooming.

As far as I know (deduced at that time, in a test and error way with many variables), not all Autocad's variables are managed by VLR-SYSVAR-REACTOR. I suppose VIEWCTR is among them... :oops: .

Regards.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: VIEWCTR reactor
« Reply #6 on: April 13, 2012, 10:27:07 AM »
Hi Andrea,

I had the same problem some of years ago, not exactly with VIEWCTR, but it was something concerning to zooming.

As far as I know (deduced at that time, in a test and error way with many variables), not all Autocad's variables are managed by VLR-SYSVAR-REACTOR. I suppose VIEWCTR is among them... :oops: .

Regards.

Thank you Pepe..
Well,....you'r right ! some variables don't seem to work.
So I've to re-think my concept and found a workaround.

the goal of my idea is that I need to detect when user PAN or ZOOM the drawing with the wheel mouse.
So I've thinke to use DBMOD and reset a LISP variable,...then,...use the VIEWCTR,...but no succes..
(at this moment)

so If any of you got any idea who can help me with this..
It will be very appreciated.

thank you. :)
Keep smile...

BlackBox

  • King Gator
  • Posts: 3770
Re: VIEWCTR reactor
« Reply #7 on: April 13, 2012, 11:12:06 AM »
...

the goal of my idea is that I need to detect when user PAN or ZOOM the drawing with the wheel mouse.

Unfortunately, vlr-Mouse-Reactor does not expose middle button (wheel) events at the moment, so FWIW here is a simple command reactor for the two commands you specified:

Code - Auto/Visual Lisp: [Select]
  1. ;;;--------------------------------------------------------------------;
  2. ;;; Start reactor function:
  3. (defun Reactor:Start ()
  4.   (cond (*Reactor_Command*)
  5.       ((setq *Reactor_Command*
  6.               (vlr-command-reactor
  7.                 nil
  8.                 '((:vlr-commandCancelled . Callback:CommandEnded)
  9.                   (:vlr-commandEnded . Callback:CommandEnded)
  10.                   (:vlr-commandFailed . Callback:CommandEnded)
  11.                   (:vlr-commandwillstart . Callback:CommandStarted))))))
  12.   (princ))
  13. ;;;--------------------------------------------------------------------;
  14. ;;; CommandStarted callback function:
  15. (defun Callback:CommandStarted  (rea cmd / cmdName)
  16.   (print (car cmd))
  17.   (cond
  18.     ((wcmatch (setq cmdName (strcase (car cmd))) "*PAN,*ZOOM")          ; Pan, or zoom
  19.      (setq *curViewctr* (getvar 'viewctr)))
  20.    
  21.     ;;((wcmatch cmdName "*OtherCommands")                                 ; <- Other commands
  22.      ;;(setq *curViewctr* (getvar 'viewctr)))
  23.     )
  24.   (princ))
  25. ;;;--------------------------------------------------------------------;
  26. ;;; CommandEnded callback function:
  27. (defun Callback:CommandEnded  (rea cmd / cmdName viewctr)
  28.   (cond
  29.     ((wcmatch (setq cmdName (strcase (car cmd))) "*PAN,*ZOOM")          ; Pan, or zoom
  30.      (if (/= *curViewctr* (setq viewctr (getvar 'viewctr)))
  31.        (progn
  32.          (terpri)
  33.          (prompt "\n** \"VIEWCTR\" has changed from: ")
  34.          (princ *curViewctr*)
  35.          (princ ", to: ")
  36.          (princ viewctr)
  37.          (terpri))))        
  38.    
  39.     ;;((wcmatch cmdName "*OtherCommands")                                 ; <- Other commands
  40.      ;;(setq *curViewctr* (getvar 'viewctr)))
  41.     )
  42.   (princ))
  43. ;;;--------------------------------------------------------------------;
  44. ;;; Stop reactor function:
  45. (defun c:STOPR  ()
  46.   (vlr-remove *Reactor_Command*)
  47.   (terpri)
  48.   (prompt "\n** Reactor stopped ** ")
  49.   (princ))
  50. ;;;--------------------------------------------------------------------;
  51. ;;; Autorun reactor:start for titled drawings (not drawing1.dwg)
  52. (if (= 1 (getvar 'dwgtitled))
  53.   (Reactor:Start))
  54.  

I'll do some digging in .NET to try and see what all is involved in order to develop custom reactor events (i.e., middle mouse button)... Just a thought. *geek*
"How we think determines what we do, and what we do determines what we get."

Ketxu

  • Newt
  • Posts: 109
Re: VIEWCTR reactor
« Reply #8 on: April 13, 2012, 11:36:52 AM »
I think sysvar reactors not working with READ ONLY variables ^^

Andrea

  • Water Moccasin
  • Posts: 2372
Re: VIEWCTR reactor
« Reply #9 on: April 13, 2012, 12:23:37 PM »
Thank you RendreMan..

It's work when using PAN or ZOOM command...
but it isn't realy what I need..

the wheel mouse button and scrooling do not call these AutoCAD command.
so maybe looking for an event in VBscript ?  hhmm !?? :roll:
Keep smile...

BlackBox

  • King Gator
  • Posts: 3770
Re: VIEWCTR reactor
« Reply #10 on: April 13, 2012, 01:01:13 PM »
I think sysvar reactors not working with READ ONLY variables ^^

That's why I posted a Command Reactor ^^

:lol:

Thank you RendreMan..

It's work when using PAN or ZOOM command...
but it isn't realy what I need..

the wheel mouse button and scrooling do not call these AutoCAD command.
so maybe looking for an event in VBscript ?  hhmm !?? :roll:


Yeah, I figured as much... I'll see what I can dig up on how one goes about creating custom Events, in an effort to add a :vlr-beginMiddleClick, :vlr-beginMiddleScrollUp, :vlr-beginMiddleScrollDown Events.  :kewl:
"How we think determines what we do, and what we do determines what we get."

VMichl

  • Mosquito
  • Posts: 8
Re: VIEWCTR reactor
« Reply #11 on: April 17, 2012, 04:41:03 PM »
I have tried to find a VIEWCTR reactor in LISP but had to revert to .NET for our DWGsync tool - http://www.cadstudio.cz/en/apps/dwgsync/

Vladimir Michl

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: VIEWCTR reactor
« Reply #12 on: April 18, 2012, 04:38:16 AM »
Yeah, I figured as much... I'll see what I can dig up on how one goes about creating custom Events, in an effort to add a :vlr-beginMiddleClick, :vlr-beginMiddleScrollUp, :vlr-beginMiddleScrollDown Events.  :kewl:
That would be absolutely wonderful, are you trying to do so in Net? Or are you making an ARX for this? My understanding is even in Net you would have to PInvoke a call into the acad.exe to generate a lisp call.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Pepe

  • Newt
  • Posts: 85
Re: VIEWCTR reactor
« Reply #13 on: April 18, 2012, 07:20:06 AM »
Quote
I have tried to find a VIEWCTR reactor in LISP but had to revert to .NET for our DWGsync tool - http://www.cadstudio.cz/en/apps/dwgsync/

Hi,

It's useful to have a 'parallel view' for drawings  ^-^.

Now ¿Could it be possible to write a registrable dll for new types of LISP reactors, such as topic?

Regards.

Xander

  • Guest
Re: VIEWCTR reactor
« Reply #14 on: April 18, 2012, 07:43:26 AM »
I don't see why a managed module couldn't support such a system.

It should be fairly straight forward having a thread idle until a specific event. A mouse wheel reactor could be done via:
  • Lisp command registers a method with the .NET module
  • The .NET module then sits and waits until the event is triggered. I.e. The scroll wheel is used, while the document window is active, and the session is capable of accessing a command.
  • The module could then post each command registered with the specific event to the document session.

Hmm... This is rather interesting, and woudl be really cool with something like: http://www.theswamp.org/index.php?topic=37553.0

Might tinker tomorrow.