Part Editor : Batch Part Library Editor

Version 11

    The EditLibraryParts.vbs script provides the mechanics for Editing Parts in the Central Library's Parts Partition. It begins by compiling a list of partitions and parts to process. It does this in a way that allows you to easily customize the resulting compilation by allowing you to define and specify filter functions that specifiy whether or not to include or exclude a partition and part. After compilation it will execute the edit process which will open each part and feed its part object to an edit function that you define and specify. This function is required to return a true or false value to indicate whether or not to save the Complete Parts Database as a result of any one part edit. It is not possible to save just one part - all parts must be saved. Below is an example use of the Subroutine "EditCLParts" that is included in the script and the functions that it uses, specified and defined by you.

     

    'Modify the call to EditCLParts to specify your

    'Partition Filter Function name (IE "myPartitionFilter")

    'Part Filter Function name (IE "myPartFilter")

    'Editor Function name (IE "EditPart")

    'Do not change the Subroutine name "main()"

    Sub main()
         EditCLParts libPath & libName,"myPartitionFilter","myPartFilter","EditPart"
    End Sub

     

    'Define your Partition Filter Function

    'Return True to include

    'This example excludes all partitions except the "darpa" partition

    Function myPartitionFilter(oPartition)

    myPartitionFilter=False

         If oPartition.Name="darpa" Then myPartitionFilter=True

    End Function

     

    'Define your Part Filter Function

    'Return True to include

    'This example includes only those parts with a part name that is not prefixed with "DARPA_"

    Function myPartFilter(oPart)

         myPartFilter=False

         If Not InStr(oPart.Name,"DARPA_")=1 then myPartFilter=True

    End Function

     

    'Define your Editor

    'Return True to save the entire Parts DB.

    'This example modifies the existing Part Name and Description by inserting the Word "DARPA_" at the beginning of the Name and "DARPA: " at the beginning of the Description.

    Function EditPart(oPart)

         EditPart=True

         oPart.Name="DARPA_" + oPart.Name

         oPart.Description="DARPA: " + oPart.Description

    End Function

     

    At the top of the script is a Const DBUG=0 statement that controls the maximum number of parts to process where 0=All. This will allow you to minimize the runtime for debug purposes.

     

    The script may be executed one of two ways:

    1) Executed via "mgcscript" in a windows command prompt with the Pathname of the library given as the sole argument:

                    "mgcscript C:\VBScripts\EditLibraryParts.vbs C:\Libraries\20078\Library.lmc"

    2) Open the script in IDE - Library Manager's File->Open Script Form and execute the "Play" button. However, this may require an Automation Pro license. It does in Expedition/FablinkXE/Drawing Editor.


    The script will write to "EditCLParts.txt" in the library's LogFile directory. Use this file to determine status of the run. Use an editor to view the file that will open files in use, ie Notepad.exe. When completed, this file will open in Notepad.

     

    HINT: when writing/debugging your Editor Function, do so first in a separate script. Otherwise, it will take considerably longer for debug.

     

    NEW VERSION: Removed Comment from execution of EditPartLib statement.