Batch Cell Library Editor

Document created by joe_krolla on Oct 13, 2010
Version 1Show Document
  • View in full screen mode

Author (required): Al Layson


Platform/Format:  VBScript


Use case description (required)


The EditLibraryCells.vbs script provides the mechanics for Editing Cells in the Central Library's Cell Partition. It begins by compiling a list of partitions and cells 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 cell. After compilation it will execute the edit process which will open each cell and feed its document 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 cell. Below is an example use of the Subroutine "EditCLCells" that is included in the script and the functions that it uses, specified and defined by you.


'Modify the call to EditCLCells to sepcify your

'Partition Filter Function name (IE "myPartitionFilter")

'Cell Filter Function name (IE "myCellFilter")

'Editor Function name (IE "TextCell")

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

Sub main()
EditCLCells libPath & libName,"myPartitionFilter","myCellFilter","TextCell"
End Sub


'Define your Partition Filter Function

'Return True to include

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

Function myPartitionFilter(oPartition)
If oPartition.Name="smd_conn" Then myPartitionFilter=True
End Function


'Define your Cell Filter Function

'Return True to include

'This example includes every cell except testpoints and jumpers

Function myCellFilter(oCell)
If oCell.Type=epcbCelltypePackage Then
  If Not oCell.PackageGroup=epcbPackageJumper And Not oCell.PackageGroup=epcbPackageTestPoint Then myCellFilter=True
End If
End Function


'Define your Editor

'Return True to save

'This example creates a FabricationLayerText at 0,0 in each cell

Function TextCell(oCellDoc)
Dim tObj
Set tObj=oCellDoc.PutFabricationLayerText("EditCLTest",0,0,epcbFabAssembly,epcbSideMount,.065,0,10,"VeriBest Gerber 0",0,epcbJustifyLeft,epcbJustifyBottom,Nothing,epcbUnitInch,epcbAngleUnitDegrees)
If Not tObj Is Nothing Then TextCell=True
End Function



At the top of the script is a Const DBUG=0 statement that controls the maximum number of cells 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\EditLibraryCells.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

The script will write to "EditCLCells.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. At This posting, it is known that after script "completion" & "Data CellDB Saved", IDE/Libray Manager will crash due to bug in IDE. Hence, I recommend using command prompt until this is fixed.


HINT: when writing/debugging your Editor Function, do so first in a separate script, drag & drop unto an open cell in the cell editor. Otherwise, it will take considerably longer for debug.



Location of the zip file:




Copyright 2010 Mentor Graphics Corporation. All Rights Reserved. Recipients who obtain this code directly from Mentor Graphics use it solely for internal purposes to serve as example Java or Java Script plugins. This code may not be used in a commercial distribution. Recipients may duplicate the code provided that all notices are fully reproduced with and remain in the code. No part of this code may be modified, reproduced, translated, used, distributed, disclosed or provided to third parties without the prior written consent of Mentor Graphics, except as expressly authorized above. THE CODE IS MADE AVAILABLE "AS IS" WITHOUT WARRANTY OR SUPPORT OF ANY KIND. MENTOR GRAPHICS OFFERS NO EXPRESS OR IMPLIED WARRANTIES AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR WARRANTY OF NON-INFRINGEMENT. IN NO EVENT SHALL MENTOR GRAPHICS OR ITS LICENSORS BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS) WHETHER BASED ON CONTRACT, TORT OR ANY OTHER LEGAL THEORY, EVEN IF MENTOR GRAPHICS OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.