TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: kruuger on November 29, 2013, 03:03:24 PM

Title: Load different ARX files
Post by: kruuger on November 29, 2013, 03:03:24 PM
hi
i saw many loader which use cond depending of arx file version
i try to wrote something different. is there any way to improve more code below ?
Code: [Select]
(defun ads:LoadArx (Lst Arch Msg / fl res)
  (setq fl "")
  (foreach % Lst
    (cond
      ( (= % "/v/") (setq fl (strcat fl (substr (getvar "ACADVER") 1 2))) )
      ( (= % "/a/") (setq fl (strcat fl "/a/")) )
      ( T (setq fl (strcat fl %)) )
    )
  )
  (if Msg
    (if
      (not
        (vl-catch-all-error-p
          (vl-catch-all-apply
            (quote arxload)
            (list
              (if (= (getenv "PROCESSOR_ARCHITECTURE") "x86")
                (setq res (vl-string-subst (car Arch) "/a/" (strcat fl ".arx")))
                (setq res (vl-string-subst (cadr Arch) "/a/" (strcat fl ".arx")))
              )
            )
          )
        )
      )
      (princ (strcat " -> Loaded: " res))
      (princ (strcat " -> Error loading: " res))
    )
  )
)
Code: [Select]
(ads:LoadArx (list "DOSLib" "/v/" "/a/") (list "" "x64") T)
(ads:LoadArx (list "OpenDCL" "/a/" "." "/v/") (list "" "x64") T)
(ads:LoadArx (list "SQLiteLsp" "/v/" "/a/") (list "x32" "x64") T)
Arguments:

Lst - is some kind of file name pattern
Arch - system version use in file name
Msg - show message after load or not


Sample:
Code: [Select]
(ads:LoadArx (list "OpenDCL" "/a/" "." "/v/") (list "" "x64") T)in Autocad 2010 program load file:
OpenDCL.18.arx (OpenDCL | space | . | 18 | .arx |)


all files name per image.
thanks
kruuger
Title: Re: Load different ARX files
Post by: divtiply on November 29, 2013, 03:29:30 PM
Your users may use 32-bit AutoCAD on 64-bit Windows.

You should replace your platform test code
Code: [Select]
(= (getenv "PROCESSOR_ARCHITECTURE") "x86")
with
Code: [Select]
(<= (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40)
Title: Re: Load different ARX files
Post by: owenwengerd on November 30, 2013, 12:33:09 AM
Your users may use 32-bit AutoCAD on 64-bit Windows.

You should replace your platform test code
Code: [Select]
(= (getenv "PROCESSOR_ARCHITECTURE") "x86")
with
Code: [Select]
(<= (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40)


You are mistaken. The PROCESSOR_ARCHITECTURE test is correct, and more clear and direct.
Title: Re: Load different ARX files
Post by: owenwengerd on November 30, 2013, 12:38:25 AM
is there any way to improve more code below ?

For OpenDCL Runtime you should use the demand-load registry keys and simply (command "_OPENDCL").
Title: Re: Load different ARX files
Post by: Lee Mac on November 30, 2013, 08:51:46 AM
I'm not qualified to advise on the best procedure to loading an ARX file, but in response to:

is there any way to improve more code below?
I would suggest the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun loadarx ( str lst msg / err )
  2.     (cond
  3.         (   (null
  4.                 (findfile
  5.                     (setq str
  6.                         (stringsubst
  7.                             (if (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
  8.                                 (cadr lst)
  9.                                 (car  lst)
  10.                             )
  11.                             "/a/"
  12.                            (stringsubst (itoa (atoi (getvar 'acadver))) "/v/" str)
  13.                         )
  14.                     )
  15.                 )
  16.             )
  17.             (prompt (strcat "\nFile not found: " str)) ;; notify user & return nil
  18.         )
  19.         (   (vl-catch-all-error-p (setq err (vl-catch-all-apply 'arxload (list str))))
  20.             (prompt (vl-catch-all-error-message err)) ;; notify user & return nil
  21.         )
  22.         (   msg (princ (strcat "\nLoaded: " str))) ;; notify user & return non-nil
  23.         (   t   )
  24.     )
  25. )
  26.  
  27. (defun stringsubst ( new old str / pos )
  28.     (if (setq pos (vl-string-search (strcase old) (strcase str)))
  29.         (strcat (substr str 1 pos) new (stringsubst new old (substr str (+ pos 1 (strlen old)))))
  30.         str
  31.     )
  32. )

Which would be called as follows:

Code - Auto/Visual Lisp: [Select]
  1. (loadarx "DOSLib/v//a/.arx"    '(""    "x64") t)
  2. (loadarx "OpenDCL/a/./v/.arx"  '(""    "x64") t)
  3. (loadarx "SQLiteLsp/v//a/.arx" '("x32" "x64") t)
Title: Re: Load different ARX files
Post by: divtiply on November 30, 2013, 09:04:54 AM
You should replace your platform test code

You are mistaken.

It seems I do...
PROCESSOR_ARCHITECTURE - reports the native processor architecture EXCEPT for WOW64, where it reports x86.
Thanks!
Title: Re: Load different ARX files
Post by: kruuger on November 30, 2013, 12:13:04 PM
is there any way to improve more code below ?

For OpenDCL Runtime you should use the demand-load registry keys and simply (command "_OPENDCL").
Owen thanks for info


@ Lee. ah yes mistake with Msg. good idea with STR as first argument.
Thanks for update


kruuger
Title: Re: Load different ARX files
Post by: 77077 on May 07, 2015, 09:22:45 PM
Good. I'll seriously study.
Title: Re: Load different ARX files
Post by: 77077 on May 08, 2015, 08:51:21 AM
Hi  Mr.kruuger

Can you sharing your runtine load DOSLib.arx ?
Title: Re: Load different ARX files
Post by: kruuger on May 08, 2015, 09:01:33 AM
Hi  Mr.kruuger

Can you sharing your runtine load DOSLib.arx ?
you can get it here
http://www.rhino3d.com/download/none/none/doslib
k.
Title: Re: Load different ARX files
Post by: 77077 on May 08, 2015, 09:09:01 AM
Hi  Mr.kruuger

Can you sharing your runtine load DOSLib.arx ?
you can get it here
http://www.rhino3d.com/download/none/none/doslib
k.

Thanks Mr.kruuger
But I can't open this link.
Title: Re: Load different ARX files
Post by: kruuger on May 08, 2015, 09:11:34 AM
Hi  Mr.kruuger

Can you sharing your runtine load DOSLib.arx ?
you can get it here
http://www.rhino3d.com/download/none/none/doslib (http://www.rhino3d.com/download/none/none/doslib)
k.

Thanks Mr.kruuger
But I can't open this link.
just enter your email and click next.
k.