AnsweredAssumed Answered

Runtime Error during general edit of library with help of a script

Question asked by bollenberg on Dec 11, 2017
Latest reply on Dec 12, 2017 by Patrick.Cashman

Dear all,

 

I would like to edit all cells of a library. Here, every cell should get a part property text.

 

The following script should do this automatically (subroutines are not shown below):

 

OptionExplicit

'global constants (the unitsEnum of all the constants below are in mm)
Const strFont = "Arial"
Const realPenWidth = 0.05


'global variables
Dim objLibraryApp
Dim objLibraryDoc
Dim objCellEditor
Dim objCellDB
Dim strCellPartition

Dim objActivePartition
Dim objActiveCell

Dim objActiveCellDoc
Dim objActiveCellApp

Dim objLayerText
Dim objLayerTextToDelete
Dim objLayerTextCollection
Dim objUserDraftLayer

Dim objTextColToFormat
Dim realHeight

'add type libraries
Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

Scripting.AddTypeLibrary ("MGCPCBLibraries.CellEditorDlg")
Scripting.AddTypeLibrary("CellEditorAddin.CellEditorDlg")


Set objLibraryApp = Application                                                                ' Get the Application object 

Set objLibraryDoc = objLibraryApp.ActiveLibrary                                                ' Get the active document 

strCellPartition = InputBox("Please enter cell partition!")

Set objCellEditor = objLibraryDoc.CellEditor                                                        ' Get the Cell Editor 

Set objCellDB = objCellEditor.ActiveDatabase                                                        ' Get the Cell database for the design 
ForEach objActivePartitionIn objCellDB.Partitions
    If objActivePartition.Name = strCellPartitionThen                                             ' Focus on Cell-Partition to be edited
        ForEach objActiveCellIn objActivePartition.Cells                                         ' Get Cell-Object from Cell-Collection
            Set objActiveCellDoc = objActiveCell.Edit()                                             ' Open Cell-Editor
            Set objActiveCellApp = objActiveCellDoc.Application                                   ' Get Application Object within Cell-Editor
            objActiveCellApp.Visible = True
            IfInStr(1,objActiveCellDoc.Name,"CAP",vbTextCompare) Then                           ' Check kind of Cell --> CAP = Capacitor
                Foreach objUserDraftLayerin objActiveCellDoc.UserLayers                        
                    SelectCase objUserDraftLayer.Name
                    Case"Assembly Items Value"                                                        ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                    Case"Assembly Items Value Top"                                                    ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                        Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0.5,epcbTextPartProperty,_

                                                objUserDraftLayer,Nothing,epcbUnitCurrent)   
                        objLayerTextCollection.DisplayCondition = 2
                        Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                    Case"Assembly Items Value Bottom"                                                ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                        Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0.5,epcbTextPartProperty,_

                                                objUserDraftLayer,Nothing,epcbUnitCurrent)   
                        objLayerTextCollection.DisplayCondition = 3
                        Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                    Case"Assembly Items Voltage"                                                    ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                 Case"Assembly Items Voltage Top"                                                ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                        Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Voltage",0,-0.5,epcbTextPartProperty,_

                                                objUserDraftLayer,Nothing,epcbUnitCurrent) 
                        objLayerTextCollection.DisplayCondition = 2
                        Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                    Case"Assembly Items Voltage Bottom"                                            ' Check UserDraftLayer
                        Call Delete_UserDraftLayer_Text(objUserDraftLayer)                           ' Delete UserDraftLayer-Text
                        Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Voltage",0,-0.5,epcbTextPartProperty,_

                                                objUserDraftLayer,Nothing,epcbUnitCurrent) 
                        objLayerTextCollection.DisplayCondition = 3
                        Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                    EndSelect
                Next
            Else
                IfInStr(1,objActiveCellDoc.Name,"RES",vbTextCompare) Then                            ' Check kind of Cell --> RES = Capacitor
                    Foreach objUserDraftLayerin objActiveCellDoc.UserLayers                      
                        SelectCase objUserDraftLayer.Name
                        Case"Assembly Items Value"                                                    ' Check UserDraftLayer
                            Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                        Case"Assembly Items Value Top"                                                ' Check UserDraftLayer
                            Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                            Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0,epcbTextPartProperty,_

                                                    objUserDraftLayer,Nothing,epcbUnitCurrent) 
                            objLayerTextCollection.DisplayCondition = 2
                            Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                        Case"Assembly Items Value Bottom"                                            ' Check UserDraftLayer
                            Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                            Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0,epcbTextPartProperty,_

                                                    objUserDraftLayer,Nothing,epcbUnitCurrent) 
                            objLayerTextCollection.DisplayCondition = 3
                            Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                        EndSelect
                    Next
                Else
                    IfInStr(1,objActiveCellDoc.Name,"IND",vbTextCompare) Then                        ' Check kind of Cell --> IND = Capacitor
                        Foreach objUserDraftLayerin objActiveCellDoc.UserLayers                
                            SelectCase objUserDraftLayer.Name
                            Case"Assembly Items Value"                                                ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                            Case"Assembly Items Value Top"                                            ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0.5,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent) 
                                objLayerTextCollection.DisplayCondition = 2
                                Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                            Case"Assembly Items Value Bottom"                                        ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Value",0,0.5,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent)
                                objLayerTextCollection.DisplayCondition = 3
                                Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                            Case"Assembly Items Current"                                            ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                            Case"Assembly Items Current Top"                                        ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Current",0,-0.5,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent)
                                objLayerTextCollection.DisplayCondition = 2
                                Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                            Case"Assembly Items Current Bottom"                                    ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                   ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Current",0,-0.5,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent)
                                objLayerTextCollection.DisplayCondition = 3
                                Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                            EndSelect
                        Next
                    Else
                        Foreach objUserDraftLayerin objActiveCellDoc.UserLayers                    
                            SelectCase objUserDraftLayer.Name
                            Case"Assembly Items Technology"                                            ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                            Case"Assembly Items Technology Top"                                        ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Technology",0,0,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent)
                                objLayerTextCollection.DisplayCondition = 2
                                Call Set_Text_Format_Top(objLayerTextCollection,0.5)
                            Case"Assembly Items Technology Bottom"                                        ' Check UserDraftLayer
                                Call Delete_UserDraftLayer_Text(objUserDraftLayer)                       ' Delete UserDraftLayer-Text
                                Set objLayerTextCollection = objActiveCellDoc.PutUserLayerTextEx("Technology",0,0,epcbTextPartProperty,_

                                                       objUserDraftLayer,Nothing,epcbUnitCurrent) 
                                objLayerTextCollection.DisplayCondition = 3
                                Call Set_Text_Format_Bottom(objLayerTextCollection,0.5)
                            EndSelect
                        Next
                    EndIf
                EndIf
            EndIf
            objActiveCellDoc.Save
            objActiveCellDoc.Close (False)
            Set objActiveCellApp = Nothing
            Set objActiveCellDoc = Nothing
        Next
    Else
    EndIf
Next

objCellEditor.Quit()
Set objCellEditor = Nothing

MsgBox ("Edit of cells within partition --> " & strCellPartition & " <-- is finished")  

 

If I use this script for a partition with round about fifty cells....there ist no problem. But if I use this scipt for a partion with more than 100 cells, after a certain time of running the script, I get a runtime error and the script is aborted. The script does not always break off at the same location of the script.

Has anybody an idea?

Outcomes