sch-rnd scripting example: TextAutoRotate

<-- back to the index of scripting examples

#### TextAutoRotate

Rotate non-locked text objects to make sure they are readable from bottom and right.

##### Example implementation

textarot.fawk

##### Explanation, step by step

Rotate non-locked text objects to make sure they are readable from bottom and right. The script registers a single action which has the usual scope argument that can be "all" or "selected".

Depending on scope, the action lists target text objects using query(), then it processes the list looking at each object id. If the object has the combination of rotation and mirrorings so that it is not readable from the bottom or right, it is rotated 180 degrees in-place. In-place rotation is achieved by rotating around the bounding box center of the object.

How to test:

- load the script
- place a few text objects, rotate and mirror them
- place symbols, rotate and mirror them
- draw some wires, use {a a} to name the nets, create floater of the name
- select everything
- invoke the script from menu or with hotkey {p s r} or using action TextAutoRotate(selected)
- some of the text objects will be rotated to match the bottom/right rule