cadman6735 Posted June 16, 2010 Share Posted June 16, 2010 I am starting to learning AutoLisp and I am a little confussed about what is the difference between: AutoLisp & Visual Lisp Seems to me that Visual Lisp gives you an editor to write your macro in, with all the bells and whistles. What else makes Visual Lisp better? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 16, 2010 Share Posted June 16, 2010 The Editor was introduced with Visual LISP, however you can still use it to write Vanilla AutoLISP. Visual LISP gives you more access to the AutoCAD Object Model and is of the same nature of VBA, with some enhanced functions. The vl*/vla*/vlax*/vlr* functions are all part of Visual LISP (an extension of Vanilla LISP) which uses the ActiveX COM Model. The vla-* functions have equivalent VBA properties and methods, and the arguments and their order all apply. However, the vlax*/vl* function don't have VBA equivalents The vlr* functions are for manipulating reactors in Visual LISP, similar to VBA Events, but their syntax and usage differ. The help on these functions is all contained in the Visual LISP Editor help files, the help for the vla-* functions is written for VBA, but everything still applies to Visual LISP. There is not much you cannot learn from the help files. Lee Quote Link to comment Share on other sites More sharing options...
cadman6735 Posted June 16, 2010 Author Share Posted June 16, 2010 The Editor was introduced with Visual LISP, however you can still use it to write Vanilla AutoLISP. Visual LISP gives you more access to the AutoCAD Object Model and is of the same nature of VBA, with some enhanced functions. The vl*/vla*/vlax*/vlr* functions are all part of Visual LISP (an extension of Vanilla LISP) which uses the ActiveX COM Model. The vla-* functions have equivalent VBA properties and methods, and the arguments and their order all apply. However, the vlax*/vl* function don't have VBA equivalents The vlr* functions are for manipulating reactors in Visual LISP, similar to VBA Events, but their syntax and usage differ. The help on these functions is all contained in the Visual LISP Editor help files, the help for the vla-* functions is written for VBA, but everything still applies to Visual LISP. There is not much you cannot learn from the help files. Lee Thanks for the quick reply: Yes, I am all about the help files and web forums but some times I can't see past the technical stuff to get a straight forward human opinion from an everyday user's point of view. You confirmed my thoughts and I thank you Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 16, 2010 Share Posted June 16, 2010 You're quite welcome Quote Link to comment Share on other sites More sharing options...
CHLUCFENG Posted June 17, 2010 Share Posted June 17, 2010 Since the topic is on the board, can anyone simplify what a reactor is? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 A reactor is a VLA-Object that will evaluate a call-back function when triggered. It can be triggered by perhaps command calls, mouse clicks, or changes to the drawing/system variable, etc depending upon what type of reactor you use. http://www.afralisp.net/archive/vl/reactors1.htm As a fun example, try this: (defun c:ExampleReactor nil ;; © Lee Mac ~ 17.06.10 (vl-load-com) (setq *doc (vla-get-ActiveDocument (vlax-get-acad-object))) ( (lambda ( data foo / react ) (if (setq react (vl-some (function (lambda ( reactor ) (if (eq data (vlr-data reactor)) reactor) ) ) (cdar (vlr-reactors :vlr-miscellaneous-reactor) ) ) ) (if (vlr-added-p react) (vlr-remove react) (vlr-add react) ) (setq react (vlr-miscellaneous-reactor data (list (cons :vlr-pickfirstmodified foo) ) ) ) ) (princ (if (vlr-added-p react) "\n** Reactor Activated **" "\n** Reactor Deactivated **" ) ) react ) "Example-Reactor" 'Example-Callback ) (princ) ) (defun Example-Callback ( reactor args / assoc++ lst->str ss l ) ;; © Lee Mac ~ 17.06.10 (vl-load-com) (defun assoc++ ( key lst ) ( (lambda ( ass ) (if ass (subst (list key (1+ (cadr ass))) ass lst) (cons (list key 1) lst) ) ) (assoc key lst) ) ) (defun lst->str ( lst del ) (if (cdr lst) (strcat (car lst) del (lst->str (cdr lst) del)) (car lst) ) ) (if (not (zerop (vla-get-Count (setq ss (vla-get-PickFirstSelectionSet *doc) ) ) ) ) (progn (vlax-for obj ss (setq l (assoc++ (cdr (assoc 0 (entget (vlax-vla-object->ename obj) ) ) ) l ) ) ) (vla-delete ss) (if l (acet-ui-status (lst->str (mapcar '(lambda ( x ) (strcat (itoa (cadr x)) " " (if (< 1 (cadr x)) (strcat (car x) "S") (car x) ) ) ) l ) ", " ) "You Have Selected" ) ) ) (acet-ui-status) ) (princ) ) Type ExampleReactor to activate the reactor (you only need to type this once), then select something... To deactivate the reactor, type ExampleReactor again... (Requires Express Tools - its a shame acet-ui-status only allows three lines...) Quote Link to comment Share on other sites More sharing options...
CHLUCFENG Posted June 17, 2010 Share Posted June 17, 2010 Neat example and excellent link! I shall read on... Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 You're very welcome Quote Link to comment Share on other sites More sharing options...
Se7en Posted June 17, 2010 Share Posted June 17, 2010 Im not sure what "acet-ui-status" is/does but there are rules to reactors like: Do not use command, setvar, etc. (I can not remember them so you will have to research them yourselves) so i would avoid using any third party libraries if i were you. Roll your own so that you can better maintain them -i.e. you never know when that bit of code could change on you and you will then be faced with a daunting task of finding the bug. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 I was previously using 'alert' in this example, but then I remembered Andrea's recent code over at theSwamp using acet-ui-status, so chose that instead Quote Link to comment Share on other sites More sharing options...
cadman6735 Posted July 12, 2010 Author Share Posted July 12, 2010 Still trying to get it thru my head... Lee, you have introduced me to: vla vlax vlr but what are vl-functions? how do they differ from vla-functions? Quote Link to comment Share on other sites More sharing options...
gile Posted July 13, 2010 Share Posted July 13, 2010 Hi, vl-* functions are 'new' AutoLISP functions which came with Visual LISP. They do not use the COM ActiveX interface (no need to invoke vl-load-com). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 13, 2010 Share Posted July 13, 2010 Thanks Gile Quote Link to comment Share on other sites More sharing options...
cadman6735 Posted July 13, 2010 Author Share Posted July 13, 2010 So, for my own sanity, I am of the opinion that I really should not worry too much about weather it is a vanilla lisp, vl*, vla*, vlax* or a vlr* and just look at them as commands (functions) with different prefix's. They all have there place that provide their specific tools for programming. -Vanilla Lisp -vl* new extended commands (functions) introduced in visual lisp -vla* VBA equivalent -vlax* (not sure) but my opinion right now is ActiveARX or C++ equivalent? -vlr* Reactors or Event equivalent It seems to me they do access different levels of programming by providing either -new tools -combination of tools for short cut coding -different accessability to either ACAD or to access other applications Sorry for being hung up on this Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 13, 2010 Share Posted July 13, 2010 I agree, just think of them as a new set of tools for you to utilise - when using them, just remember that the vla* etc functions (those that use ActiveX) need to be loaded first using (vl-load-com). Also, you will find that the help for the vla* functions is written for VBA, but the order of the arguments and their data type is the same for VL, so it shouldn't be too hard to make the connection. Lee Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.