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>=34.0 then
                 yearLabel = "2026"
         elseif version>=33.0 then
                 yearLabel = "2025"
         elseif version>=32.0 then
                 yearLabel = "2024"
         elseif version>=31.0 then
                 yearLabel = "2023"
         end If
 ElseIf UCase (application)="INVENTOR" Then
         if version>=31.0 then
                 yearLabel = "2027"
         elseif version>=30.0 then
                 yearLabel = "2026"
         elseif version>=29.0 then
                 yearLabel = "2025"
         elseif version>=28.0 then
                 yearLabel = "2024"
         End if
 ElseIf UCase (application)="SOLIDEDGE" Then
         if version>=226.0 then
                 yearLabel = "2026"
         elseIf version>=225.0 then
                 yearLabel = "2025"
         elseIf version>=224.0 then
                 yearLabel = "2024"
         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

 

 

Example PS1

#force stop execution at first cmdlet error
$ErrorActionPreference = "Stop"
#loads and initialize MwPdmApi dll
Add-type -path $Env:DBWorksApiNetDll
$instance = New-Object MwPDMApi.Initialize
$appName = $Env:DBWorksApplicationName
$app=$instance.StartConnection($appName)
$major = ""
$sp = ""
$application = $app.CADSystem().GetCADVersion([ref] $major,[ref] $sp)
$version = $major + $sp
$app.UserInterface().MsgBox("you're running: $application`nversion $version")