Support Forum

Array of element definition and indexing

Luca

Thursday 11th July 2024
I would like to define an array of element * in order to easly refer to the created element by exploiting the array index. Unfortunately element type cannot be used as array and also it seems not possible to define a struct in the layout editor script ( "Unknown identifier struct" ). The elementList class is not useful because only nextElement and thisElement functions are present and it is not defined a function to address by the index. How can I manage it? Many thanks Best regards Luca
Jürgen
LayoutEditorFull
Friday 12th July 2024
You are right. The definition of a *struct* is not supported and there is no type to store pointers as array. In a cell the elements are stored as a linked list. Some operations may insert new elements in the middle of that list. That makes an indexing impossible as such operations will break the index. Even some operations will make some pointers to the elements invalid. For example if you convert a box to a polygon the pointer to the box will not be valid afterwards. For that reason I recommend not to store any element pointer for a longer time. Always get the actual pointer from one of the methods of the *cell* class and disregards the pointer afterwards. To identify an element you may set the datatype and get its pointer by calling *selectDatatype()* and *selectedElement(NULL)*.