Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
hypersonic
Posts: 227
Registered: ‎12-27-2007
Message 1 of 6 (207 Views)
Accepted Solution

Is it possible to make the left mouse click initiate a zoom window?

207 Views, 5 Replies
01-01-2012 06:17 AM

i.e. I still want it to have its normal behavior while in a command, but when not in a command it still enters the selection mode, which does not help me much, but if it would enter a zoom window command, it might be a more useful command.

Does anyone have any thoughts on how to do this?

 

Thank you and Happy New Year!!


hypersonic wrote:

i.e. I still want it to have its normal behavior while in a command, but when not in a command it still enters the selection mode, which does not help me much, but if it would enter a zoom window command, it might be a more useful command.


 

This is the closest I believe you could get without resorting to a possible .NET solution:

 

(vl-load-com)
(if (null *mouse-reactor*)
(setq *mouse-reactor* (vlr-mouse-reactor nil '((:vlr-begindoubleclick . zoomwindow))))
)
(if (null *editor-reactor*)
(setq *editor-reactor* (vlr-editor-reactor nil '((:vlr-beginclose . releaseobjects))))
)
(defun zoomwindow ( reactor params / p2 )
(if
(and
(zerop (getvar 'CMDACTIVE))
(setq p1 (car params))
(setq p2 (getcorner "\nSpecify Opposite Corner: " (trans p1 0 1)))
)
(progn
(setq *app* (cond (*app*) ((vlax-get-acad-object)))
*wsh* (cond (*wsh*) ((vlax-create-object "WScript.Shell")))
)
(vlax-invoke *app* 'zoomwindow p1 (trans p2 1 0))
(vlax-invoke *wsh* 'sendkeys "{ESC}")
)
)
(princ)
)
(defun releaseobjects ( reactor params )
(if (and *wsh* (eq 'VLA-OBJECT (type *wsh*)) (not (vlax-object-released-p *wsh*)))
(vl-catch-all-apply 'vlax-release-object (list *wsh*))
)
(if (and *mouse-reactor* (eq 'VLA-OBJECT (type *mouse-reactor*)))
(vlr-remove *mouse-reactor*)
)
(vlr-remove reactor)
(princ)
)
(princ)

 

The above uses a Mouse Reactor triggered when the user Double-Clicks, and will subsequently prompt for another point to use for a ZoomWindow operation.

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 2 of 6 (198 Views)

Re: Is it possible to make the left mouse click initiate a zoom window?

01-01-2012 09:26 AM in reply to: hypersonic

hypersonic wrote:

i.e. I still want it to have its normal behavior while in a command, but when not in a command it still enters the selection mode, which does not help me much, but if it would enter a zoom window command, it might be a more useful command.


 

This is the closest I believe you could get without resorting to a possible .NET solution:

 

(vl-load-com)
(if (null *mouse-reactor*)
    (setq *mouse-reactor* (vlr-mouse-reactor nil '((:vlr-begindoubleclick . zoomwindow))))
)
(if (null *editor-reactor*)
    (setq *editor-reactor* (vlr-editor-reactor nil '((:vlr-beginclose . releaseobjects))))
)
(defun zoomwindow ( reactor params / p2 )
    (if
        (and
            (zerop (getvar 'CMDACTIVE))
            (setq p1 (car params))
            (setq p2 (getcorner "\nSpecify Opposite Corner: " (trans p1 0 1)))
        )
        (progn
            (setq *app* (cond (*app*) ((vlax-get-acad-object)))
                  *wsh* (cond (*wsh*) ((vlax-create-object "WScript.Shell")))
            )
            (vlax-invoke *app* 'zoomwindow p1 (trans p2 1 0))
            (vlax-invoke *wsh* 'sendkeys "{ESC}")
        )
    )
    (princ)
)

(defun releaseobjects ( reactor params )
    (if (and *wsh* (eq 'VLA-OBJECT (type *wsh*)) (not (vlax-object-released-p *wsh*)))
        (vl-catch-all-apply 'vlax-release-object (list *wsh*))
    )
    (if (and *mouse-reactor* (eq 'VLA-OBJECT (type *mouse-reactor*)))
        (vlr-remove *mouse-reactor*)
    )
    (vlr-remove reactor)
    (princ)
)
(princ)

 

The above uses a Mouse Reactor triggered when the user Double-Clicks, and will subsequently prompt for another point to use for a ZoomWindow operation.

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Mentor
hypersonic
Posts: 227
Registered: ‎12-27-2007
Message 3 of 6 (196 Views)

Re: Is it possible to make the left mouse click initiate a zoom window?

01-01-2012 10:00 AM in reply to: hypersonic

That is awesome Lee, can the same thing be done for the right mouse button i.e.. make a double click do a zoom previous?

Thanks :smileyvery-happy:

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 4 of 6 (189 Views)

Re: Is it possible to make the left mouse click initiate a zoom window?

01-01-2012 10:47 AM in reply to: hypersonic

hypersonic wrote:

can the same thing be done for the right mouse button i.e.. make a double click do a zoom previous?


No since the Mouse Reactor offers only two Events: BeginDoubleClick and BeginRightClick, so callback functions can only be evaluated following these two actions.

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Mentor
hypersonic
Posts: 227
Registered: ‎12-27-2007
Message 5 of 6 (185 Views)

Re: Is it possible to make the left mouse click initiate a zoom window?

01-01-2012 11:01 AM in reply to: Lee_Mac

Ah, o.k. thank you very much for your help!

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 6 of 6 (180 Views)

Re: Is it possible to make the left mouse click initiate a zoom window?

01-01-2012 12:02 PM in reply to: hypersonic

You're welcome hypersonic :smileyhappy:

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.