SWVersion

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Commands Reference > CADSystem >

SWVersion

Description

Returns the version of the current hosting CAD application.

Syntax

call DBWShell("SWVersion")

Results

After executing the command, use the Standard Library command DBWResult to check the value of the following parameters:

@APPLICATION

application name

@VERSION

the CAD version in the format <major version>.<service pack>

Remarks

When creating the sldworks object you may need to create a specific version object rather than the generic one like

swApp = createObject("sldworks.application")

So you can use the function SWVersion to retrieve the exact version you need to specify.

On the other hand you can trust on some standard Library constants to get the application name and the application version:

if Ucase(DBWorksApplicationName) = "DBWORKS" then

 objstr ="SldWorks.Application." & Left(DBWorksCADApplicationVersion,2)
 Set DBWApp = CreateObject(objstr)
 ...
end if

See also

See SWVersionHistory command
DBWorksApplicationName and DBWorksCADApplicationVersion in Standard Library global constants.

Example

Sub main()

 DBWInit(TRUE)
 DBWShell("SWVersion")
 application = DBWResult("@APPLICATION")
 version = DBWResult("@VERSION")
 if Ucase(application) = "SOLIDWORKS" then
  if version>=27.0 then
   yearLabel = "2019"
  elseif version>=26.0 then
   yearLabel = "2018"
  elseif version>=25.0 then
   yearLabel = "2017"
  elseif version>=24.0 then
   yearLabel = "2016"
  elseif version>=23.0 then
   yearLabel = "2015"
  end If
 ElseIf UCase (application)="INVENTOR" Then
  if version>=22.0 then
   yearLabel = "2019"
  elseif version>=21.0 then
   yearLabel = "2018"
  elseif version>=20.0 then
   yearLabel = "2017"
  elseif version>=19.0 then
   yearLabel = "2016"
  elseif version>=18.0 then
   yearLabel = "2015"
  End if
 ElseIf UCase (application)="SOLIDEDGE" Then
  if version>=219.0 then
   yearLabel = "2019"
  elseif version>=110.0 then
   yearLabel = "ST10"
  elseif version>=109.0 then
   yearLabel = "ST9"
  elseif version>=108.0 then
   yearLabel = "ST8"
  end if
 Else ' "STANDALONE"
  'DBWMsgBox "standalone application: no cad found"
  yearLabel = "no data"
  version = "no data"
 End If
 ArrVer=Split(version,".")
 mainVer=ArrVer(0)
 sp=ArrVer(1)
 DBWMsgBox "application: "  & application & vbcrlf &  "version: " & yearLabel & vbcrlf & "sp: " & sp
end sub