Using 'path' gives off-grid errors

J

Jan Mikkelsen

Guest
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
 
Jan Mikkelsen wrote:

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 :)
I tend to draw 45 degree lines with polygons. Put a path down first (for
ease of drawing) and then put the polygon over the path.

Paths are defined as the centre points and a width so will always have
this "problem" as far as I can see.

Cheers,

Roger
 
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())
)
)



Jan Mikkelsen wrote:
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
 
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



Jan Mikkelsen wrote:
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
 
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


Suresh Jeevanandam wrote:
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())
)
)



Jan Mikkelsen wrote:

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
 

Welcome to EDABoard.com

Sponsor

Back
Top