Author Topic: How to detect autocad 32 /64 bits  (Read 10815 times)

0 Members and 1 Guest are viewing this topic.

VVA

  • Newt
  • Posts: 166
Re: How to detect autocad 32 /64 bits
« Reply #15 on: April 23, 2010, 11:05:51 AM »
My 5 cents
Quote
vlax-get-acad-object in 64-bit return a longer object ID number than in the 32-bit so the function Acad64Bit-version will return T if AutoCAD is a 64-bit version.
Code: [Select]
(defun Acad64Bit-version ()
;;; Get from http://forum.dwg.ru/showthread.php?t=31568
;;;vlax-get-acad-object in 64-bit return a longer object ID number
;;;than in the 32-bit so the function Acad64Bit-version
;;; will return T if AutoCAD is a 64-bit version.
  (vl-load-com)
  (> (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40)
)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #16 on: April 23, 2010, 11:35:25 AM »
Just to add to what others and I have already provided ...

These should work in theory, but as I'm not running 64 bit here -- no can test. Would be great if some 64 bit folks could test and report success/fail. Thanks in advance.

*Not better <hard to improve upon (getenv "PROCESSOR_ARCHITECTURE")>, just another way to skin the cat.*

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Description))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (wcmatch result "*64*"))

)

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Architecture))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (eq 9 result))

)

Edit: Fixed glaring typo.
« Last Edit: April 23, 2010, 12:45:17 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: How to detect autocad 32 /64 bits
« Reply #17 on: April 23, 2010, 12:35:11 PM »
All I have time for right now; have a meeting this afternoon.

Windows 7 x64
AutoCAD MEP 208 x32

Quote
Command:
Command: (getenv "PROCESSOR_ARCHITECTURE")
"x86"

