Jump to content

Lisp to draw a polyline around the extents of a set of polylines


acheok24

Recommended Posts

Hello everyone,

 

This is my first post on here so please forgive my ignorance if this is posted somewhere else. I am trying to create a lisp that will draw a polyline around a set of polylines, essentially connecting all start points and all endpoints.

 

I just started writing lisps last week so I'm pretty new to this stuff, but the way I'm thinking about doing this is selecting all the polylines, filter out closed polylines that could be in the set, run a while loop to create a list of start points and end points, use repeat to draw a line from start point 1 to start point 2 to start point 3 etc. and then doing the same with the endpoints, and finally join all these lines into one polyline.

 

Let me know what you all think.

 

Thanks in advance.

Link to comment
Share on other sites

Thanks for the quick reply CafeJr. I followed your link and found this code that written by alanjt. I edited it and it almost works correctly now. I've attached two images: 1) showing what the code does 2) what I need it to do. Thanks for your help.

 

(defun c:SPLC (/ ss lst)

;; Spline Connect

;; Alan J. Thompson, 05.15.10

;; Edited by acheok24, 05.21.15

(vl-load-com)

(if (setq ss (ssget))

(progn

(vl-cmdf "pline")

(foreach p (vl-sort

((lambda (i)

(while (setq e (ssname ss (setq i (1+ i))))

(setq lst

(cons

(car

(vl-sort (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e))

(function (lambda (a b) (> (cadr a) (cadr b))))

)

)

lst

)

)

)

)

-1

)

(function (lambda (a b) (

)

(vl-cmdf "_non" (trans p 0 1))

)

(vl-cmdf "" "" "")

)

)

(princ)

)

 

whatINeed.jpg

whatCodeDoes.jpg

Link to comment
Share on other sites

The lines crossing the drawing are created when I run the above referenced code. It seems the code is only drawing lines to connect the start points of each polyline and are connecting them in a random order.

 

Thanks for the link. It is the correct idea that I'm looking for, but it unfortunately will not create a boundary around the extents of polylines.

 

Thank you for your help CafeJr.

Link to comment
Share on other sites

The lines crossing the drawing are created when I run the above referenced code. It seems the code is only drawing lines to connect the start points of each polyline and are connecting them in a random order.

 

Thanks for the link. It is the correct idea that I'm looking for, but it unfortunately will not create a boundary around the extents of polylines.

 

Thank you for your help CafeJr.

 

Could you attach your example drawing here (in dwg file)!?...

 

As I told you, it occurs because you do the command and select all the drawing (I guess), if you do it in parts (I don't know how many drawings or times do you need to do it), but you will creating small linkages of end points, and at the end of it you can join these lines to make a final Pline as you need.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...