Author Topic: Auto load ARX  (Read 6955 times)

0 Members and 1 Guest are viewing this topic.

77077

  • Guest
Auto load ARX
« on: May 07, 2015, 11:10:41 AM »
Hi all
Operating system contains 32 and 64 - bit version , autoCAD contains  R15~ R20 version .

How to automatically load matching arx ?


Code: [Select]
(defun S::STARTUP ()
  (cond
    ((= (atoi (substr (getvar "acadver") 1 2))17)
      (if (not (member "OpenDCL.17.arx" (arx)))
        (if (findfile "OpenDCL.17.arx")
          (arxload "OpenDCL.17.arx")
        )
      )
    )
    ((= (atoi (substr (getvar "acadver") 1 2))18)
      (if (not (member "OpenDCL.18.arx" (arx)))
        (if (findfile "OpenDCL.18.arx")
          (arxload "OpenDCL.18.arx")
        )
      )
    )
  )
)

I need for my CAD and OS ,Automatically select the appropriate ARX.

and written this ARX patch & name  to the  acad.rx

Is possible?
« Last Edit: May 07, 2015, 09:33:48 PM by 77077 »

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Auto load ARX
« Reply #1 on: May 07, 2015, 11:24:11 AM »
I'd put acad.rx files in the paths of each version.  Best way to autoload arx files.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Auto load ARX
« Reply #2 on: May 07, 2015, 11:31:48 AM »
I don't use open dcl but maybe this .. not sure if the arx names vary per architecture.
Yup .. looks like it does.
Code - Auto/Visual Lisp: [Select]
  1. (defun s::startup (/ odcl)
  2.   (and (setq odcl (strcat "OPENDCL." (substr (getvar "acadver") 1 2) ".ARX"))
  3.        (not (member odcl (mapcar 'strcase (arx))))
  4.        (findfile odcl)
  5.        (arxload odcl)
  6.   )
  7. )
« Last Edit: May 07, 2015, 11:43:58 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

77077

  • Guest
Re: Auto load ARX
« Reply #3 on: May 07, 2015, 12:23:00 PM »
I'd put acad.rx files in the paths of each version.  Best way to autoload arx files.

Yes , two methods ,1. Write the registry 2. Write to acad.rx

I need to choose which one need load for my cad and OS


77077

  • Guest
Re: Auto load ARX
« Reply #4 on: May 07, 2015, 12:46:26 PM »
I don't use open dcl but maybe this .. not sure if the arx names vary per architecture.
Yup .. looks like it does.
Code - Auto/Visual Lisp: [Select]
  1. (defun s::startup (/ odcl)
  2.   (and (setq odcl (strcat "OPENDCL." (substr (getvar "acadver") 1 2) ".ARX"))
  3.        (not (member odcl (mapcar 'strcase (arx))))
  4.        (findfile odcl)
  5.        (arxload odcl)
  6.   )
  7. )

Thanks ,But I can't understand. If my OS is 64bit ?

I need for my CAD and OS ,Automatically select the appropriate ARX.

and written this ARX patch & name  to the  acad.rx

Is possible?


ronjonp

  • Needs a day job
  • Posts: 7529
Re: Auto load ARX
« Reply #5 on: May 07, 2015, 01:00:21 PM »
Look at the link in my previous post .. detecting the architecture is fairly easy like so:
Code - Auto/Visual Lisp: [Select]
  1. (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
  2.   "x64"
  3.   "x32"
  4. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Auto load ARX
« Reply #6 on: May 07, 2015, 04:02:25 PM »
(command "OpenDCL")
James Buzbee
Windows 8

77077

  • Guest
Re: Auto load ARX
« Reply #7 on: May 07, 2015, 09:23:55 PM »
(command "OpenDCL")


I'm not use for opendcl

77077

  • Guest
Re: Auto load ARX
« Reply #8 on: May 08, 2015, 06:43:29 AM »
Look at the link in my previous post .. detecting the architecture is fairly easy like so:
Code - Auto/Visual Lisp: [Select]
  1. (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
  2.   "x64"
  3.   "x32"
  4. )


Thanks ronjonp
XLRX_API.R16.x32.arx is for cad2004~2006
XLRX_API.R2005.arx is for cad2005
SO if my cad version is cad2005 , that need load XLRX_API.R2005.arx  not XLRX_API.R16.x32.arx  ????
I'm a Newt ,I need a fish ,  can you give me ?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Auto load ARX
« Reply #9 on: May 08, 2015, 10:31:01 AM »
Just thinking outside the box but .. why don't you rename those earlier versions to match the naming convention that uses (substr (getvar "acadver") 1 2) .. that would simplify things.

This should work for the file list you posted above .. but I'd still recommend using a standard naming convention.

Code - Auto/Visual Lisp: [Select]
  1. (defun s::startup (/ a f v v2)
  2.   (and (setq a (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
  3.                  ".X64.ARX"
  4.                  ".X32.ARX"
  5.                )
  6.        )
  7.        (setq v (substr (ver) 13 4))
  8.        (setq v2 (substr (getvar "acadver") 1 2))
  9.        (setq f (strcat "XLRX_API.R"
  10.                        (cond ((wcmatch v "2005,2006") (strcat v ".ARX"))
  11.                              ((= v "2008") (strcat v a))
  12.                              ((strcat v2 a))
  13.                        )
  14.                )
  15.        )
  16.        (findfile f)
  17.        (not (member (strcase f) (mapcar 'strcase (arx))))
  18.        (arxload f)
  19.   )
  20. )
« Last Edit: May 08, 2015, 11:05:33 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Auto load ARX
« Reply #10 on: May 08, 2015, 11:06:56 AM »
XLRX_API.R16.x32.arx is for cad2004~2006
XLRX_API.R2005.arx is for cad2005
SO if my cad version is cad2005 , that need load XLRX_API.R2005.arx  not XLRX_API.R16.x32.arx  :? ?
I'm a Newt ,I need a fish ,  can you give me ?
Agreed about renaming ... Can you rename the ARX files to use ACad's internal version numbers instead of those external 20## numbers?


If not you could build the possible version numbers using this:
Code - Auto/Visual Lisp: [Select]
  1. (defun get-acadversions (/ r i j L a)
  2.   (setq r (atof (getvar "acadver"))
  3.         i (atoi (rtos r))
  4.         j (atoi (rtos (* 10 (- r i))))
  5.         L (list (itoa i) (strcat (itoa i) "." (itoa j))))
  6.   (if (>= i 15)
  7.     (setq L (cons
  8.               (cond ((= i 15)
  9.                      (strcat "200" (cond ((= j 1) "1i") (t (itoa j)))))
  10.                     ((< i 19)
  11.                      (itoa (+ 2004 (* (- i 16) 3) j)))
  12.                     (t
  13.                      (itoa (+ 2013 (* (- i 19) 2) j))))
  14.               L)))
  15.   (append L (mapcar '(lambda (s) (strcat "r" s)) L)))


Then use a function to search for the first file found using those numbers. Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun find-by-ver (pre post)
  2.   (vl-remove 'nil (mapcar '(lambda (v) (findfile (strcat pre v post)))
  3.                           (get-acadversions))))



You could call it thus in your scenario:
Code - Auto/Visual Lisp: [Select]
  1. (if (setq found (find-by-ver
  2.                   "XLRX_API."
  3.                   (strcat (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
  4.                             "x64"
  5.                             "x32")
  6.                           ".arx")))
  7.   (arxload (car found)))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Auto load ARX
« Reply #11 on: May 08, 2015, 12:22:46 PM »
Nice idea & code Irné - I see you have cracked the AutoCAD release numbering pattern :-)

Perhaps another way to write it to avoid the reliance on Autodesk being consistent...
Code - Auto/Visual Lisp: [Select]
  1. (defun acadversions ( / a b c d )
  2.     (setq a (getvar 'dimzin)
  3.           b (atof (getvar 'acadver))
  4.     )
  5.     (setvar 'dimzin 0)
  6.     (setq c (list (substr (ver) 13 (- (strlen (ver)) 17)) (rtos b 2 0) (rtos b 2 1))
  7.           d (append c (mapcar 'strcat '("r" "r" "r") c))
  8.     )
  9.     (setvar 'dimzin a)
  10.     d
  11. )

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Auto load ARX
« Reply #12 on: May 08, 2015, 12:39:58 PM »
Nice Lee :) .. this is the way I'd write it.


Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun acadversions (/ l m a c)
  3.   (setq l (getvar 'dimzin)
  4.         m (atof (getvar 'acadver))
  5.   )
  6.   (setvar 'dimzin 0)
  7.   (setq a (list (substr (ver) 13 (- (strlen (ver)) 17)) (rtos m 2 0) (rtos m 2 1))
  8.         c (append a (mapcar 'strcat '("r" "r" "r") a))
  9.   )
  10.   (setvar 'dimzin l)
  11.   c
  12. )
  13. (acadversions)
  14.  

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Auto load ARX
« Reply #13 on: May 08, 2015, 01:17:53 PM »
Haha!  :-D

Thanks Ron  :-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Auto load ARX
« Reply #14 on: May 08, 2015, 04:27:00 PM »
Here's my lazy method...

Code: [Select]
;; DosLib
(vl-some (function (lambda (dos)
                     (or (vl-position dos (arx))
                         (not (vl-catch-all-error-p (vl-catch-all-apply 'arxload (list dos))))
                     )
                   )
         )
         (vl-directory-files "C:\\alan\\arx\\" "DOSLIB*ARX")
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox