It looks like you're new here. If you want to get involved, click one of these buttons!
Hello,
I want to move the selected shapes in the current layout view by an offset (x,y).
I already managed to select all shapes in the current view programmatically.
Now i can iterate over each ObjectInstPath object, like that
lv.each_object_selected do |sel|
???
end
But how can the shapes now be transformed / moved?
I already tried to use the ObjectInstPath.trans object. But it doesnt work or i missed something important.
I would appreciate your help.
Cheers,
Indigo
Comments
Hi Indigo,
actually there is a simple or a complex case.
The complex case occurs if you want to move shapes that are located in child cells. In the general case that involves variant building because a cell might be instantiated with different orientations. If you want to move the shapes in the same direction (as seen on from the parent cell) you'll have to apply a different transformation for each orientation variant and before you can do so you'll have to create copies of that cell. Since I assume you are dealing with the simple case where that is not required, I'll skip that topic here.
The simple case oocurs if you have only objects local in the current cell or inside child cells which are instantiated without rotation. In that case, the loop to move the selection is simply
That loops handles both shapes and instances.
Please note that this sample does not include undo/redo capabilities. You can add this by wrapping your code into a transaction .. commit block like that:
Regards,
Matthias
Hi Matthias,
That was excatly what i was looking for!
Thank's for the fast answer!
Regards,
Indigo
Hi @Matthias,
Sorry for necrobumping, but I suppose it is better to ask my question here. I'm trying to do some actions with the selected objects, similarly to Indigo, and as a reference, I used your code to iterate over the selection. The boxes/polygons/etc are moved nicely; however, if selection contains instances, the error comes out:
Caught the following exception: Trying to replace an object in a list that it does not belong to in Cell::transform (Class RuntimeError)
.So the question is how to modify this code to iterate over selection? I use KLayout 0.27.3.
Regards,
Anton