It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I'm struggling with writing a Python script to draw paths between labeled ports (boxes). The labels are on top of the ports and I guess there should be a way to use the location of these labels as the location of the ports as well. What I would like to do is to extract the location of these labels and use them as two ends of a path that I want to draw between them.
Any suggestions?
Thanks in advance.
Comments
Hi, Mo!
I think
text
method of Shape class should be used. It returnsNone
or object of Text class that has methods to get coordinates.@EugeneZelenko
Thanks for your response. I have already used the Text Class to label the ports, and I can basically draw traces knowing the coordinates of each port. However, for each trace between two ports I need to calculate the coordinates of the ports, which does not make sense as it would be very time-consuming. Instead, if there was a way to use the labels (because there is a text associated with them) then simply I could make a path between the port with label 'X' and the port with label 'Y'.
Hope this makes sense.
Thank you!
It'll be useful if you'll create diagram of your layout. Where X/Y labels are located? In same layer/datatype or different one? You could also use user properties (see
Shape
'sproperty
,set_property
methods) to identify ports or their coordinates instead of labels.Not Python but can be converted
Thank you @EugeneZelenko and @tagger5896 for your suggestions. I will look into them and if I have any questions I will reach out to you.
It would be great if answers / examples came back as well....
@dick_freebird
Let's see
you could do the following below in the while statement add a array to capture the text name and x/y coords
such as this , then process the saved array, then use a A* to route, that's another topic
Update Proof of Concept Router to Ports using A*
Discussion is here
https://www.klayout.de/forum/discussion/1778/proof-of-concept-router-for-klayout#latest
Dear all,
thanks to all for this discussion and the code.
I'd like to add that extracting the coordinates of texts should not be time consuming. If the code above is too slow, you can specialize the RecursiveShapeIterator to only deliver texts:
This way your loop will only visit texts (is_text? should not longer be necessary) and it should be quite fast.
Matthias