draw polyline by joining multiple points

draw polyline by joining multiple points

Anonymous
Not applicable
4,125 Views
10 Replies
Message 1 of 11

draw polyline by joining multiple points

Anonymous
Not applicable

in my work i use the divide command alot in order to convert arch to be segmented in a good way 

can you provide me with autolisp that draw polyline by joining multiple points in sorted order

0 Likes
Accepted solutions (2)
4,126 Views
10 Replies
Replies (10)
Message 2 of 11

3wood
Advisor
Advisor

You can try LINKPOINTS.vlx.

 

Message 3 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

... i use the divide command ... to convert arch to be segmented .... autolisp that draw polyline by joining multiple points in sorted order


Are you using the Divide command to put Point objects along the arch, and then you want to draw a Polyline through those Point objects?  If that's the idea, and if the Polyline is to be of line segments, I have a routine that will draw that Polyline without needing either the Divide command or the Point objects.  Is that the kind of thing you're looking for?

Kent Cooper, AIA
Message 4 of 11

Anonymous
Not applicable

yes that what i need 

 

0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

Try the WPL command in WobblyPline.lsp, available >here<.  For the path type option, type EX for EXisting, answer whether to Retain or Delete the path, choose a path object, give it a number of segments, and when it asks:

 

Maximum displacement as percentage of average segment length:

 

type in 0 [zero] so that the locations will not be randomized but will lie exactly on the path and equally spaced.

Kent Cooper, AIA
0 Likes
Message 6 of 11

Sea-Haven
Mentor
Mentor

Another example

 

; converts an arc to plines
; by Alanh updated March 2021

(defun c:arcch ( / oldsnap ent obj div totlen arclen chrdpt lst num newpt)
(vl-load-com)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)

(while (setq ent (entsel "\nPick arc: "))
(setq obj (vlax-ename->vla-object (car ent)))
(if (= div nil) (setq div (getint "\nEnter number of chords: ")))
      
(setq  endpt (vlax-curve-getEndPoint obj)
     totlen (vlax-curve-getDistAtPoint obj endpt)
     arclen (/ totlen div)
     chrdpt (vlax-curve-getStartPoint obj)
     num 1     
)
(setq lst '())
(setq lst (list chrdpt))
(repeat div
  (setq newpt (vlax-curve-getPointatDist obj (* arclen num)))
  (setq lst (cons  newpt lst))
  (setq num (+ num 1))
) ;repeat

(entmakex (append (list (cons 0 "LWPOLYLINE")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbPolyline")
                         (cons 90 (length lst))
                         (cons 70 0))
                   (mapcar (function (lambda (p) (cons 10 p))) lst))
)

) ; end while

(setvar "cmdecho" oldecho)
(setvar "osmode" oldsnap)

(princ)
)
0 Likes
Message 7 of 11

ronjonp
Mentor
Mentor

@Sea-Haven 

FWIW you don't need any of this in your code since there are no command calls.

ronjonp_0-1614654338774.png

 

0 Likes
Message 8 of 11

Sea-Haven
Mentor
Mentor

Thanks old habits.

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

....

....
(while (setq ent (entsel "\nPick arc: "))
....

If I'm reading it right, that routine will work on anything of finite length with linearity -- Line, Polyline, Arc, Spline, Ellipse, Circle [i.e. any (vlax-curve...)-class object other than a Ray or Xline that have no length that can be divided].  The OP said "arch," which could well be a Polyline of multiple segments, and it would work on that, so I wouldn't want them to think it's limited to use on an Arc object only.

Kent Cooper, AIA
0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... arch to be segmented ....


If "segmented" means you ultimately want to actually break the arch [whether an Arc object, or something like a Polyline shape] into equal-length pieces, directly, without the need for any intermediary things like the Divide command or Point objects or a new Polyline via the WPL or arcch routines or anything, you can use Subdivide.lsp with its SD command, >here<.  The resulting pieces will keep any curvature.

Kent Cooper, AIA
0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

You are correct its always hard when poster maybe does not give a full description of what is required.

 

Polishing the crystal ball was a bit hazy.

 

Code was done for wipeouts which do not support arcs so explode pline do arcs, rejoin.

 

0 Likes