5 Replies Latest reply on Aug 1, 2016 12:16 AM by MaBUa

    VX1.2 - Script - CellEditorGRAPHICS - Adding "Property_Text" in BATCH

    MaBUa

      Hello all,

      help me please.

      I need add to all my cells a new Property_Text property in batch by a script. (The result is on the picture - made manually).

      It is not possible to do by ALE.

      I didn't find a DATA MODEL for CELL EDITOR GRAPHICS.

       

      Many thanks

      Martin

        • 1. Re: VX1.2 - Script - CellEditorGRAPHICS - Adding "Property_Text" in BATCH
          andrew.french

          this is in C#

          //Create handle to the cell editor using the library specified in the global variables section
                      CellEditorAddinLib.CellEditorDlg cellEd = new CellEditorAddinLib.CellEditorDlg();
                      CellEditorAddinLib.CellDB cellDB = cellEd.OpenDatabase(lib, false);
          
          
                      //Get the collection of partitions in the library and iterate through them
                      CellEditorAddinLib.Partitions partitions = cellDB.get_Partitions();
                      foreach (CellEditorAddinLib.Partition p in partitions)
                      {
                          //Get the collection of cells in the current partition and iterate through them
                          CellEditorAddinLib.Cells cells = p.get_Cells();
                          foreach (CellEditorAddinLib.Cell c in cells)
                          {
          
          
                              //Open the current cell with the Cell Editor and create a handle to it
                              MGCPCB.Document ExpDoc = c.Edit();
                              MGCPCB.Application ExpApp = (MGCPCB.Application)ExpDoc.Application;
                              MGCPCB.EPcbUnit unit = ExpDoc.CurrentUnit;
          
          
                              //Lock the server for better performance
                              ExpApp.LockServer();
          
          
                              //Make all cell edits here
                              
                              
          
          
                              //Release handle on cell editor
                              ExpApp.UnlockServer();
                              ExpDoc.Close(true);  //saves cell
                              ExpDoc = null;
                              ExpApp = null;
          
          
                          } //cells
                      } //partitions
          
          
                      //Save and exit out of the Library and release handles
                      cellEd.SaveActiveDatabase();
                      cellEd.Quit();
                      cellEd = null;
                      cellDB = null;
          
          • 2. Re: VX1.2 - Script - CellEditorGRAPHICS - Adding "Property_Text" in BATCH
            Mike_Walsh

            There is an example of how to perform graphical edits on cells in a "batch" mode in the AATK examples directory (AATK/examples/vbs).  It is called CellEditorLoop.vbs.  The example script does little more than traverse a design's library, open all of the cells, open the graphic editor on each, then close it and proceed.  You would have to "fill in the blank" (see lines 157-159) with your specific edits you want to do on each cell with the proper automation code.

             

            This script runs on an open PCB database but you could probably use the same basic idea to run it from Library Manager.

             

            'Acceptable Usage Policy
            '
            '  This software is NOT officially supported by Mentor Graphics.
            '
            '  ####################################################################
            '  ####################################################################
            '  ## The following  software  is  "freeware" which  Mentor Graphics ##
            '  ## Corporation  provides as a courtesy  to our users.  "freeware" ##
            '  ## is provided  "as is" and  Mentor  Graphics makes no warranties ##
            '  ## with  respect  to "freeware",  either  expressed  or  implied, ##
            '  ## including any implied warranties of merchantability or fitness ##
            '  ## for a particular purpose.                                      ##
            '  ####################################################################
            '  ####################################################################
            '
            ' vim: set expandtab tabstop=4 shiftwidth=4:
            '
            '  I like Vim (http://www.vim.org) as a text editor.  The above line
            '  tells Vim to set the indent to 4 spaces and the tab key to indent
            '  4 spaces.
            ' 
            '  CellEditorLoop.vbs
            '
            '  This automation example will traverse all of the cells contained in
            '  a design and one by one, open the Cell Editor on each one.  After the
            '  Cell Editor is opened, the Graphics Editor is opened.  The purpose of
            '  this script is to demonstrate how to traverse all of Cells in a design
            '  and open the editors such that some editing or reporting operation could
            '  be performed.
            '
            '  This script is run by dragging the file on to a running instance of
            '  Expedition or from the "File->Open Script Form ..." menu.
            '
            '  (c) December 2010 - Mentor Graphics Corporation
            '
            '  Mike Walsh - mike_walsh@mentor.com
            '
            '  Mentor Graphics Corporation
            '  1001 Winstead Drive, Suite 380
            '  Cary, North Carolina 27513
            '
            '  This software is NOT officially supported by Mentor Graphics.
            '
            '  ####################################################################
            '  ####################################################################
            '  ## The following  software  is  "freeware" which  Mentor Graphics ##
            '  ## Corporation  provides as a courtesy  to our users.  "freeware" ##
            '  ## is provided  "as is" and  Mentor  Graphics makes no warranties ##
            '  ## with  respect  to "freeware",  either  expressed  or  implied, ##
            '  ## including any implied warranties of merchantability or fitness ##
            '  ## for a particular purpose.                                      ##
            '  ####################################################################
            '  ####################################################################
            '
            '  Change Log:
            '
            '    12/03/2010 - Initial version.
            '
            
            
            Option Explicit
            
            
            '-------------------------------------------------------------------------
            '  Function that returns a licensed doc object
            '
            '  Returns: 
            '   - 'Nothing' if licensing failed . 
            '   - A reference to the active document of the application if 
            '     licensing succeeded. 
            '-------------------------------------------------------------------------
            Public Function GetLicensedDoc(appObj)
                On Error Resume next
                Dim key,licenseServer,licenseToken,docObj
            
            
                Set GetLicensedDoc = Nothing
            
            
                '  Collect the active document
                Set docObj = appObj.ActiveDocument
                If (Err) Then  
                    Call appObj.Gui.StatusBarText("No active document: " + _
                                                  Err.Description,epcbStatusFieldError)
                    Exit Function
                End If
            
            
                '  Ask Expedition’s document for the key
                key = docObj.Validate(0)
            
            
                '  Get token from license server
                Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
                licenseToken = licenseServer.GetToken(key)
                Set licenseServer = Nothing
            
            
                '  Ask the document to validate the license token
                Err.Clear 
                docObj.Validate(licenseToken)
                If (Err) Then  
                    Call appObj.Gui.StatusBarText("No active document license: " + _
                                                  Err.Description,epcbStatusFieldError)
                    Exit Function
                End If
            
            
                '  Everything is OK, return document
                Set GetLicensedDoc = docObj 
            End Function
            
            
            
            
            '-------------------------------------------------------------------------
            '  CellEditorLoop main routine
            '-------------------------------------------------------------------------
            
            
            Dim app, pcbDoc, appObj
            Dim cellEdObj, cellDB
            Dim Cell, Part
            Dim cellDoc, cellApp
            
            
            '  Connect to the MGCPCB application
            On Error Resume Next
            'Set app = GetObject(, "MGCPCB.Application")
            '  Use Application method, it runs faster!
            Set app = Application
            Call Scripting.AddTypeLibrary("MGCPCB.Application")
            
            
            Set pcbDoc = GetLicensedDoc(app)
            
            
            Call appObj.Gui.StatusBarText("Open Cell Editor.")
            '  Get the Cell Editor object from the PCB document
            Set cellEdObj = pcbDoc.CellEditor
            '  Set the Cell Editor to be visible so we can see it
            cellEdObj.Visible = True
            Set cellDB = cellEdObj.ActiveDatabase
            
            
            '  Loop through all of the Cell Partitions
            For Each Part In cellDB.Partitions
            
            
                '  Loop through all of the Cells in each Partition
                For Each Cell In Part.Cells
                    '  Call the Cell Graphics Editor
                    Set cellDoc = Cell.Edit()
                 Set cellApp = cellDoc.Application
                    '  Make sure the Cell Graphics Editor is visible
                 cellApp.Visible = True
                    '  This is where a real application would do something
                    '  useful.  This example script does nothing but sleep
                    '  for half a second before closing the Graphic Editor.
                    Scripting.Sleep(500)
                    cellDoc.Close(False)
                    '  Do some clean up
                 Set cellApp = Nothing
                 Set cellDoc = Nothing
                Next
            Next
            
            
            '  Close the Cell Editor
            cellEdObj.Quit
            Call appObj.Gui.StatusBarText("Done.")
            
            • 3. Re: VX1.2 - Script - CellEditorGRAPHICS - Adding "Property_Text" in BATCH
              MaBUa

              Helo Mike,

              thanks for your answer.

              But I'm not sure we both talk about the same CellEditor.

              I can script on Cell Editor .. see here:

              (The data model is known.. it is ok)

              CellEditor.jpg

              ------------------------------------------------------------------------------------------------------------------------------------------------

              BUT I need script over the Cell's Graphics items.. e.g. width, height of line, text; cell origin position, pins position, put a property text on specific position and so on. I mean this editor:

              CellEditor_property_text.jpg

               

              Is this editor what you are talking too?

               

              If yes Where to find the DATA MODEL???

              Many Thanks

              Martin

              • 4. Re: VX1.2 - Script - CellEditorGRAPHICS - Adding "Property_Text" in BATCH
                Mike_Walsh

                Cell Editor and Cell Editor Graphics are two different things as you've noted.  The Cell Editor Graphics uses the same data model as Xpedition.  There are some slight quirks to using it but you can do what you want to do.  The script I provide gets to the point where the Cell is open in the Editor.  You would then use Xpedition API calls to operate on the Cell.  The graphic cell editor is essentially a specialized version of Xpedition.

                3 of 3 people found this helpful