Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

measure different lengths along polyline

5 REPLIES 5
Reply
Message 1 of 6
CAD7875
2236 Views, 5 Replies

measure different lengths along polyline

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

5 REPLIES 5
Message 2 of 6
_gile
in reply to: CAD7875

Hi,

 

Have a look at the vlax-curve-* functions (i.e. vlax-curve-getPointAtDist).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 6
Kent1Cooper
in reply to: CAD7875

[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.

Kent Cooper, AIA
Message 4 of 6
vishal.Gawde
in reply to: Kent1Cooper

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

Message 5 of 6
Kent1Cooper
in reply to: vishal.Gawde


@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.]

Kent Cooper, AIA
Message 6 of 6
vladimir_michl
in reply to: CAD7875

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost