Support Forum

Select element from its pointer

Luca

Saturday 18th May 2024
I am new to layout editor and I am having trouble finding a function to select an element using simply its pointer. Functions for moving, copying, and other common operations require the element to be selected first. How is this operation performed?
Jürgen
LayoutEditorFull
Sunday 19th May 2024
There are several ways to select shapes or just parts of it. The mosts simple one is the default edit/select mode where you can select shapes with just clicking on it. Other select features are in select menu. Once the selection is completed, the required editing feature needs to be called
Luca

Wednesday 29th May 2024
Thanks, but I mean from the programming code point of view. I am trying to use: element* e1=layout->drawing->currentCell->firstElement->thisElement; e1->selectAll(); With this code, I can select the last drawing element. However, if I design a new element and then I run again the command e1->selectAll(), the last drawing element will be selected, but I would like to have a reference to the previous designed element.
Jürgen
LayoutEditorFull
Wednesday 29th May 2024
You can store the pointer, if you need it later: ```cpp layout->drawing->currentCell->addBox(.........); element *e1=layout->drawing->currentCell->firstElement->thisElement; layout->drawing->currentCell->addBox(.........); element *e2=layout->drawing->currentCell->firstElement->thisElement; ``` or even better the method addBox will return the pointer to the new created element: ```cpp element *e1=layout->drawing->currentCell->addBox(.........); element *e2=layout->drawing->currentCell->addBox(.........); e1->selectAll(); ```
Luca

Wednesday 29th May 2024
Yes, I am doing in this way. Howewer, if I am checking well, when I run e1->selectAll() after having created the second box, the last one is selected and not the first. I run layout->drawing->deselectAll(); before selecting it.
Luca

Tuesday 4th June 2024
Thanks Jürgen, I would try explaining better. The problem is related to a copy of the element. If I create a new box, I can easily select the last created element, but if I create a copy of an element, when I run layout->drawing->currentCell->firstElement->thisElement->selectAll() the original element is selected and not the copy.
Jürgen
LayoutEditorFull
Tuesday 4th June 2024
In general the list of elements is unsorted. Except for adding a single element you cannot rely on any order. Even a "undo" will change it. So in the macro programming you should identify the element differently. Ether by position, by layer, or by the selection status. For the copy operation the status works well as the copied element will get selected after the operation. So you just need to loop through all element and find the one that is selected.