Community
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@silambua36 wrote:
…. get the length of a line or a particular segment of a polyline consiting of both straight line and curves and store it to a variable! …. I don't want the total length of polyline just a segment length as different segments have different spacing ….
Do I assume correctly that you would pick on the segment you want the length of? If so, try this [lightly tested]:
(setq plsel (entsel "\nSelect Polyline on segment to get length of: ") pl (car plsel) prepar (fix (vlax-curve-getParamAtPoint pl (osnap (cadr plsel) "_nea"))) segmentlength (- (vlax-curve-getDistAtParam pl (1+ prepar)) (vlax-curve-getDistAtParam pl prepar) ) )
You could add things such as to verify that you picked on a Polyline, etc.
@silambua36 wrote:
…. Can you modify this so i can get either line or polyline length? ….
This will do that, not just for a Line or Polyline, but also an Arc, Circle, or Spline.
(setq esel (entsel "\nSelect object or Polyline segment to get length of: ") ent (car esel) len (if (wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE") (- ; then (vlax-curve-getDistAtParam ent (1+ (setq prepar (fix (vlax-curve-getParamAtPoint ent (osnap (cadr esel) "_nea")))) ) ) (vlax-curve-getDistAtParam ent prepar) ) (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)); else ) )
Can't find what you're looking for? Ask the community or share your knowledge.