BG  Scope: Web  By:  
Applies To: ALL Translators
 
New version of translators support the RadialSoft Naming extension mechanism.
This system is made to allow companies to customize the file names produced either to standardize them or to connect the translator to the PDM system.
 
By default a standard naming scheme is used:
 
The standard naming scheme.
 
The default output format string is 
OutputFormatString = "[%ORIPATH%\\]%ORIFN%.%ORIEXT%[-%POSTFIX%][-%MN%][-%TGTI%].%TGTEXT%"
 
Another good example is
Save under a different sub directory
SavePath"="G:\\CAD\\SolidWorks\\"
"OutputFormatString"="[%OUTDIR%\\]%ORIFN%.%ORIEXT%[-%POSTFIX%][-%MN%][-%TGTI%][.%TGTEXT%]"
 
 
You can superseed this value by settings the value "OutputFormatString". By default this value is not created.
The output format string is used to produce a filename as follow.
The original file name is splitted in elements.
The recognized items in the format string are replaced by their values.
 
CURDIR            Current directory (could be different from original file directory)
ORIPATH          Directory of original file
ORIFN              File name of roginal file (without the path and the extension)
ORIEXT            Extension of original file
POSTFIX          Extra post fix
MN                  Model name
MI                    Model Index (empty string if 0)
RI                    Reason id. A integer used when several files are produce per model
TGTI                Target part index (imagine a model containing 10 parts, TGTI will vary from 0 to 9)
TGTEXT           Target part extension.
OUTDIR            Predefined output directory. The default output directory is in the registry key "SavePath" (This setting is c:\temp by default)
COMPUTER     Computer Name
USER              User Name
SOFTWARE    Addin Name
VERSION        Addin Version
HOST              CAD Software Name
HOSTVERSION    CAD Software Version
ORIROOT            Root of path of original Name (like C:\)
ORISUBPATH0    File name and lowest directory in the path ( C:\CCC\DFDG\DCC\TE.model will give DCC\TE.model)
ORISUBPATH1    Same as above + one level more ( DFDG\DCC\TE.model)
ORISUBPATH2    Same as above + one level more ( DFDG\DCC\TE.model)

A part of the format string can be surrounded by brackets. Only one level of brackets is supported. If all substitutions made within the brackets are empty the complete text within the brakets is ignored.
 
The Naming Extension
 
If you are limited by the standard naming scheme you can implement and use your own.
 
To achive this you need to use a programming language like C++ or Visual Basic. Add the RSEventsLib type library to your interface and build an object that implements IRSPDMInterface. As of August 2003 the only function is ComposeFileName.
 
Here is the header of this method.
 
 HRESULT ComposeFileName (
        BSTR OriginalFileName1,
        BSTR ModelName,
        int ModelNumber,
        int ReasonID,
        int TargetPartNumber,
        BSTR ExtraPostFix,
        BSTR DesiredExtension,
        BSTR CurrentDirectory,
        BSTR * FullFileName )
    {
List of Registry settings
SubPath/PDMInterface
SubPath/OutputFormatString
SubPath/SavePath
SubPath/Script    absolute path to script file (.vbs)
 
Sample Script File
'------------------------------------------------------------------------------
'FILE DESCRIPTION: A description was not provided.
'------------------------------------------------------------------------------
dim MyData
 
Sub NamingStd_OnInitialize( _
 Settings, _
 RequestingSoftware, _
 SoftwareVersion, _
 HostSoftware, _
 HostVersion )
    MyData = settings.GetStr("Directory3", "test")
End Sub
 
Function NamingStd_OnComposeFileName( _
 OriginalFileName, _
 ModelName, _
 ModelNumber, _
 ReasonID, _
 TargetPartNumber, _
 ExtraPostFix,_
 DesiredExtension,_
        FullFileName)
 
    Dim PosXDB
    PosXDB = Instr( FullFileName, ".xdb")
    PosXDB = PosXDB + 5
    Dim PosRsf
    PosRsf = Instr( FullFileName, "..MAQ.rsf")
    Dim LenRSF
    LenRSF = 9
    if posRsf = 0 then
 LenRSF = 8
 PosRsf = Instr( FullFileName, ".MAQ.rsf")
    end if
    Dim PosEndDir
    PosEndDir = InstrRev( FullFileName, "\")
    if (ReasonID = 1) Then
 ' Top files
 FullFileName = mid(FullFileName, 1, PosEndDir) + mid(FullFileName, PosXDB, PosRSF - PosXDB) + mid( FullFileName, PosRsf + LenRSF)
 NamingStd_OnComposeFileName = FullFileName
    Elseif (ReasonID = 5) Then
 ' created sub parts
 if len(ModelName) > 0 Then
     FullFileName = mid(FullFileName, 1, PosEndDir) & ModelName
     ' cf mail from 2005/03/24 add CInt
     if CInt(TargetPartNumber) > 0 Then
  FullFileName = FullFileName & Str(CInt(TargetPartNumber))
     End if
     FullFileName = FullFileName & "." & DesiredExtension
 Else
     FullFileName = mid(FullFileName, 1, PosEndDir) & mid(FullFileName, PosXDB, PosRSF - PosXDB) + mid( FullFileName, PosRsf + LenRSF)
 End if
 NamingStd_OnComposeFileName = FullFileName
    Elseif (ReasonID = 6) Then
 ' looking for external parts
 FullFileName = mid(FullFileName, 1, PosEndDir) + ExtraPostFix
 dim FSO
 set FSO = createObject("VBCOM.VBCOM.1")
 if (FSO.FileExists( FullFileName & ".sldprt")) Then
     FullFileName = FullFileName & ".sldprt"
 else
     if (FSO.FileExists( FullFileName & ".sldasm")) Then
  FullFileName = FullFileName & ".sldasm"
     else
  FullFileName = ""
     end if
 end if
 NamingStd_OnComposeFileName = FullFileName
    Elseif (ReasonID = 4) Then
 ' log files
 FullFileName = mid(FullFileName, 1, PosEndDir) + mid(FullFileName, PosXDB, PosRSF - PosXDB) + mid( FullFileName, PosRsf + LenRSF)
 NamingStd_OnComposeFileName = FullFileName
    Else
 ' 2 is log from CadLoader
 ' 3 is sem
 NamingStd_OnComposeFileName = FullFileName
    End if
End Function
 
Last modified: May 24th 2005
 
Once you object is build modify the PDMInterface setting to set it to the ProdID or the CLSID of you own object.
 
Take care that it becomes your responsability to ensure that file names are distinct if you are given distinct model number or TargetPartNumber.
 
Technical Notes

Wiki Home