aloy Posted July 22, 2012 Posted July 22, 2012 How can I convert a series of line sgments to a polyline, or draw them as a pline by modifying the following code: (setq p1(cadr (car l))) (while (/= l nil) (setq l(cdr l)) (setq p2(cadr (car l))) (command "line" "_NON" p1 "_NON" p2 "") (setq p1 p2) ) Thanking in advance, Aloy Quote
fixo Posted July 22, 2012 Posted July 22, 2012 Try this code, if you need to make the pline closed hit "CL" at the end (defun C:demo() (setq osm (getvar "osmode")) (setvar "osmode" 0) (command "._pline") (while (= 1 (logand 1 (getvar "cmdactive"))) (command pause)) (setvar "osmode" osm) (princ) ) ~'J'~ Quote
aloy Posted July 22, 2012 Author Posted July 22, 2012 Hi Fixo, The code you gave works fine on it own just like pline in autoCad. What I need is, to extract the point from the list, l ,when prompted to give the point. Regards, Aloy Quote
Lee Mac Posted July 22, 2012 Posted July 22, 2012 Query the DXF data of the resultant polyline. Quote
fixo Posted July 22, 2012 Posted July 22, 2012 Try instead (defun C:demo(/ closed osm ptlist) (setq osm (getvar "osmode")) (setvar "osmode" 0) (setq ptlist [ your points ]) (setq closed T ;|or nil if open| (command "._pline") (mapcar 'command ptlist) (if closed (command "CL") (command "") (setvar "osmode" osm) (princ) ) Quote
Stefan BMR Posted July 22, 2012 Posted July 22, 2012 aloy, From your code, the list must be something like ((a (x y z)) (b (u v w)) ... In this case, this code will draw a Polyline instead of Lines. (command "PLINE") (foreach x l (command "_non" (cadr x)) ) (command "") Quote
BlackBox Posted July 22, 2012 Posted July 22, 2012 (edited) How can I convert a series of line sgments to a polyline One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set, example: (defun c:FOO (/ ss) (if (setq ss (ssget "_:L" '((0 . "LINE")))) (command "._pedit" "multiple" ss "" "y" "") (prompt "\n** Nothing selected ** ") ) (princ) ) ... You can tailor this how you like, if you wanted to join the lines, etc.. HTH Edited July 24, 2012 by BlackBox Quote
aloy Posted July 23, 2012 Author Posted July 23, 2012 Stefan, Thanks a lot. Fantastic. Regards, Aloy Quote
aloy Posted July 23, 2012 Author Posted July 23, 2012 Hi RenderMan, It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try. Regards, Aloy Quote
BlackBox Posted July 24, 2012 Posted July 24, 2012 How can I convert a series of line sgments to a polyline One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set Hi RenderMan, It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try. To reiterate... The function prompts the user for a Selection Set of lines that already exist within the drawing (and not a list of points), then converts the a valid Selection Set to Polylines. This function does not accept any arguments (i.e., a list of points). You've mentioned different tasks in this thread; this offering is by no means an answer for each of them. Quote
aloy Posted July 24, 2012 Author Posted July 24, 2012 Hi RenderMan, Yes, what 'pedit' does is to convert lines to individual polilines. That's what happened when I drew the series of lines which are connected, end to end, and use c:foo function to convert them. However few understood my intension though the title may not explain fully. Regards, Aloy Quote
eldon Posted July 24, 2012 Posted July 24, 2012 what 'pedit' does is to convert lines to individual polilines. That's what happened when I drew the series of lines which are connected, end to end I can't help thinking that you are not using Pedit to its full extent. If I had a series of lines which are connected in groups, I would start the command Pedit. then before selecting polyline, I would type M for multiple. To select objects, I would do a window selection, then Y to convert lines and arcs to polylines. Choosing the option J to join, then accept the fuzz distance of 0.00. All joining lines are converted to joined-up polylines. You can do it by Lisp, but it seems to be re-inventing the wheel. Perhaps you should post your drawing. Quote
aloy Posted July 24, 2012 Author Posted July 24, 2012 Hi, eldon, Thank you very much for enlighting about full extent of pedit. It works. In the real world these lines constitute centre line of a road which will be drawn on the AutoCAD suyvey plan; hence there will be many other line making it difficult to select by a window. I will post the drawing on another thread to prepare a table of coordinates. Regards, Aloy Quote
eldon Posted July 24, 2012 Posted July 24, 2012 In the real world these lines constitute centre line of a road which will be drawn on the AutoCAD suyvey plan; hence there will be many other line making it difficult to select by a window. If you are sure that only the lines to form the polyline are connected, then when asked to select objects, type "all". Everything will be selected, but only touching lines will be joined to make the polyline. Quote
BlackBox Posted July 24, 2012 Posted July 24, 2012 I can't help thinking that you are not using Pedit to its full extent. Thanks for the clarification, eldon. Aloy - To reiterate, this was mentioned back in post #7, where I also included a link to the Command's documentation for your use: One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set, example: ... You can tailor this how you like, if you wanted to join the lines, etc.. Quote
aloy Posted July 24, 2012 Author Posted July 24, 2012 Sorry RenderMan, I did not notice the last line in the posting No. 7; now I am clear. Regards, Aloy Quote
Recommended Posts
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.