Thanks Matthias for a very useful piece of software! I was looking to do an equivalent operation to the 'Selection'->'Flip..' or 'Selection'->'Rotation...' with Ruby script commands. Specifically I would like to flip or rotate a select number of geometrical primitives in a cell, but not necessarily all of them. Is this possible using a Ruby script?
Comments
Hi ronm,
Yes, that is possible. The key to that functionality is the method "Shapes#transform(shape, transformation)". The "transformation" is an affine transformation of class "Trans" which can represent a flipping or rotation operation. "shape" is a "Shape" object representing the database object that you want to transform and "Shapes" is the container where that object is contained in (inside the database a single layer of a single cell).
Give you have obtained a Shape object, you can use code like this to transform a shape:
You can obtain the shape objects for the current selection from the layout view by using a code like this:
There are a couple of pitfalls. You'll have to check whether the object selected is a cell instance rather than a shape. Shapes may be selected inside child cells which implies the possibility of multiple instances being selected at the same time etc.
Please also note that the above code works in Editor mode only.
Unless you have some experience already I'd strongly suggest to have a look at the introduction docs, i.e. http://www.klayout.de/doc/programming/database_api.html for more details about the database API.
Regards,
Matthias
Ron