; 1. Load this script file into PCB Editor ; load("./MakeTOC.il") ; 2. Execute testbrokencleanup() ; A TOC-symbol appears in the top left corner of your design ; No message about matching symbols or symdefs appear - this is expected behaviour ; 3. Execute testbrokencleanup() again. ; Expected behaviour: Both symbol and symdef is found and then removed, then a new TOC-symbol appears ; Observed behaviour: Neither symbol nor symdef is found or removed. The TOC was placed. ; Additional observation: A remnant of the symbol is placed at 0,0. The remnant is not recognized as a symbol, but contains all the lines and text of the original symbol, but none of the text or shapes that were added later. ; 4. Manual Cleanup: Use General Edit to select the symbol and remnant (text and lines) respectively, and remove them. The Symbol is removed with "Unplace Component" and the remnant is removed by selecting all artifacts and then "Delete". ; 5. Execute testbrokencleanup() again. ; Expected behaviour: No symbol nor symdef is recognized. The TOC is placed ; Observed behaviour: A message is displayed that a Symbol was found. The TOC was placed. ; 6. Manually delete the symbol like you did in step 4 ; 7. Execute testbrokencleanup() again. ; Now there is no message indicating that any symbol or symdef exists procedure(drawRectShape(llx lly urx ury layer) path = axlPathStart(list( llx:lly llx:ury urx:ury urx:lly llx:lly )) axlDBCreateShape(path t layer nil) );procedure procedure( testbrokencleanup() layer = "DRAWING FORMAT/NSCOLOR_LEGEND" ; Create list of items and colors input_list = makeTable("colorlist" nil) input_list["Item A"] = 16 input_list["Item B"] = 32 input_list["Item C"] = 48 input_list["Item D"] = 64 input_list["Item E"] = 96 ; ################################ ; Attempt to clean up the design ; ################################ ; Clean up symbols slist = axlDBGetDesign()->symbols foreach(sid slist when(sid->name && lowerCase(sid->name) == "_my_name" printf("I have found a matching Symbol with name: %L\n" sid->name) foreach(cid sid->children axlDeleteObject(cid) ) axlDeleteObject(sid) ) ) ; Clean up symbol definitions slist = axlDBGetDesign()->symdefs foreach(sid slist when(sid->name && lowerCase(sid->name) == "_my_name" printf("I have found a matching Symbol Definition with name: %L\n" sid->name) foreach(inst sid->instances axlDeleteObject(inst) ) ) ) ; ################################ ; Prepare Symbol ; ################################ ; Headers columna = "COLUMN A" columnb = "COLUMN B" ; Get Character dimension properties tblockno = 2 text = axlGetParam(strcat("paramTextBlock:" sprintf(nil "%d" tblockno))) charHeight = text->height ; Height of the text charWidth = text->width ; Width of a character charSpacing = text->charSpace ; Space between characters charThickness = text->photoWidth ; Width of the "pen" writting the letter textloc = make_axlTextOrientation(?textBlock tblockno, ?rotation 0.0, ?mirrored nil, ?justify "left") ; Table Dimensions linew = axlMKS2UU("0.15 millimeters") ; Width of a line in the table items = length(input_list) ; Number of items in the legend tableheight = (items + 1)* charHeight * 2 ctotwidth = (charSpacing + charWidth + charThickness + charSpacing) ; The total width of a character, with space between the chars tablewidth = charSpacing + ctotwidth * strlen(columna) + ctotwidth * strlen(columnb) + charSpacing llx = 0 lly = 0 - tableheight px = llx + charSpacing + charWidth ; X where the text in the first column is written tx = px + strlen(columna) * ctotwidth + charSpacing + charSpacing ; X where the text in the second column is written ly = 2 * charHeight ; offset required to shift to the next cell in a column urx = 0 + tablewidth ury = 0 ; Defining the "drawing area" of the symbol. the 2* linew is a buffer to avoid issues with fat lines symextend = list(llx - 2 * linew : lly - 2 * linew urx + 2 * linew : ury + 2 * linew) ; Initialize layer when(axlIsLayer(layer) axlDeleteByLayer(layer) my_layer = axlLayerGet(layer) axlDeleteObject(my_layer) ) axlLayerCreateNonConductor(layer) axlVisibleLayer(layer t) axlVisibleUpdate(t) ; ################################ ; Create Symbol and Symdef ; ################################ ; Initialize symdef (This draws a table with two columns and 6 items, including header) symdef = axlDBCreateSymDefSkeleton('("_my_name" "mechanical") symextend) axlDBCreateLine(list(llx:lly llx:ury) linew layer 'line symdef) axlDBCreateLine(list(llx:ury urx:ury) linew layer 'line symdef) axlDBCreateLine(list(urx:ury urx:lly) linew layer 'line symdef) axlDBCreateLine(list( llx + charSpacing + ctotwidth * strlen(columna) + charSpacing: lly llx + charSpacing + ctotwidth * strlen(columna) + charSpacing:ury) linew layer 'line symdef) axlDBCreateText(columna px:ury - 1.5 * charHeight textloc layer symdef) axlDBCreateText(columnb tx:ury - 1.5 * charHeight textloc layer symdef) for( i 1 length(input_list)+1 axlDBCreateLine( list( llx : ury - i * ly urx : ury - i * ly ) linew layer 'line symdef) ) tablex = caar(axlExtentDB('windowfit)) tabley = caadr(axlExtentDB('windowfit)) ; Place the symbol symboldbid = axlDBCreateSymbol('("_my_name" "MECHANICAL") tablex:tabley) ; Add text and shapes to the symbol item = 1 foreach(key input_list textdbid = axlDBCreateText(key tablex + px:tabley + ury - 1.5 * charHeight - item * ly textloc layer) axlSymbolAttach(car(symboldbid) car(textdbid)) ; attach text to symbol ; Create the shape colorShapedbid = drawRectShape(tablex + tx tabley + ury - 1.5 * charHeight - item * ly tablex + tx + ctotwidth * 3.5 tabley + ury - 0.5 * charHeight - item * ly layer) ; Remove the group members if the group already exists. Otherwise, create the group grpName = strcat("_my_name" key) grp = car(axlSelectByName("GROUP" grpName nil)) axlClearSelSet() if( grp then when(grp axlDeleteObject(grp->groupMembers)) else grp = axlDBCreateGroup(grpName "generic" nil) ) when(colorShapedbid axlDBAddGroupObjects(grp car(colorShapedbid)) ) axlSymbolAttach(car(symboldbid) car(colorShapedbid)) axlCustomColorObject(grp input_list[key]) axlDBAddProp(list(car(colorShapedbid)) list("NSCOLOR" key)) item++ ) t )