TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: RAIN CODE on November 02, 2014, 07:16:19 AM

Title: Detect autocad express tools installed
Post by: RAIN CODE on November 02, 2014, 07:16:19 AM
Hi guys,

Just wondering - can autolisp able to detect if AutoCad Express Tools is installed ??

Thanks
Title: Re: Detect autocad express tools installed
Post by: CAB on November 02, 2014, 08:50:47 AM
     ;; Set Express Tools Flag
     (if (vl-catch-all-error-p (vl-catch-all-apply '(lambda()(acet-sys-shift-down))))
       (alert "\n** ExpressTools not loaded. Some Functions May not be Available. **")
       (setq shiftOK T)
     )
Title: Re: Detect autocad express tools installed
Post by: Lee Mac on November 02, 2014, 10:40:45 AM
Something similar:

Code - Auto/Visual Lisp: [Select]
  1. (defun expresstools-p nil
  2.     (or (member "acetutil.arx" (arx))
  3.         (and (findfile "acetutil.arx") (arxload "acetutil.arx" nil))
  4.     )
  5.     (eval
  6.         (list 'defun 'expresstools-p nil
  7.             (not
  8.                 (vl-catch-all-error-p
  9.                     (vl-catch-all-apply
  10.                         (function (lambda nil (acet-sys-shift-down)))
  11.                     )
  12.                 )
  13.             )
  14.         )
  15.     )
  16.     (expresstools-p)
  17. )
Title: Re: Detect autocad express tools installed
Post by: MP on November 02, 2014, 12:07:49 PM
While Lee's expresstools-p is cleverly penned (as usual :)) it captures and subsequently reports a static snapshot of the acet call attempt for the dynamically defined version of self, which sports misleading results if the ET tools library is unloaded (arxunload "acetutil.arx") after expresstools-p has been called:

(expresstools-p)

T

(arxunload "acetutil.arx")

(expresstools-p)

T

(acet-sys-shift-down)

*kaboom*

This can be remedied by modifying expresstools-p thusly:

Code: [Select]
(defun expresstools-p nil
   (or (member "acetutil.arx" (arx))
       (and (findfile "acetutil.arx") (arxload "acetutil.arx" nil))
   )
   (eval
       (list 'defun 'expresstools-p nil
          '(not
               (vl-catch-all-error-p
                   (vl-catch-all-apply
                       (function (lambda nil (acet-sys-shift-down)))
                   )
               )
           )
       )
   )
   (expresstools-p)
)

That said, it still is not ideal, as expresstools-p will no longer make the attempt to load the ET library if the ET library is unloaded after it is called, merely returning nil:

(expresstools-p)

T

(arxunload "acetutil.arx")

(expresstools-p)

nil

So in the end, my sleep deprived brain thinks the more pragmatic albeit less sexy version merely need be:

Code: [Select]
(defun expresstools-p ( )
    (or
        (member "acetutil.arx" (arx))
        (and (findfile "acetutil.arx") (arxload "acetutil.arx" nil))
    )
)

But mommy, I need coffees. Bad.
Title: Re: Detect autocad express tools installed
Post by: Lee Mac on November 02, 2014, 12:27:01 PM
You raise a good point MP, I hadn't considered the possibility of the Express Tools being unloaded.  :-)
Title: Re: Detect autocad express tools installed
Post by: MP on November 02, 2014, 12:41:51 PM
:)

All said, it's kind of odd I barged my way into this discussion -- I'm a long time express tools use dissenter.  :-D
Title: Re: Detect autocad express tools installed
Post by: ronjonp on November 02, 2014, 09:35:32 PM
What's this talk about express fools ?  :-)
Title: Re: Detect autocad express tools installed
Post by: roy_043 on November 03, 2014, 04:59:57 AM
Is there a particular reason for using a catch-all-apply structure instead of:
Code: [Select]
(and acet-sys-shift-down)
Title: Re: Detect autocad express tools installed
Post by: RAIN CODE on November 04, 2014, 06:26:30 AM
damn my pc conked off again the very same day it got repaired.

have to wait for it to repair before I could try these.

 thanks anyway
Title: Re: Detect autocad express tools installed
Post by: RAIN CODE on November 06, 2014, 04:52:20 AM

While waiting for my PC to repair, I went thru a nos. of posting here. It really gives me a good impression that of all the autolisp Forum, I find TheSwamp is one of the best Forum around, with alot of people with excellant understanding of Autolisp programming.

To anyone (or my ex-colleagues) without the knowledge of Autolisp programmin, should start with the Basic.

You may not know what you are missing, programming is a wonderful ....hmm should I say hobby. When you find your program working the first time that feeling is undiscribeable. That kind of feeling is almost akin to...you know what I mean ...

More so if the program you wrote helps to shorthen your office work.




Title: Re: Detect autocad express tools installed
Post by: CAB on November 06, 2014, 08:16:09 AM
Welcome to the Dark Side, you'll never go back.  :)
Title: Re: Detect autocad express tools installed
Post by: RAIN CODE on November 07, 2014, 03:13:49 AM
Welcome to the Dark Side, you'll never go back.  :)

CAB is one of the Jedi Master here which I really have high respects for his work. :)

Sorry for my bad English I think the word for that posting should be indescribeable also the word 'out' missing in 'missing'