Luca Posted October 29, 2006 Share Posted October 29, 2006 Hallo, is there a way to read point coordinates along a polylines? This mean: I draw a polyline, then I need to read the x,y values at given intervals along the polyline (i.e. every 5 cm), (therefore it is not useful to read the vertex coordinates because I need more points than those I used to actually draw the polyline). Thank you very much for ypur help Quote Link to comment
islandmon Posted October 30, 2006 Share Posted October 30, 2006 If you know the vector angle in radians between two vertices, then use trig to calculate the XY coordinates of the set of points comprising the vector. This works both ways ; ) Quote Link to comment
Rick Francken Posted October 30, 2006 Share Posted October 30, 2006 Hi Luca, You can use the "PointAlongPoly" from the VWPluginLibraryRoutines.p file. The function is declared like this because the mechanism that generated the file can't handle Vector types: PointAlongPoly(h: HANDLE; dist: REAL; VAR ptX, ptY, ptZ: REAL; VAR tangentX, tangentY, tangentZ: REAL) : BOOLEAN; So you need to use the function as though it was declared like this: PointAlongPoly(h: HANDLE; dist: REAL; VAR pt: vector; VAR tangent: vector): BOOLEAN; Here is a simple script that shows how you would use this function. procedure MyPoly; const PointSpacing = 5cm; var PolyHand: handle; pt: vector; tangent: vector; pointDist, PerimeterLength: real; ptresult: boolean; begin {create a polyline and get its handle} CallTool(-204); PolyHand:= LSActLayer; { get the perimeter length of the polyline } PerimeterLength:= HPerim(PolyHand); pointDist:= 0.0; {draw points 5cm apart } while pointDist<PerimeterLength do begin ptresult:= PointAlongPoly(PolyHand, pointDist, pt, tangent); Locus(pt.X, pt.Y); pointDist:= pointDist + PointSpacing; end; end; run(MyPoly); Good luck, Quote Link to comment
islandmon Posted October 30, 2006 Share Posted October 30, 2006 Rick, this is, indeed, a powerful little script ... although for some reason beyond my knowledge it refuses to close the last leg of the poly and then 'magically' inserts a couple random loci here and there ; ) Quote Link to comment
Rick Francken Posted October 31, 2006 Share Posted October 31, 2006 Islandmon, Thanks. I use a variation of that to place other custom objects along a path polyline, where the objects have to be aligned with the curve of the path. It's a very useful way to place repeating elements. I did observe the same behavior you are seeing, and it happens whether the polyline is closed or open. Still trying to figure out a fix for it...not much documentation available. Quote Link to comment
SYLVAIN Posted November 21, 2006 Share Posted November 21, 2006 Hello, I tried the trick, and enjoy to find an answer to a very old question of mine. Thanks If you have an idea to solve the problem of unexpected points when the poly is closed, it would be great. I also work on it. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.