hi there, does anyone know how I can measure different lengths along a polyline. I have to set blocks at different distances along a polyline ie from 1st block, next is 3m along, 3rd is 3.6m along etc etc .
managed to find something that would do it along the curve of the polyline but not on a straight line or the polyline entirety
[I thought this question looked familiar -- I saw it at the cadforum.cz site.]
Try this pretty basic one:
(vl-load-com); if needed
(if (setq plsel (entsel "\nSelect Polyline: "))
(progn
(setq
pl (car plsel)
pt (osnap (getpoint "\nPoint on Polyline for first Block: ") "_nea")
cumdist (vlax-curve-getDistAtPoint pl pt)
); setq
(setvar 'osmode 0)
(command "_.insert" "YourBlockName" pt "" "" "")
(while
(setq nextdist (getdist "\nDistance farther along Polyline to next Block: "))
(setq cumdist (+ cumdist nextdist))
(command "_.insert" "" (vlax-curve-getPointAtDist pl cumdist) "" "" "")
); while
); progn
); if
It could be enhanced in various ways -- error handler, object-type control in selection, saving/resetting object-snap, scale factor option [it currently uses scales of 1], align Blocks with Polyline [it currently puts them in all at 0 rotation] or option whether to do so, etc.
somehow it is showing an error
bad argument type: 2D/3D point: nil
I need this lisp can you please share it solving the problem
@vishal.Gawde wrote:
somehow it is showing an error
bad argument type: 2D/3D point: nil
....
Does this always happen, or only sometimes? It would happen if you missed when picking a Polyline, or if you gave it a next distance that took the cumulative distance past the end of the Polyline.
[And by the way, it should work on other kinds of path objects -- Lines, Arcs, Circles, Ellipses, Splines, even Rays.]
There is also the TraceCurve utility which may do what you need - see the tip:
http://www.cadforum.cz/cadforum_en/measure-lengths-along-a-curve-points-in-given-distances-tip11625
(and its related tips)
Vladimir Michl, www.cadstudio.cz www.cadforum.cz