Hi,
I have my own acaddoc.lsp file, I need to load some arx file depends on Windows version:
acaddoc.lsp:
;if AutoCAD is 32bit:
(arxload "DOSLib19.arx")
;if AutoCAD is 64bit:
(arxload "DOSLib19x64.arx")
So, how can I find out the OS version and implement this lisp file?
Thanks,
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
aqdam1978,
with the
(getvar "PLATFORM");;for Windows 7 I get
"Microsoft Windows NT Version 6.1 (x86)"
for 32bit and
"Microsoft Windows NT Version 6.1 (x64)"
for 32bit, so to implement your arxload, using your previous code, perhaps something like
(setq str (getvar "PLATFORM")) (setq pos (vl-string-position (ascii "(") str)) (setq osver (substr str (+ pos 2))) (if (= osver "x86)") (arxload "DOSLib19.arx") (arxload "DOSLib19x64.arx") );; if
perhaps not the most elegant way to do it, but will do the trick.
hope that helps
Henrique
Hi hmsilva,
Thank you for your code,
I just change the 3rd and 4th line:
;;----- gets OS version x86 or x64 --------------------- (setq str (getvar "PLATFORM")) (setq pos (vl-string-position (ascii "(") str)) (setq osver (substr str (+ pos 2) 3)) (if (= osver "x86") (arxload "DOSLib19.arx") (arxload "DOSLib19x64.arx") );; if
aqdam1978,
just another way to load the arx files, or other file types, is first to be sure that the file exists,
and then load it, in this way there will be no error related to the load, and canceling the rest of your code,
in the example below, the file to load is in a suport directory, if not, we have to provide the full path,
(if (and (= osver "x86") (findfile "DOSLib19.arx"));; if osver is 32bit and the arx file is found then (arxload "DOSLib19") );; if (if (and (= osver "x64") (findfile "DOSLib19x64.arx"));; if osver is 64bit and the arx file is found then (arxload "DOSLib19x64") );; if
or another way
(cond ((and (= osver "x86") (findfile "DOSLib19.arx"));; if osver is 32bit and the arx file is found then (arxload "DOSLib19") ) ((and (= osver "x64") (findfile "DOSLib19x64.arx"));; if osver is 64bit and the arx file is found then (arxload "DOSLib19x64") ) );; cond
hope that helps
Henrique
Hi Henrique,
Thanks for your ideas,
I change the program to:
;;----- LOAD your app depends on OS version (x86 or x64) ----------- (defun C:app_load_by_OS(/ str pos OSVer x86app x64app) (setq str (getvar "PLATFORM") pos (vl-string-position (ascii "(") str) osver (substr str (+ pos 2) 3) ;------ Your app in both version (x86 or x64) --------------------- x86app "DOSLib19.arx" x64app "DOSLib19x64.arx" );;setq (if (= osver "x86") (progn (if (findfile x86app) (arxload x86app) (alert (strcat "Error:\nfile: " x86app "\nNot found!"))) );;progn ;;else if (if (= osver "x64") (progn (if (findfile x64app) (arxload x64app) (alert (strcat "Error:\nfile: " x64app "\nNot found!"))) );;progn ;;else (alert "Error:\nYour system not supported!") );;if x64 );;if x86 )
Thanks,
Abbas
Operating systems don't change day to day, week to week, or even month-to-month. Create your own registry key and set it once with "x32" or "x64" (or "x128" - future compatibility...), then read it when checking using (vl-registry-read...). You can also use it for other applications.
Hi Hmsilva,
(getvar "PLATFORM") did not work on some windows OS's.
it is better to use this code:
(defun c:GetOSArchitecture (/ WMI meth1 meth2 result) (vl-load-com) (cond ((and (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")) (setq meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)) (setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" "OperatingSystem"))) (vlax-for itm (vlax-get (vlax-invoke meth2 'ItemIndex 0) 'Properties_) (if (eq (vlax-get itm 'name) "OSArchitecture") (setq result (vlax-get itm 'value))))))) (mapcar 'vlax-release-object (list meth1 meth2 wmi)) result )
Abbas
What about many years known function:
(defun is64 () (vl-load-com) (> (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40) )
P.S.: Version of Windows (i.e.. x86 or x64) and version of AutoCAD can be different. For example AutoCAD 2007 x86 can be installed and work on Windows x64 (XP/Vista/Win7). Version of arx-files dependent of AutoCAD version and not of Windows version.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Alexander.Rivilis wrote:
What about many years known function:
...
Alexander. thank you, "many years known function"
but I did not know ...
Henrique
Alexander. thank you, "many years known function"
but I did not know ...
This is because you do not use Search.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Alexander.Rivilis wrote:
This is because you do not use Search.
...
not correct, I often use "search" is a very good tool and is my first choice...
Henrique
what is you opinion about reading from registry?
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE
Inspecting (getvar "PLATFORM") will not work, as you have found. You must use (getenv "PROCESSOR_ARCHITECTURE") for inspecting the architecture of the running AutoCAD. See ISX64.LSP here:
http://www.manusoft.com/software/freebies/lisp.html
@aqdam1978 wrote:
what is you opinion about reading from registry?
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE
PROCESSOR_ARCHITECTURE allow check Windows architecture (x86/x64) but not a AutoCAD architecture. As I wrote above this is not the same thing.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.