Hi,
I would like to create a macro which would to slice polygons or boxes vertically or horizontally
into two parts. Could you give some hints on how to implement the following?
In detail the functionality of a "slice-vertical" macro would be:
1 - select a set of polygons or boxes
2 - launch the sliceV script through a Shift+V keyboard shortcut
3 - click a point on the layoutview window
4 - an imaginary vertical line going through the point determined in step 3 cuts all the shapes selected in step 1 into two halves.
Similarly for slice-horizontal.
Thanks for help!
P.S. tried if using the erase mode and very narrow paths would work. Nothing happens when
the path width is smaller than dbu. Paths with width > dbu work as expected, but I would really want "infinitesimally narrow" paths, so that the cuts define the shapes nicely along the used grid points.
Comments
Hi,
the request can probably be implemented, but the effort will be substantial. The basic approach for implementing a feature that provides mouse interaction is to employ the
RBA::Plugin
framework. A starting point is the documentation provided for the PluginFactory class and a basic introduction to this concept.I feel you ask for a emulation of Virtuoso's slice feature. Please consider not keeping the results to yourself but publish them if you think it's useful for others. This is the spirit of open source.
Kind regards,
Matthias
and sorry for the delay in my comment :)
I will probably try implementing this at some point in the future.
Indeed I'm looking for an emulation feature - I've used Tanner's L-edit and slicing polygons
has been an integral part of my drawing workflow. I'll share the result as soon as
I have made something useful.
Can I use python for using the PluginFactory class (couldn't find any example code on python using this class) or should I learn Ruby?
Cheers,
Antti
Hi Antti,
one more suggestion: what about a feature like "separate into inner and outer parts"?
There are already two operations which you can use in order to split a polygon: "Edit/Selection/Intersection" and "Edit/Selection/Subtraction". So imagine you want to keep the right half of a polygon, you could:
Admittedly this is very tedious. But how about combining these instructions into a single operation, i.e "Edit/Selection/Separate Inside+Outside"? Then you do
the result would two polygons - the inside part and the outside part.
What do you think? This feature is just a combination of existing functions - hence should be straightforward to implement.
Matthias
thanks for your response.
Yes, your suggestion sounds like an easier way to go, definitely something to start with first.
Eventually, to get mouse interaction I understand that PluginFactory is needed.
Regarding this, should PluginFactory work with python? If you have any example code of PluginFactory + python I'd appreciate a link...
Cheers,
Antti
An alternative way to split the polygon is to use diff mode and draw two identical rectangles over the right half.
BR,
Harri
@Harri: thanks for the suggestion and yes, that's one more option.
I basically wanted to say, that within the framework of the current application it's possible to create a function that probably solves the problem stated. It's just not precisely like L-Edit. Instead of drawing a line you have a draw a mask shape. Within this approach, the solution is a few lines of script:
This script can be bound to a menu: if you chose "edit_menu.selection_menu.intersection" it will be put in the "Edit/Selection" menu.
Regards,
Matthias
I am not familiar with the KLayout scripting API, but I would like to perform something like this, except I would like to split all shapes in half (either vertical or horizontal). This is because during geometry/DRC debug, I often need to measure from the center of a shape (i.e. center of the gate to the metal0 edge). Is it possible for you to modify the previous script answer? Thanks!
Hi nmz787_intel,
Here's an example of split selected shapes in half,
you can paste this into py macro page and enable "run on startup "
then it'll be bounded to the tool menu.
Due to the nature of gds, shapes might have remainders after spliting,
so some split lines might be slightly off by one grid.
Hi nmz787_intel,
if your intension is to measure from shape center (boundbox center) without modify the layout
then you'll need to use Plugin to create custom ruler like example below.
It kind of work under my limited test cases.
1. selected ONE shape before click on this center rule measurement
2. click and the first point of the ruler will be snaped to selected shape BOUNDBOX center
3. make your measurement
Note:
bound box center is not necessary be the shape center if the shape is not rect.
using ruler (annotation) should able to avoid gds grid limitation, should works better then splitting shapes
I don't believe we have the "zero width path" which some of the
CAD tools use for "chop". So "Subtract, others from first" will make
a minW/2 error, maybe off grid.
But could that (zero width path) be enabled and used for such things?
Hello,
The script below will add a "cross ruler" in the bbox center of each selected object. It can then be used to start your measurement from, or for instance, manually add a label (Text) in a I/O pad center or manually route (Path) from I/O pad center to I/O pad center...
Cheers,
Tomas