Using 'path' gives off-grid errors

  • Thread starter Thread starter Jan Mikkelsen
  • Start date Start date
J

Jan Mikkelsen

Hi

Most likely a stupid question but never the less. When I draw a 45
degree bend using path the centerline is on-grid but the perimeter
corners are not. Is there any way to solve this? Apart from not using
the 45 degree bends naturally :-)

/Jan
 
Following code may help you,
Change the grid value in the second procedure,

Select all the paths,
call sjMakePathOnGrid()

;-------------------------------------------------
procedure( sjOnGrid(pt grid)
let( (r)
if(listp(pt)
then
mapcar( lambda((a) sjOnGrid( a grid)) pt)
else
r = 10 ** -log10(grid)
round((pt*r))/float(r)
))
)

procedure( sjMakePathOnGrid()
let(
(
grid
)
;Set the grid
grid = 0.01
leHiConvertShapeToPolygon()
mapcar(lambda((obj) obj->points = sjOnGrid(obj->points grid))
geGetSelSet())
)
)
 
here is my version of a script.

call it and it will do the job on selected paths if any are selected or
on all the path if none are selected.

right now it snaps to the x-y snap spacings defined in the layout editor
if no snap spacing is explicitely provided. this could easily be changed
to snap to the manufacturing grid with
xSnap=ySnap=techGetMfgGridResolution(techGetTechFile(geGetEditCellView(wnd)))
or why not write an options form to allow selecting the snap spacing.

you can bind it to a key or a menu
hiSetBindKey( "Layout" "Ctrl<Key>F" "Path2Grid() )

the snapping mechanism is a simple rounding, that could probably be
improved.

hope this helps,

stéphane

procedure( Path2Grid( @optional (wnd hiGetCurrentWindow()) (snapX 0.0)
(snapY 0.0) "wff" )
let( (polygon shapes)
when( snapX == 0.0
snapX = wnd~>xSnapSpacing
)
when( snapY == 0.0
snapY = wnd~>ySnapSpacing
)
shapes = geGetSelSet(wnd) || geGetEditCellView(wnd)~>shapes
foreach( shape setof( x shapes x~>isShape )
polygon = leConvertShapeToPolygon( shape )
polygon~>points = mapcar( lambda( ( pt ) list( snapX*round(
car(pt)/snapX ) snapY*round( cadr(pt)/snapY ) ) ) polygon~>points )
) ; foreach
) ; let
) ; procedure
 
10 ** -log10(grid) is equal to grid**-1

So, the procedures should be,
;-----------------------------------------
procedure( sjOnGrid(pt grid)
if(listp(pt)
then
mapcar( lambda((a) sjOnGrid( a grid)) pt)
else
round((pt/grid))*float(grid)
))

procedure( sjMakePathOnGrid()
let(
(
grid
)
grid = 0.01
leHiConvertShapeToPolygon()
mapcar(lambda((obj) obj->points = sjOnGrid(obj->points grid))
geGetSelSet())
)
)

regards,
Suresh
 
note that snapping to the "nearest grid" could cause problems when the
line is minimum width.
This will then cause "drc" width violations.
I prefer a "snapping up" solution that always results in lines that are
= the design width.
(note however that this will result in ussues when a pair of diagonal
center-lines are snapped.
(i.e. when aware of the snap up behavior, you need to have slightly
increased 45 degree center-line spacing.)

When doing hand layout I tend to use my "6 percent solution TM".

(i.e. for a centerline of 4x width (x being the grid!) when the
centerline has a 45 degree bend,
The inside edge starts 2x oer and 1x back. The outside edge starts
2x over and 1 up. )
The resulting line is ~ 1.06x the width of the orthogonal piece.
Also when the legal spacing to the next centerline over is 2y, the
bend in it's centerline is
2y over and y backed off. This results in 1.06y spacing on diagonals.


This keeps pesky DRC tools happy (except when Fab's put tighter
restrictions on 45's ....)

YMMV

-- Gerry
 
Back
Top