|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > Examples > OnNewRev.LST example |
This is an example of OnNewRev.LST script file.
The script create the revision of a new drawing starting from the last revision of the drawing template.
.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