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

Find segments of polyline

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
spykat
4177 Views, 20 Replies

Find segments of polyline

I have a old program I'm trying to update for 2014. It would prompt you to pick a segment of a polyline then return the vertices of that segment and for the adjacent segment on eash side.

 

(setq pline (entsel "\nSelect end of Slab"))
(setvar "osmode" 0)
(setq pl (car pline)
      pl1 (entget pl)
      pick (cadr pline)
      plObj (vlax-ename->vla-object pl)
      pick2 (vlax-curve-getclosestpointto plobj pick)
      param (vlax-curve-getparamatpoint plObj pick2)
      segment (fix param)
      vertlist (get-vertices pl1))
(if (= segment 0)(setq apt1 (nth (1- (cdr (assoc 90 pl1))) vertlist))(setq apt1 (nth (1- segment) vertlist)))
(setq apt2 (nth segment vertlist))
(if (= segment (1- (cdr (assoc 90 pl1))))(setq apt3 (nth 0 vertlist))(setq apt3 (nth (1+ segment) vertlist)))
(if (= segment (1- (cdr (assoc 90 pl1))))(setq apt4 (nth 1 vertlist))(setq apt4 (nth (+ 2 segment) vertlist)))

 

When I try this in AutoCAD 2014 I get something like;

 

Command: !vertlist
((10304.7 765.717) 0 0.0 0.0 0.0 (10544.7 729.717) 0 0.0 0.0 0.0 (10544.7 1271.72) 0 etc.

 

It doesn't appear to return the complete list of vertices and I also don't know where all of those 0's came from.

Can anybody help me debug this?

20 REPLIES 20
Message 21 of 21
john.uhden
in reply to: Kent1Cooper

I can't speak for @j.cordero but the subject of polylines always brings up responses of how to access their data and deal with them.  Here you have seen a variety of ways, any one of which may help the OP or any lurker learn how to write the code that serves his needs.

John F. Uhden

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

Post to forums  

Autodesk Design & Make Report

”Boost