Command: (defun _Is64Bit ( / wmiLocater wmiService queryResult result )
(_>
(_>     
;;========================================================================
(_>     ;;
(_>     ;;  2010/04/23 | Quick & Dirty | Michael Puckett
(_>     ;;
(_>     
;;========================================================================
(_>
(_>     (vl-catch-all-apply
((_>        '(lambda ( )
(('(_>             (vlax-for item
(('((_>                 (setq queryResult
(('(((_>                     (vlax-invoke
(('((((_>                         (setq
(('(((((_>                             wmiLocater (vlax-create-object
"WbemScripting.SWbemLocator")
(('(((((_>                             wmiService (vlax-invoke wmiLocater
'ConnectServer "." "root\\cimv2")
(('(((((_>                         )
(('((((_>                        'ExecQuery
(('((((_>                         (strcat
(('(((((_>                             "Select * "
(('(((((_>                             "from   Win32_Processor "
(('(((((_>                         )
(('((((_>                     )
(('(((_>                 )
(('((_>                 (setq result (vlax-get item 'Description))
(('((_>             )
(('(_>         )
((_>     )
(_>
(_>     (if queryResult (vlax-release-object queryResult))
(_>     (if wmiService (vlax-release-object wmiService))
(_>     (if wmiLocater (vlax-release-object wmiLocater))
(_>
(_>     (if result (wcmatch result "*64*"))
(_>
(_> )
_IS64BIT

Command: (_is64bit)
T


Command: (defun _Is64Bit ( / wmiLocater wmiService queryResult result )
(_>
(_>     
;;========================================================================
(_>     ;;
(_>     ;;  2010/04/23 | Quick & Dirty | Michael Puckett
(_>     ;;
(_>     
;;========================================================================
(_>
(_>     (vl-catch-all-apply
((_>        '(lambda ( )
(('(_>             (vlax-for item
(('((_>                 (setq queryResult
(('(((_>                     (vlax-invoke
(('((((_>                         (setq
(('(((((_>                             wmiLocater (vlax-create-object
"WbemScripting.SWbemLocator")
(('(((((_>                             wmiService (vlax-invoke wmiLocater
'ConnectServer "." "root\\cimv2")
(('(((((_>                         )
(('((((_>                        'ExecQuery
(('((((_>                         (strcat
(('(((((_>                             "Select * "
(('(((((_>                             "from   Win32_Processor "
(('(((((_>                         )
(('((((_>                     )
(('(((_>                 )
(('((_>                 (setq result (vlax-get item 'Architure))
(('((_>             )
(('(_>         )
((_>     )
(_>
(_>     (if queryResult (vlax-release-object queryResult))
(_>     (if wmiService (vlax-release-object wmiService))
(_>     (if wmiLocater (vlax-release-object wmiLocater))
(_>
(_>     (if result (eq 9 result))
(_>
(_> )
_IS64BIT

Command: (_is64bit)
nil
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #18 on: April 23, 2010, 12:44:34 PM »
GAAA. F*****G LAME TYPING SKILLS.

The property should be 'Architecture, not 'Architure (epic facepalm).

Try this --

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Architecture))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (eq 9 result))

)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hmspe

  • Bull Frog
  • Posts: 362
Re: How to detect autocad 32 /64 bits
« Reply #19 on: April 23, 2010, 04:29:09 PM »
Both _Is64Bit functions return T on my 64 bit Win 7 computer.  I added a function that ran (Print (_Is64Bit)) on each.  It took almost 3 seconds to run on an Intel E8400 at 3GHz.   (getenv "PROCESSOR_ARCHITECTURE") returns "AMD64".
"Science is the belief in the ignorance of experts." - Richard Feynman

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #20 on: April 23, 2010, 05:25:46 PM »
3 seconds to execute (_Is64Bit)? Good gief that's horrible. Subtitle: Aside from possible academic value what I posted is worthless. DO NOT USE!

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #21 on: April 23, 2010, 05:28:40 PM »
PS: thx for trying. :)

PS2: forgive 'gief' typo in preceding post - no can edit from blackberry.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: How to detect autocad 32 /64 bits
« Reply #22 on: April 28, 2010, 02:04:56 PM »
The operating system isn't something that changes on a day-to-day basis, so if the value is needed a simple set and forget user registry entry could be used to store the value.  The registry entry can then be checked when the 32/64 bit value is needed and if missing, query the user via a dialog or silently via other settings (even if it takes several seconds its a one-time deal).
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How to detect autocad 32 /64 bits
« Reply #23 on: April 28, 2010, 06:45:21 PM »
PS2: forgive 'gief' typo in preceding post - no can edit from blackberry.
Eehhh Phone is not so smart as it thinks it is?  Or is is the operator?  :evil: :roll:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to detect autocad 32 /64 bits
« Reply #24 on: April 29, 2010, 11:33:23 AM »
just putting some info...

Code: [Select]
(vl-registry-descendents "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node")
Keep smile...

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #25 on: April 29, 2010, 01:28:30 PM »
Doslib is not the only arx i want to load .Is it possible to add

Idwgtab
Periscope
Quikpik
to this code.?



Code: [Select]
(defun ISX64 (/ proc_arch)
(and
(setq proc_arch (getenv "PROCESSOR_ARCHITECTURE"))
(< 1 (strlen proc_arch))
(eq "64" (substr proc_arch (1- (strlen proc_arch))))
)
)

;; determine whether appropriate version of DOSLib is already loaded.
;; if not, try to load it.
(setvar "cmdecho" 0)
(setq CADver (substr (getvar "acadver") 1 2)) ;; i.e., "17", "18", etc.
(setq arxlist (arx))
(if (isX64)
(setq DOSLibname (strcat "doslib" CADver "x64.arx"))
(setq DOSLibname (strcat "doslib" CADver ".arx"))
)
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtStartup T) ))
(if (not loadedAtStartup)

(vl-cmdf "._arx" "_load" (findfile DOSLibname))
)

;; verify that load was successful.
;; if not, quit.
(setq arxlist (arx))
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtRuntime T) ))
(if (not loadedAtRuntime)
(progn
(prompt "Sorry - DOSLib is not loaded and cannot be found in the
AutoCAD search path.")
(vlr-beep-reaction)
(quit)
  (setvar "cmdecho" 1)
)
)