Author Topic: Load different ARX files  (Read 5031 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 637
Load different ARX files
« 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

divtiply

  • Guest
Re: Load different ARX files
« Reply #1 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)

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Load different ARX files
« Reply #2 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.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Load different ARX files
« Reply #3 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").

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Load different ARX files
« Reply #4 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?
  • Note that if the 'msg' argument is nil, the ARX won't be loaded.
  • Rather than constructing the filename string from a list of strings, I would supply the function with a string in the first place.
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)
« Last Edit: November 30, 2013, 09:06:27 AM by Lee Mac »

divtiply

  • Guest
Re: Load different ARX files
« Reply #5 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!

kruuger

  • Swamp Rat
  • Posts: 637
Re: Load different ARX files
« Reply #6 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

77077

  • Guest
Re: Load different ARX files
« Reply #7 on: May 07, 2015, 09:22:45 PM »
Good. I'll seriously study.

77077

  • Guest
Re: Load different ARX files
« Reply #8 on: May 08, 2015, 08:51:21 AM »
Hi  Mr.kruuger

Can you sharing your runtine load DOSLib.arx ?

kruuger

  • Swamp Rat
  • Posts: 637
Re: Load different ARX files
« Reply #9 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.

77077

  • Guest
Re: Load different ARX files
« Reply #10 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.

kruuger

  • Swamp Rat
  • Posts: 637
Re: Load different ARX files
« Reply #11 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
k.

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