OnNewRev.LST script file

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > DBWCommandShell > Event Scripts > Revision >

OnNewRev.LST script file

Description

This script is executed when a new revision action is requested. It returns a value for such revision.

Activation

Options→Revisions

Input

@LAST_REVISION

"" (empty string) if it is the FIRST revision; last revision of the document otherwise

@MODELESS

0: a dialog is displayed for input
1: dialog is running in a modeless way

@DOCUMENT_UNIQUE_ID

unique id of the document

@IS_CONFIGURATION_REVISION

0: not a configuration revision
1: a configuration revision
The script can generate different sequences of revision depending on CONFIGURATION_REVISION case

Output

NAME_FIELD_REVISION

new revision value

Remarks

The script must output the new calculated revision value with the following method:

DBWOutput DBWLookup("NAME_FIELD_REVISION"), new_revision_value, ForWriting

A revision schema dialog is available for defining the values of the revisions offered by the OnNewRev.LST. Only listed values are supported.
In the shortcut bar tools this dialog is accessed with the Edit revision schema script.

EditRevisionSchema

Example

.VBSCRIPT
'-------------------------------------------------------------------------------------
' field data entry routines
'
Dim swApp
Sub Main()
 DBWinit(TRUE)
 Set swApp = CreateObject ("SldWorks.Application")
 lastRevision = DBWInput("@LAST_REVISION")
 modeless = DBWInput("@MODELESS")
 docUniqueId = DBWInput("@DOCUMENT_UNIQUE_ID")
 lastRevision = NextRevision(lastRevision) 'it should be always calculated through a function
 iin = lastRevision
 if modeless=1 then
  iin = InputBox("Please enter the new revision number", "Assign a new revision", lastRevision )
 end if
 DBWOutput DBWLookup("NAME_FIELD_REVISION"), iin, ForWriting
End Sub
Function NextRevision( lastRevision )
 if lastRevision="" then
  NextRevision = "A.1"
 elseif lastRevision="A.1" then
  NextRevision = "A.2"
 elseif lastRevision="A.2" then
  NextRevision = "A.3"
 elseif lastRevision="A.3" then
  NextRevision = "B.1"
 elseif lastRevision="B.1" then
  NextRevision = "B.2"
 else
  NextRevision = "99"
 end if
End Function

The following example creates a new drawing for a given model setting for it a revision number consistent with the revision of the model.

 .VBSCRIPT

Sub Main()
        DBWinit(TRUE)
        lastRevision = DBWInput("@LAST_REVISION")
        modeless = DBWInput("@MODELESS")
        uid = DBWInput("@DOCUMENT_UNIQUE_ID")
        t = DBWQueryByUid( uid, "T" )
        if t="D" and lastRevision = "" then
                Dim modelList()
                n = DBWGetChildren( uid, modelList, " AND T IN ('P','A')" )
                'assume all documents have the same revision
                firstDocUid = modelList(0)
                rev = DBWQueryByUid( firstDocUid, "REVISION" )
                DBWOutput "REVISION", rev, ForWriting
                exit sub
        end if
        lastRevision = NextRevision(lastRevision) 'it should be always calculated through a function
        iin = lastRevision
        if modeless=0 then
                iin = InputBox("Please enter the new revision number", "Assign a new revision", lastRevision )
                if iin<>"" then
                        DBWOutput "REVISION", iin, ForWriting
                        DBWOutput "DESCRIPTION", "The new revision is " & iin, ForAppending
                        DBWOutput "NOTES", "The notes for this revision are: " & iin, ForAppending
                end if
        else
                DBWOutput "REVISION", iin, ForWriting
                DBWOutput "DESCRIPTION", "The new revision is " & iin, ForAppending
                DBWOutput "NOTES", "The notes for this revision are: " & iin, ForAppending
        end if
End Sub
'__________________________________
function NextRevision(rev)
        NextRevision = rev
        if rev = "R" then
                NextRevision = "A"
        elseif rev = "A" then
                NextRevision = "M"
        elseif rev = "M" then
                NextRevision = "Z"
        else
                NextRevision = "R"
        end if
end function