0 Replies Latest reply on Nov 30, 2015 5:58 AM by mark.postema

    CellEditor startup/edit from xPCB

    mark.postema

      Hello,

       

      I am developing in Visual Basic 2010 Express. We have done most of our scripting using Forms (.efm) and VBScript for xPCB. I am having trouble editing a cell after CellEditor is started (and visible) from xPCB Layout.

       

      I may be overlooking something very obvious here...

       

      I already have:

      -Set references in VBE (MGCPCB*.tlb and Cell*.tlb)

      -Connected to xPCB

      -Validated the license token

      -Set the ActiveDatabase

      -Looped the Partitions (only 1)

      -Looped the Cells

      -Started CellEditor and made it visible

       

      This works (code snippet I found) in VBScript:

      '  Get the Cell Editor object from the PCB document
      Set cellEdObj = oPCBdoc.CellEditor
      '  Set the Cell Editor to be visible so we can see it
      cellEdObj.Visible = False
      Set cellDB = cellEdObj.ActiveDatabase

      '  Loop through all of the Cell Partitions
      ForEach PartIn cellDB.Partitions
          '  Loop through all of the Cells in each Partition
          ForEach CellIn Part.Cells
              If Cell.Name = "P47F_NO_HS"Then
                  '  Call the Cell Graphics Editor
                  Set cellDoc = Cell.Edit()
                  MsgBox("Edit")
                  Set cellApp = cellDoc.Application
                  '  Make sure the Cell Graphics Editor is visible
                  cellApp.Visible = True
                  MsgBox("Visible")
                  '  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)
                  MsgBox("Close")
                  '  Do some clean up
                  Set cellApp = Nothing
                  Set cellDoc = Nothing
              EndIf
          Next
      Next

      '  Close the Cell Editor
      cellEdObj.Quit
      Call oPCBapp.Gui.StatusBarText("Done.")

      This VBE code fails at the Edit:

              ' open CellEditor and close it

              'Dim oCellED As CellEditorAddinLib.CellEditorDlg

              'Dim oCellDB As CellEditorAddinLib.CellDB

              oCellED = CType(oPCBDoc.CellEditor, CellEditorAddinLib.CellEditorDlg)

              oCellED.Visible = True

              oCellDB = oCellED.ActiveDatabase

       

       

              Console.Write(vbCrLf & oCellDB.Partitions.Count)

              For z As Integer = 1 To oCellDB.Partitions.Count

                  oPart = oCellDB.Partitions.Item(z)

                  Console.Write(vbCrLf & oPart.Name.ToString)

       

                  Console.Write(vbCrLf & oPart.Cells.Count)

                  For y As Integer = 1 To oPart.Cells.Count

                      oCell = oPart.Cells.Item(y)

                      Console.Write(vbCrLf & oCell.Name.ToString)

       

                      oCellDoc = CType(oCell.Edit, CellEditorAddinLib.Cell)

                      oCellGFX = CType(oCellDoc.Edit, CellEditorAddinLib.CellEditorDlg)

       

                      'oCellDoc.Visible = True

                      oCellGFX.Visible = True

       

                      'MsgBox("OPEN")

       

                      'oCellDoc.Quit()

                      oCellGFX.Quit()

       

                  Next

       

              Next

       

              MsgBox("OPEN")

              oCellED.Quit()