├── README.md ├── add_layer_name.form └── add_layer_name.il /README.md: -------------------------------------------------------------------------------- 1 | ### About 2 | This script will automatically add subclass name to the selected layers 3 | 4 | This script is for Cadence Allegro software. Tested with Allegro 17.2 5 | 6 | Created by Robert Feranec 7 | 8 | (c) 2017 FEDEVEL, https://www.fedevel.com/academy 9 | 10 | ### Video 11 | Here you can find a detailed video about how to create, run and use this script 12 | [![Script GUI / Dialogue Form](https://user-images.githubusercontent.com/5564443/32172814-2574b7fa-bd3a-11e7-8bdf-52da990275c7.jpg)](https://www.youtube.com/watch?v=qY_MK-_1VWE) 13 | ### Screenshots 14 | #### Script GUI / Dialogue Form 15 | ![Script GUI / Dialogue Form](https://user-images.githubusercontent.com/5564443/31919490-ad7a6e4c-b817-11e7-8d36-093c58fad0e2.png) 16 | #### Before running the script 17 | ![Before running the script](https://user-images.githubusercontent.com/5564443/31919557-2c608476-b818-11e7-97d5-5552fb464f4c.png) 18 | #### After running the script 19 | Notice the added layer name in the bottom left corner 20 | ![After running the script - notice the added layer name in the bottom left corner](https://user-images.githubusercontent.com/5564443/31919566-355eb818-b818-11e7-8fa8-958385825828.png) 21 | #### Detail of the automatically added layer name 22 | ![Detail of the automatically added layer name](https://user-images.githubusercontent.com/5564443/31919568-3da6e2b6-b818-11e7-9577-cf3b8a4caa70.png) 23 | 24 | ### Installation 25 | To use this script, simply copy the files into your Cadence directory. For example, if your Cadence installation directory is d:\Cadence\SPB_17.2\ then: 26 | * copy *add_layer_name.il* file into: d:\Cadence\SPB_17.2\share\local\pcb\skill\ 27 | * copy *add_layer_name.form* into d:\Cadence\SPB_17.2\share\local\pcb\forms\ 28 | 29 | ### How to load the script 30 | #### Automatically 31 | If you would like to automatically load this script by your Allegro when it starts, do following: 32 | 1. Switch OFF Allegro 33 | 2. Go to: d:\Cadence\SPB_17.2\share\local\pcb\skill\ 34 | 3. Copy *example.ilinit* into *allegro.ilinit* 35 | 4. Start Allegro 36 | 37 | #### Manually (useful for debugging) 38 | This is what you need to do to (re)load the script in the Allegro commad line: 39 | 1. go to skill command mode (only run this once, when you start your allegro): 40 | ``` 41 | skill 42 | ``` 43 | 2. reload the script (do this every time you make any changes in the script) 44 | ``` 45 | load("add_layer_name.il") 46 | ``` 47 | 48 | ### How to run the script 49 | To start the script, run the following command in Cadence Allegro command line or in SKILL mode: 50 | ``` 51 | add_layer_name 52 | ``` 53 | 54 | ### Documentation 55 | Documentation which you may need when you are creating your own scripts or which you may need to understand the commands and features used in this script: 56 | * Allegro skill documentation directory: d:\Cadence\SPB_17.2\doc\algroskill\ 57 | * Content of all Functions: file:///D:/Cadence/SPB_17.2/doc/algroskill/algroskillTOC.html 58 | * Form Interface Functions: file:///D:/Cadence/SPB_17.2/doc/algroskill/11frmint.html 59 | * SKILL Commands: Search on Internet for "Skill Language User Guide", e.g.: http://pwp.gatech.edu/wp-content/uploads/sites/367/2016/03/Intro_to_skill_prog.pdf 60 | 61 | *Note: The absolute PATH depends on your Cadence installation.* 62 | 63 | Examples to create your own scripts (very useful, especially the axlfrom.il) can be found here: 64 | d:\Cadence\SPB_17.2\share\pcb\examples\skill\form\ 65 | 66 | ### Note for me 67 | Here is how to create software links under Windows 7 68 | 69 | You have to start cmd as Administrator. Then run following commands: 70 | 71 | ``` 72 | mklink "d:\Cadence\SPB_17.2\share\local\pcb\forms\add_layer_name.form" "d:\Users\Robo\Code\allegro\scripts\add_layer_name\add_layer_name.form" 73 | mklink "d:\Cadence\SPB_17.2\share\local\pcb\skill\add_layer_name.il" "d:\Users\Robo\Code\allegro\scripts\add_layer_name\add_layer_name.il" 74 | ``` 75 | -------------------------------------------------------------------------------- /add_layer_name.form: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | #This file is part of add_layer_name script for Allegro 17.2 3 | # 4 | #Created by Robert Feranec 5 | #(c) 2017 FEDEVEL, https://www.fedevel.com/academy 6 | # 7 | #Download the script: https://github.com/FEDEVEL/allegro-script-add_layer_name 8 | #-------------------------------------------------------------------- 9 | 10 | #If your Cadence installation directory is d:\Cadence\SPB_17.2\ 11 | #then copy this file into: d:\Cadence\SPB_17.2\share\local\pcb\forms\ 12 | 13 | #Documentation 14 | #More information about commands used in this form: file:///D:/Cadence/SPB_17.2/doc/algroskill/11frmint.html#414284 15 | 16 | FILE_TYPE=FORM_DEFN VERSION=2 17 | 18 | FORM AUTOGREYTEXT 19 | FIXED 20 | PORT 64 100 21 | HEADER "FEDEVEL Commands" 22 | 23 | POPUP "PLACEHOLDER""0". 24 | 25 | TILE 26 | #====================== 27 | 28 | #simple text, the text is bold, position of text 2,1 (x,y) 29 | TEXT "Add Layer Name to the Selected Layers" 30 | OPTIONS BOLD 31 | TLOC 2 1 32 | ENDTEXT 33 | 34 | TEXT "This command will automatically add Layer name into the selected layers." 35 | TLOC 2 3 36 | ENDTEXT 37 | 38 | #group, starts at 2,5 and has 60 18 (height width) size 39 | GROUP "Select Layers" 40 | FLOC 2 5 41 | FSIZE 60 18 42 | INFO group 43 | ENDGROUP 44 | 45 | TEXT "TOP" 46 | FLOC 5 7 47 | ENDTEXT 48 | 49 | #list 50 | FIELD subclass_top 51 | FLOC 5 9 52 | LIST "" 25 7 53 | OPTIONS multiselect prettyprint 54 | ENDFIELD 55 | 56 | TEXT "BOTTOM (Mirrored)" 57 | FLOC 35 7 58 | ENDTEXT 59 | 60 | #list 61 | FIELD subclass_bottom 62 | FLOC 35 9 63 | LIST "" 25 7 64 | OPTIONS multiselect prettyprint 65 | ENDFIELD 66 | 67 | #group 68 | GROUP "Options" 69 | FLOC 2 23 70 | FSIZE 60 5 71 | INFO group 72 | ENDGROUP 73 | 74 | TEXT "Text Size:" 75 | FLOC 5 25 76 | ENDTEXT 77 | 78 | #drop down box 79 | FIELD font_size 80 | FLOC 13 25 81 | ENUMSET 12 82 | POP "FONTSIZES" 83 | ENDFIELD 84 | 85 | TEXT "Position (X:Y):" 86 | FLOC 35 25 87 | ENDTEXT 88 | 89 | #text input field, STRFILLIN = of the input filed and maximum number of characters which can be written 90 | FIELD text_position_x 91 | FLOC 46 25 92 | STRFILLIN 5 10 93 | ENDFIELD 94 | 95 | TEXT ":" 96 | FLOC 53 25 97 | ENDTEXT 98 | 99 | #text input field 100 | FIELD text_position_y 101 | FLOC 54 25 102 | STRFILLIN 5 10 103 | ENDFIELD 104 | 105 | #button 106 | FIELD done 107 | FLOC 10 30 108 | MENUBUTTON "Press this button to add names to the selected layers" 10 3 109 | ENDFIELD 110 | 111 | #this is just to add bottom padding 112 | GROUP "" 113 | FLOC 1 32 114 | FSIZE 0 1 115 | ENDGROUP 116 | 117 | #====================== 118 | ENDTILE 119 | 120 | ENDFORM -------------------------------------------------------------------------------- /add_layer_name.il: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------- 2 | ;This script will automatically add subclass name to the selected layers 3 | ;This script is for Cadence Allegro software. Tested with Allegro 17.2 4 | ;Created by Robert Feranec 5 | ;(c) 2017 FEDEVEL, https://www.fedevel.com/academy 6 | ; 7 | ;Download the script: https://github.com/FEDEVEL/allegro-script-add_layer_name 8 | ;-------------------------------------------------------------------- 9 | 10 | ;Location of this file 11 | ;If your Cadence installation directory is d:\Cadence\SPB_17.2\ 12 | ;then copy this file into: d:\Cadence\SPB_17.2\share\local\pcb\skill\ 13 | ;IMPORTANT: Do not forget. This script also requires add_layer_name.form file. 14 | 15 | ;How to load the script 16 | ;This is what you need to do to (re)load the script in the Allegro commad line: 17 | ;1) go to skill command mode (only run this once, when you start your allegro): 18 | ;skill 19 | ;2) reload the script 20 | ;load("add_layer_name.il") 21 | 22 | ;How to run the script 23 | ;1) Run following command in Cadence Allegro command line: 24 | ;add_layer_name 25 | 26 | ;Documentation 27 | ;Documentation which you may need to create your own scripts or understand the commands and features used here: 28 | ;Note: The absolute PATH depends on your Cadence installation. 29 | ;Allegro skill documentation directory: d:\Cadence\SPB_17.2\doc\algroskill\ 30 | ;Content of all Functions: file:///D:/Cadence/SPB_17.2/doc/algroskill/algroskillTOC.html 31 | ;Form Interface Functions: file:///D:/Cadence/SPB_17.2/doc/algroskill/11frmint.html 32 | ;SKILL Commands: Search on Internet for "Skill Language User Guide", e.g.: http://pwp.gatech.edu/wp-content/uploads/sites/367/2016/03/Intro_to_skill_prog.pdf 33 | 34 | ;Examples to create your own scripts (very useful, especially the axlfrom.il) 35 | ;d:\Cadence\SPB_17.2\share\pcb\examples\skill\form\ 36 | 37 | ;NOTE 38 | ;If you would like to automatically load this script by your Allegro when it starts, do following: 39 | ;1) Go to: d:\Cadence\SPB_17.2\share\local\pcb\skill\ 40 | ;2) Copy "example.ilinit" into "allegro.ilinit" 41 | ;3) Copy "add_layer_name.il" to d:\Cadence\SPB_17.2\share\local\pcb\skill\ 42 | ;4) Copy "add_layer_name.form" to d:\Cadence\SPB_17.2\share\local\pcb\forms\ 43 | 44 | ;----------------------------- THE SCRIPT --------------------------------------- 45 | 46 | ;Print a note in Allegro commadn line when this script is loaded 47 | print "Loading add_layer_name. Created by Robert Feranec (c) 2017 FEDEVEL" 48 | 49 | ;register this command, so we can start it from Allegro command line 50 | axlCmdRegister( "add_layer_name" `add_layer_name) 51 | 52 | ;When anything happen in our form, this function is called (e.g when you do any chages in the form or when you press button) 53 | (defun _afAddLayerNameCallback (fw) 54 | (prog (t1 item field cnt) 55 | 56 | if((fw->doneState == 1) then ;we pressed our done button Note: 0 = action; 1 = done; 2 = cancel; 3 = abort, more info at file:///D:/Cadence/SPB_17.2/doc/algroskill/11frmint.html#428663 57 | 58 | axlUIWPrint(nil "Adding layer names ...") ;console printing 59 | 60 | ;prepare position where the text will be added (the position is stored in list of floating x and y) 61 | position_list = '() ; create an empy list 62 | position_x = atof(axlFormGetField(fw "text_position_x")) ;get the x position and convert string to float 63 | position_y = atof(axlFormGetField(fw "text_position_y")) ;get the y position and convert string to float 64 | position_list = cons(position_y position_list) ;add x to the list 65 | position_list = cons(position_x position_list) ;add y to the list 66 | 67 | ;TOP Layers (text is not mirrored) 68 | selected_layers = axlFormListGetSelItems(fw "subclass_top") ;get all the layers selected in subclass_top list 69 | myorient = make_axlTextOrientation(?textBlock axlFormGetField(fw "font_size"), ?rotation 0.0,?mirrored nil, ?justify "left") ;set the text property 70 | 71 | foreach(selected_layer selected_layers ;go through every selected layer in subclass_top list 72 | axlDBCreateText( selected_layer, position_list, myorient, strcat("manufacturing/" selected_layer), nil) ; add the subclass name to the layer 73 | ) 74 | 75 | ;BOTTOM Layers (text is mirrored) 76 | selected_layers = axlFormListGetSelItems(fw "subclass_bottom") ;get all the layers selected in subclass_bottom list 77 | myorient = make_axlTextOrientation(?textBlock axlFormGetField(fw "font_size"), ?rotation 0.0,?mirrored t, ?justify "right") ;set the text property 78 | 79 | foreach(selected_layer selected_layers ;go through every selected layer in subclass_bottom list 80 | axlDBCreateText( selected_layer, position_list, myorient, strcat("manufacturing/" selected_layer), nil) ; add the subclass name to the layer 81 | ) 82 | 83 | axlUIWPrint(nil "Done") ;console printing 84 | axlFormClose(fw) 85 | ) 86 | return() 87 | ) 88 | ) 89 | 90 | ;------------------------------------- 91 | ;Definition of add_layer_name command 92 | ;------------------------------------- 93 | procedure( add_layer_name() 94 | ;define constants 95 | TOP_VARIANT_NAME_SUBSTRING = "VARIANT_T" 96 | BOTTOM_VARIANT_NAME_SUBSCTRING = "VARIANT_B" 97 | DEFAULT_TEXT_BLOCK_NAME = "Standard" 98 | DEFAULT_CLASS = "MANUFACTURING" 99 | DEFAULT_TEXT_POSITION = "0:-2" 100 | VERSION = "Version 0.1" 101 | 102 | axlUIWPrint(nil "Starting add_layer_name script.") ;console printing 103 | 104 | ;create the form 105 | fw = axlFormCreate( (gensym) "add_layer_name.form" nil '_afAddLayerNameCallback t nil) 106 | 107 | ;NOTE: this is currently hardcoded for "MANUFACTURING" class, but if people are interested, a class selection drop down box can be added in new script version 108 | variants = axlSubclasses( axlMapClassName(DEFAULT_CLASS)) ;get list of all subclasses in MANUFACTURING class 109 | 110 | ;prepare and pre-select TOP 111 | axlFormSetField(fw "subclass_top" variants) ;fill up TOP list with all the subclasses 112 | foreach(variant variants ;go through the list and pre-select all layers which contain variant substring e.g. if there is "VARIANT_T" in subclass name 113 | if(rexMatchp(TOP_VARIANT_NAME_SUBSTRING variant)==t then 114 | axlFormListSelect(fw "subclass_top" variant) 115 | ) 116 | ) 117 | 118 | ;prepare and pre-select BOTTOM 119 | axlFormSetField(fw "subclass_bottom" variants) ;fill up BOTTOM list with all the subclasses 120 | foreach(variant variants ;go through the list and pre-select all layers which contain variant substring e.g. if there is "VARIANT_B" in subclass name 121 | if(rexMatchp(BOTTOM_VARIANT_NAME_SUBSCTRING variant)==t then 122 | axlFormListSelect(fw "subclass_bottom" variant) 123 | ) 124 | ) 125 | 126 | ;prepare some variables 127 | numTextBlocks = axlDBGetTextBlockCount() ;get number of all text box sizes 128 | text_sizes_list = '() ;we are going to prepare list of all text sizes 129 | preselected_text_size = "" ; default text size 130 | 131 | ;prepare list of all the available text boxes (list of all available fonts) 132 | i = numTextBlocks 133 | while( i > 0 134 | 135 | ;"cons", the compand which we will be using later, doesnt like "nil", so if font name is empty, set it to " " 136 | text_name = axlDBTextBlockGetName(i) ;based on text block number, get name of the font 137 | if(text_name==nil then 138 | text_name = " " 139 | ) 140 | 141 | ;create a temporary list with block number/name and its position. It will look like ("#1 Name" "i") 142 | tmp_list = '() 143 | tmp_list = cons(sprintf(nil "%d" i) tmp_list) 144 | tmp_list = cons(sprintf(nil "#%d %s" i text_name) tmp_list);build the list, looks like ("#1 Name" "i") 145 | 146 | ;now, add this tempary list into our main list with the text sizes 147 | text_sizes_list = cons(tmp_list text_sizes_list) ;the list will look like ("#1 Name" "1")("#2 Name" "2") ... 148 | 149 | ;remember the default font position in the list, it will be pre-selected later 150 | if(text_name==DEFAULT_TEXT_BLOCK_NAME then 151 | preselected_text_size = sprintf(nil "%d" i) 152 | ) 153 | i-- 154 | ) 155 | ;axlUIWPrint(nil sprintf(nil "%L" text_sizes_list)) ;console printing, just an example how to print list .. in case we need it :) 156 | 157 | ;fill up and preselect font sizes 158 | axlFormBuildPopup(fw "fontsizes" text_sizes_list ) ; update list of text sizes 159 | axlFormSetField(fw "font_size" preselected_text_size ) ; pre-select the text size 160 | 161 | ;default text position 162 | axlFormSetField(fw "text_position_x" "0" ) 163 | axlFormSetField(fw "text_position_y" "-2" ) 164 | 165 | ;display the form 166 | axlFormDisplay(fw) 167 | 168 | axlUIWPrint(fw VERSION) ;Write into the status bar of the form, add there version info 169 | ) --------------------------------------------------------------------------------