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

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
How to detect autocad 32 /64 bits
« on: April 20, 2010, 02:36:06 AM »
We are in the proces of upgrading to x64 workstations.
Now is on all 32 bits stations doslib loaded in startup suite.(becasue all the same.)
Now i want to detect somehow if a workstation is running autocad 32 or 64 and load the correct arx.
« Last Edit: April 20, 2010, 06:28:04 AM by MvdP »

Patrick_35

  • Guest
Re: How to detect 32 /64 bits
« Reply #1 on: April 20, 2010, 04:23:54 AM »
Hi

You should find your happiness

Code: [Select]
(defun c:info(/ item meth1 meth2 process wmi)
  (defun lister(val / it)
    (vlax-for it val
      (princ (strcat "\n" (vlax-get it 'name) " : "))
      (if (vlax-get it 'value)
        (princ (vlax-get it 'value))
        (princ "Nil")
      )
    )
  )

  (vl-load-com)
  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
        meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))
  (foreach process (list "BIOS" "Processor" "VideoController" "SoundDevice" "CDROMDrive" "OperatingSystem" "ComputerSystem" "PhysicalMemory" "DiskDrive")
    (setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" Process)))
    (princ (strcat "\nCaractéristiques " process " :"))
    (vlax-for item meth2
      (lister (vlax-get item 'Properties_))
      (lister (vlax-get item 'Qualifiers_))
      (getkword "\nAppuyez sur entrée pour continuer...")
    )
  )
  (mapcar 'vlax-release-object (list meth1 meth2 wmi))
  (princ)
)

@+

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #2 on: April 20, 2010, 06:29:59 AM »
Thanks Patrick, but sorry for the misunderstanding.I modified my guestion..

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #3 on: April 20, 2010, 06:40:05 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #4 on: April 20, 2010, 06:42:49 AM »
Or, would this be enough?

Code: [Select]
(vl-string-search "X64" (strcase (getvar 'PLATFORM)))

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8662
  • AKA Daniel
Re: How to detect autocad 32 /64 bits
« Reply #5 on: April 20, 2010, 08:06:39 AM »
(getenv "PROCESSOR_ARCHITECTURE")

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to detect autocad 32 /64 bits
« Reply #6 on: April 20, 2010, 08:14:07 AM »

Doslib is demand loaded ... just drag it into the app when setting up ... don't jump through unnecessary hoops.

There are several add-ons that come in several versions .. personally I'd rely on my initial setup/install to make sure ONLY the correct versions are available. 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #7 on: April 20, 2010, 08:20:09 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #8 on: April 20, 2010, 08:20:17 AM »
(getenv "PROCESSOR_ARCHITECTURE")

I knew there had to be something easier...   :-)

Are there only certain registry keys that can be obtained using getenv? And which are they?

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #9 on: April 20, 2010, 08:21:02 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

I was just trying to understand the code you posted - I have never used the WMI before  :|

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #10 on: April 20, 2010, 08:31:22 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

I was just trying to understand the code you posted - I have never used the WMI before  :|
To protect a lisp, I was asked as a question of finding the ID of the processor.
This is the method I found. And as I was, I took the opportunity to identify any.
Like this, no need to seek :D

Quote
(getenv "PROCESSOR_ARCHITECTURE")
Great, I do not know.
How to see all the "getenv" ?

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to detect autocad 32 /64 bits
« Reply #11 on: April 20, 2010, 09:16:19 AM »
I'll share with you what I have collected for GetEnv :
Quote
;; Shows how to use expanding environment strings
;; Usage: (ExpEnvStr "%TEMP%\\MYDATA")
;; Results of sample: "C:\\DOCUME~1\\Lee\\LOCALS~1\\Temp\\MYDATA"
(defun ExpEnvStr ( strVal / wshShell)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (vlax-invoke-method wshShell 'ExpandEnvironmentStrings strVal)
)

;; Retreive the value of the environment variable
;; Usage: (GetEnvStr "SYSTEM" "USERID")
(defun GetEnvStr ( strVarType strVarName / wshShell envVars)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (setq envVars (vlax-get-property wshShell 'Environment strVarType))
  (vlax-get-property envVars 'Item strVarName)
)

;; Set the value to an environment variable
;; Usage: (SetEnvStr "SYSTEM" "USERID" "L123")
(defun SetEnvStr ( strVarType strVarName strVarVal / wshShell envVars)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (setq envVars (vlax-get-property wshShell 'Environment strVarType))
  (vlax-put-property envVars 'Item strVarName strVarVal)
)



 Lee, although you shell object is obviously more powerful, I have found that
 you can use (getenv) to return environment variables (at least the ones you can
 access through the DOS [SET] command).

For example: (strcat (getenv "temp") "\\MYDATA")

So for simply retreiving the %temp% directory, the ComputerName, the UserDomain,
etc. - (getenv) should work.

Quote
Posted by: R.K. McSwain | Friday, December 09, 2005 at 07:42 AM

GETENV does work for getting the variables, but the problem is that even though
there is a SETENV function; it can't be used to update OS environment variables.
It instead is wired to specific locations under the AutoCAD registry keys.

So if I have a variable called ALLDOCS that is defined in as a System Variable
for the OS and use SETENV to update it, SETENV writes to the Fixed Profile >>
General location under HKEY_CURRENT_USER >> Software >> Autodesk >> AutoCAD >>
(Release) >> (ProdID).

So it is for this reason that I like to use FSO for everything. From what I have
seen, there is no slow down in performance getting a variable value this way.
Now setting one is a slightly different story.


Code: [Select]
Environment Variables Listing.
Compiled and kindly donated by Stig Madsen.

Remember that environment variables are dependent on .. well, the environment, so each may or may not apply to a certain setup.
Some are almost described, some are definitely not. The first are OS dependent, the rest are AutoCAD dependent.



--------------------------------------------------------------------------------

System related

(getenv "Path") ;string System search paths

(getenv "COMSPEC") ;string Cmd.exe path

(getenv "UserName");string User logon name

(getenv "Temp") ;string Temp path

(getenv "TMP") ;string Temp path

(getenv "ComputerName");string Computer name

(getenv "Windir") ;string Windows path

(getenv "OS") ;string Operating system

(getenv "UserProfile");string Current user profile path

(getenv "Pathext") ;string Exec extensions

(getenv "SystemDrive");string System drive

(getenv "SystemRoot");string System root path

(getenv "MaxArray");integer


--------------------------------------------------------------------------------

General

(getenv "ACAD") ;string Support search paths

(getenv "ANSIHatch");string Pattern file for ANSI setup 1)

(getenv "ANSILinetype");string Linetype file for ANSI setup 1)

(getenv "ISOHatch");string Pattern file for ISO setup 1)

(getenv "ISOLinetype");string Linetype file for ISO setup 1)

(getenv "StartUpType");string Current default for StartUp dialog

(getenv "acet-MenuLoad");string Loading of Express Tools menu

(getenv "Measureinit");string MEASUREINIT

(getenv "InsertUnitsDefSource");integer INSUNITSDEFSOURCE

(getenv "InsertUnitsDefTarget");integer INSUNITSDEFTARGET

(getenv "acet-Enable");string

(getenv "LastTemplate");string Last DWT used

(getenv "AcetRText:type");string Current default for RTEXT "Diesel"

(getenv "Pickstyle");integer

(getenv "Coords") ;integer

(getenv "ShowProxyDialog");integer

(getenv "Osmode") ;integer

(getenv "EdgeMode");integer

(getenv "PAPERUPDATE");integer

(getenv "ACADPLCMD");string Plotter command string

(getenv "ImageHighlight");integer

(getenv "Attdia") ;integer

(getenv "Attreq") ;integer

(getenv "Delobj") ;integer

(getenv "Dragmode");integer

(getenv "UseMRUConfig");integer

(getenv "PLSPOOLALERT");integer

(getenv "PLOTLEGACY");integer

(getenv "PSTYLEPOLICY");integer

(getenv "OLEQUALITY");integer

(getenv "Anyport") ;integer

(getenv "Validation Policy");integer

(getenv "Validation Strategy");integer

(getenv "CommandDialogs");integer CMDDIA

(getenv "TempDirectory");string Temp dir

(getenv "PlotSpoolerDirectory");string Spooler dir

(getenv "DefaultLoginName");string Default login

(getenv "MenuFile");string Default menu path

(getenv "NetLocation");string Default URL

(getenv "ACADDRV") ;string Driver path

(getenv "ACADHELP");string Help path

(getenv "PrinterConfigDir");string Plotter path

(getenv "PrinterStyleSheetDir");string Plot styles path

(getenv "PrinterDescDir");string Plotter driver path

(getenv "NewStyleSheet");string Default .stb/.ctb file

(getenv "DefaultFormatForSave");integer Default saveas

(getenv "DefaultConfig");string Default pc3

(getenv "LastModifiedConfig");string Last pc3

(getenv "MRUConfig");string pc3?

(getenv "ACADLOGFILE");string Logfile

(getenv "MaxDwg") ;integer

(getenv "AVEMAPS") ;string Texture files path

(getenv "TemplatePath");string Templates path

(getenv "DatabaseWorkSpacePath");string Data Links path

(getenv "DefaultPlotStyle");string e.g. "ByLayer"

(getenv "DefaultLayerZeroPlotStyle");string e.g."Normal"

(getenv "LineWeightUnits");integer

(getenv "LWDEFAULT");integer Default lineweight

(getenv "CustomColors");integer

(getenv "Blipmode");integer

(getenv "ToolTips");string

1) used by MEASUREINIT and MEASUREMENT sysvars


--------------------------------------------------------------------------------

Editor Configuration

(getenv "SDF_AttributeExtractTemplateFile");string ??

(getenv "AutoSnapPolarAng");string POLARANG

(getenv "AutoSnapPolarDistance");string POLARDIST

(getenv "AutoSnapPolarAddAng");string POLARADDANG

(getenv "AutoSnapControl");integer AUTOSNAP

(getenv "AutoSnapTrackPath");integer TRACKPATH

(getenv "PickBox") ;integer PICKBOX

(getenv "AutoSnapSize");integer

(getenv "PickFirst");integer PICKFIRST

(getenv "PickAuto");integer PICKAUTO

(getenv "MenuOptionFlags");integer MENUCTL

(getenv "FontMappingFile");string

(getenv "LogFilePath");string

(getenv "PSOUT_PrologFileName");string

(getenv "MainDictionary");string

(getenv "CustomDictionary");string

(getenv "MTextEditor");string

(getenv "XrefLoadPath");string

(getenv "SaveFilePath");string

(getenv "AcadLspAsDoc");string


--------------------------------------------------------------------------------

Drawing Window

(getenv "Background");integer Background color

(getenv "Layout background");integer PS Background color

(getenv "XhairPickboxEtc");integer Crosshair color

(getenv "LayoutXhairPickboxEtc");integer PS Crosshair color

(getenv "Autotracking vector");integer Autotracking vector color

(getenv "MonoVectors");integer

(getenv "FontFace");string Screen Menu

(getenv "FontHeight");integer

(getenv "FontWeight");integer

(getenv "FontItalic");integer

(getenv "FontPitchAndFamily");integer

(getenv "CursorSize");integer

(getenv "HideWarningDialogs");integer:00000008 <- hit

(getenv "ScreenMenu") ; interger, 1 turns it on;

(getenv "SDIMode") ;integer:00000000 <- hit


--------------------------------------------------------------------------------

Command Line Windows

(getenv "CmdLine.ForeColor");integer

(getenv "CmdLine.BackColor");integer

(getenv "TextWindow.ForeColor");integert

(getenv "TextWindow.BackColor");integer

(getenv "CmdLine.FontFace");string

(getenv "CmdLine.FontHeight");integer

(getenv "CmdLine.FontWeight");integer

(getenv "CmdLine.FontItalic");integer

(getenv "CmdLine.FontPitchAndFamily");integer

(getenv "TextWindow.FontFace");string

(getenv "TextWindow.FontHeight");integer

(getenv "TextWindow.FontWeight");integer

(getenv "TextWindow.FontItalic");integer

(getenv "TextWindow.FontPitchAndFamily");integer
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #12 on: April 20, 2010, 09:20:59 AM »
Thanks Alan, appreciated.  :-)

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #13 on: April 20, 2010, 09:27:34 AM »
Found this on the Autodesk discussion groups.

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)
)
)

http://discussion.autodesk.com/forums/thread.jspa?messageID=6347941&#6347941

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #14 on: April 20, 2010, 10:52:37 AM »
Thanks Cab  :-)

@+