OnConfigurationFilter.LST script file

<< Click to Display Table of Contents >>

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

OnConfigurationFilter.LST script file

available from build: 20061011

Description

DBWorks/DBInventor will use the logic programmed in the script for deciding if a configuration must be saved as distinct record or not.

The script replaces any parameters-based logic
Save configurations of components with names like/not like:
and
Save configurations only of components with configuration names like:
assigned in the same options page.

Activation

Options→Environment→Configurations

Input

@DOCUMENT_PATH_NAME

the full path name when available; it is empty for new documents

@DOCUMENT_CONFIGURATION

the configuration when available; empty if not available

Output

@OKCONFIGURATION

0: don’t save this configuration
1: ok save configuration

@NOCACHE

it avoids the use of the configuration values cache, maintained internally by DBWorks for performance purpose.

It may be helpful for debugging cases where the cache would not be correctly synchronized (configuration events scripts)

Remarks

The script is invoked at a very low level in the system, so it may happen that it is called many time for a single save. For such reason, it is highly recommeded to keep it simple and with no database access at all.

Example

The following sample accepts the configurations for documents where the filename ends with the string "_Pxxx" ( where x is any character ), or where the configuration is similar to *(*).
Please note that the supplied regexp sample uses a syntax different from the syntax allowed for the parameters-based logic.For more details about the Pattern characters supported by the RegExp object, please read the topic:
Windows Script Technologies→VBScript→Reference→Properties→Patter Property

.VBSCRIPT

sub main()
 documentPathName = DBWInput("@DOCUMENT_PATH_NAME")
 documentConfiguration = DBWInput("@DOCUMENT_CONFIGURATION")
 'DBWMsgBox  "====== OnConfigurationFilter.LST =======" & vbcrlf & vbcrlf &_
 '"Document path name: " & documentPathName & vbcrlf &_
 '"Document configuration: " & documentConfiguration
 okConfiguration = 0
 ext = right(documentPathName,7)
 if ext = ".SLDASM" or ext = ".SLDPRT" then
  fileName = ucase(DBWFileNameNoExt1(documentPathName))
  ext = ucase(DBWExtFromFileName(documentPathName))
  if fileName<>"" and okMatchString( fileName, "_P???$" ) then
   okConfiguration = 1
  end if
 end if
 if documentConfiguration<>"" and okMatchString( documentConfiguration, "\(*\)$" ) then
  okConfiguration = 1
 end if
 DBWOutput "@OKCONFIGURATION",okConfiguration,ForWriting
end sub

 

function okMatchString(StringToMatch, Pattern)

 okMatchString = false
 Set RegularExpressionObject = new RegExp
 With RegularExpressionObject
  .Pattern = Pattern
  .IgnoreCase = True
  .Global = True
 End With
 okMatchString = RegularExpressionObject.Test(StringToMatch)
 Set RegularExpressionObject = nothing
end function