Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate 2d Polyline from midpoint every segment of another 2d polyline

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
707 Views, 3 Replies

Generate 2d Polyline from midpoint every segment of another 2d polyline

hi,

i have a problem, i will draw a DESTINATION 2d polyline (using lsp ??) using midpoint (every segment) of another SOURCE 2d polyline

can somebody help me ?

many Thanks

Ste
18221.jpg

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....

i have a problem, i will draw a DESTINATION 2d polyline (using lsp ??) using midpoint (every segment) of another SOURCE 2d polyline
....


Welcome to the Forums!  This isn't really a release-specific issue, and the Customization Forum would be a better place [I didn't Search for whether someone may have asked the same thing before, but it's possible].  But quickly:

 

(vl-load-com); if needed

(defun C:PLMID (/ pl clo n ptlist)
  (setq
    pl (car (entsel "\nSelect Polyline: "))
    clo (vlax-curve-isClosed pl)
    n 0
  ); setq
  (repeat (- (cdr (assoc 90 (entget pl))) (if clo 0 1)); number of vertices, minus 1 if open
    (setq
      ptlist (cons (vlax-curve-getPointAtParam pl (+ n 0.5)) ptlist); halfway points
      n (1+ n)
    ); setq
  ); repeat
  (command "_.pline")
  (foreach pt ptlist (command "_none" pt))
  (command (if clo "_close" ""))
); defun

 

That's very basic, and minimally tested.  It will draw on the current Layer, using whatever the current Polyline thickness is, and doesn't check that the User actually picked a Polyline [or even anything at all], and so on, but all those improvements and more can easily be added.

 

[It is rarely possible that it could fail, since Polylines can under strange circumstances find their Parameter values out of whack and not with integer values representing the vertices, but I've never had that happen.  There's a thread that discusses that somewhere, but I didn't find it in a really quick Search.]

Kent Cooper, AIA
Message 3 of 4
Anonymous
in reply to: Kent1Cooper

Thank you,

 

you are like Master Oogway but of Lisp

 

Ste

Smiley Very Happy

Message 4 of 4
Kent1Cooper
in reply to: Anonymous

You're welcome [I'll have to look up Master Oogway, to see whether to take that as a compliment...], and I found that discussion of quirky Polyline Parameter values -- see Owen Wengerd's message at the bottom of page one of this thread, and subsequent discussion.

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost