mostafa badran Posted March 4, 2014 Posted March 4, 2014 Hi all, Looking for a LISP routine to draw double polyline like MLINE. Quote
ReMark Posted March 4, 2014 Posted March 4, 2014 Use the MLine command then convert to LWPolylines using Lee Mac's Multilines to Polylines lisp routine. Quote
JamCAD Posted March 4, 2014 Posted March 4, 2014 Alternatively there are muliple lisp routines around (both on this forum and others) that allow you to select a polyline and it will offset on both sides. http://www.cadtutor.net/forum/showthread.php?52012-Lisp-for-offset-both-sides Quote
mostafa badran Posted March 4, 2014 Author Posted March 4, 2014 Use the MLine command then convert to LWPolylines using Lee Mac's Multilines to Polylines lisp routine. Exactly I do this but it take a long time. I think when I draw polyline directly is better. Quote
mostafa badran Posted March 4, 2014 Author Posted March 4, 2014 Alternatively there are muliple lisp routines around (both on this forum and others) that allow you to select a polyline and it will offset on both sides. http://www.cadtutor.net/forum/showthread.php?52012-Lisp-for-offset-both-sides Thanks j0nat for your reply, but I don't need offset I won't option like MLINE to draw polyline from middle. Quote
lucas3 Posted March 4, 2014 Posted March 4, 2014 (defun c:2l(/ ent1 ent2 ent3 ent4 wwdy str1 pt1 pt2 dis1 ag1 pt1u pt2u) (setq ent1 nil ent2 nil ent3 nil ent4 nil) (defun sk_mkl(p1 p2) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) ) ) ) (setq wwdy (getreal "\nPlease enter the spacing between the two lines:")) (if (= wwdy nil)(setq wwdy 6)) (setq str1 (rtos wwdy 2 2)) (prompt "\n now dline width is: ") (prompt str1) (if(setq pt1 (getpoint "\n enter start point:")) (while (setq pt2 (getpoint pt1 "\n enter next point:")) (redraw) (if (and ent1 ent2) (setq ent3 ent1 ent4 ent2)) (setq dis1 (* 0.5 wwdy)) (setq ag1 (angle pt1 pt2)) (setq pt1u (polar pt1 (+ ag1 1.5708) dis1)) (setq pt2u (polar pt2 (+ ag1 1.5708) dis1)) (setq pt1d (polar pt1 (- ag1 1.5708) dis1)) (setq pt2d (polar pt2 (- ag1 1.5708) dis1)) (setq ent1(sk_mkl pt1u pt2u) ent2(sk_mkl pt1d pt2d) pt1 pt2 ) (setvar "FILLETRAD" 0.0) (command "FILLET" ent1 ent3) (command "FILLET" ent2 ent4) ) ) (princ) ) Quote
JamCAD Posted March 4, 2014 Posted March 4, 2014 Exactly I do this but it take a long time.I think when I draw polyline directly is better. Take a long time? Do you mean the actual lisp routine runs slowly? Or that you want to effectivly reduce the steps of drawing the Mline, loading the lisp routine, and running the routine? Quote
mostafa badran Posted March 4, 2014 Author Posted March 4, 2014 (defun c:2l(/ ent1 ent2 ent3 ent4 wwdy str1 pt1 pt2 dis1 ag1 pt1u pt2u) (setq ent1 nil ent2 nil ent3 nil ent4 nil) (defun sk_mkl(p1 p2) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) ) ) ) (setq wwdy (getreal "\nPlease enter the spacing between the two lines:")) (if (= wwdy nil)(setq wwdy 6)) (setq str1 (rtos wwdy 2 2)) (prompt "\n now dline width is: ") (prompt str1) (if(setq pt1 (getpoint "\n enter start point:")) (while (setq pt2 (getpoint pt1 "\n enter next point:")) (redraw) (if (and ent1 ent2) (setq ent3 ent1 ent4 ent2)) (setq dis1 (* 0.5 wwdy)) (setq ag1 (angle pt1 pt2)) (setq pt1u (polar pt1 (+ ag1 1.5708) dis1)) (setq pt2u (polar pt2 (+ ag1 1.5708) dis1)) (setq pt1d (polar pt1 (- ag1 1.5708) dis1)) (setq pt2d (polar pt2 (- ag1 1.5708) dis1)) (setq ent1(sk_mkl pt1u pt2u) ent2(sk_mkl pt1d pt2d) pt1 pt2 ) (setvar "FILLETRAD" 0.0) (command "FILLET" ent1 ent3) (command "FILLET" ent2 ent4) ) ) (princ) ) Thanks Mr lucas3 for your reply. That is what I want,I don't know if it possible to edit it to draw polyline? Quote
mostafa badran Posted March 4, 2014 Author Posted March 4, 2014 Take a long time? Do you mean the actual lisp routine runs slowly? Or that you want to effectivly reduce the steps of drawing the Mline, loading the lisp routine, and running the routine? yes j0nat as you said that effectively reduce the steps of drawing the Line, loading the lisp routine, and running the routine. Quote
lucas3 Posted March 5, 2014 Posted March 5, 2014 Thanks Mr lucas3 for your reply. That is what I want,I don't know if it possible to edit it to draw polyline? (defun c:2l(/ ent1 ent2 ent3 ent4 wwdy1 str1 pt1 pt2 dis1 ag1 pt1u pt2u sspl) (setq ent1 nil ent2 nil ent3 nil ent4 nil sspl nil) (defun sk_mkl(p1 p2) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) ) ) ) (setq cmd_old(getvar 'cmdecho)) (setvar 'cmdecho 0) (or wwdy (setq wwdy 6)) (if(setq wwdy1 (getreal (strcat "\nPlease enter the spacing between the two lines:<Current:"(rtos wwdy 2 3) ">:"))) (setq wwdy wwdy1)) (setq str1 (rtos wwdy 2 2) sspl (ssadd)) (prompt "\n now dline width is: ") (prompt str1) (if(setq pt1 (getpoint "\n enter start point:")) (progn (while (setq pt2 (getpoint pt1 "\n enter next point:")) (redraw) (if (and ent1 ent2) (setq ent3 ent1 ent4 ent2)) (setq dis1 (* 0.5 wwdy)) (setq ag1 (angle pt1 pt2)) (setq pt1u (polar pt1 (+ ag1 1.5708) dis1)) (setq pt2u (polar pt2 (+ ag1 1.5708) dis1)) (setq pt1d (polar pt1 (- ag1 1.5708) dis1)) (setq pt2d (polar pt2 (- ag1 1.5708) dis1)) (setq ent1(sk_mkl pt1u pt2u) ent2(sk_mkl pt1d pt2d) pt1 pt2 ) (setvar "FILLETRAD" 0.0) (command "FILLET" ent1 ent3) (command "FILLET" ent2 ent4) (if(and ent1 ent2) (setq sspl(ssadd ent1 sspl) sspl(ssadd ent2 sspl))) (if(and ent3 ent4) (setq sspl(ssadd ent3 sspl) sspl(ssadd ent4 sspl) )) ) (if (and sspl (> (sslength sspl) 2)) (command "pedit" "m" sspl "" "j" "0.00" "") ) ) ) (if cmd_old (setvar 'cmdecho cmd_old)) (princ) ) Quote
mostafa badran Posted March 5, 2014 Author Posted March 5, 2014 (defun c:2l(/ ent1 ent2 ent3 ent4 wwdy1 str1 pt1 pt2 dis1 ag1 pt1u pt2u sspl) (setq ent1 nil ent2 nil ent3 nil ent4 nil sspl nil) (defun sk_mkl(p1 p2) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) ) ) ) (setq cmd_old(getvar 'cmdecho)) (setvar 'cmdecho 0) (or wwdy (setq wwdy 6)) (if(setq wwdy1 (getreal (strcat "\nPlease enter the spacing between the two lines:<Current:"(rtos wwdy 2 3) ">:"))) (setq wwdy wwdy1)) (setq str1 (rtos wwdy 2 2) sspl (ssadd)) (prompt "\n now dline width is: ") (prompt str1) (if(setq pt1 (getpoint "\n enter start point:")) (progn (while (setq pt2 (getpoint pt1 "\n enter next point:")) (redraw) (if (and ent1 ent2) (setq ent3 ent1 ent4 ent2)) (setq dis1 (* 0.5 wwdy)) (setq ag1 (angle pt1 pt2)) (setq pt1u (polar pt1 (+ ag1 1.5708) dis1)) (setq pt2u (polar pt2 (+ ag1 1.5708) dis1)) (setq pt1d (polar pt1 (- ag1 1.5708) dis1)) (setq pt2d (polar pt2 (- ag1 1.5708) dis1)) (setq ent1(sk_mkl pt1u pt2u) ent2(sk_mkl pt1d pt2d) pt1 pt2 ) (setvar "FILLETRAD" 0.0) (command "FILLET" ent1 ent3) (command "FILLET" ent2 ent4) (if(and ent1 ent2) (setq sspl(ssadd ent1 sspl) sspl(ssadd ent2 sspl))) (if(and ent3 ent4) (setq sspl(ssadd ent3 sspl) sspl(ssadd ent4 sspl) )) ) (if (and sspl (> (sslength sspl) 2)) (command "pedit" "m" sspl "" "j" "0.00" "") ) ) ) (if cmd_old (setvar 'cmdecho cmd_old)) (princ) ) Thank you so much, but sometimes makes line and sometimes makes polyline sorry for inconvenience. Quote
lucas3 Posted March 5, 2014 Posted March 5, 2014 Thank you so much, but sometimes makes line and sometimes makes polyline sorry for inconvenience. sometimes makes line and sometimes makes polyline ???what's meaning? Quote
mostafa badran Posted March 5, 2014 Author Posted March 5, 2014 sometimes makes line and sometimes makes polyline ???what's meaning? I mean when I used the lisp it's draw sometimes 2 line and sometimes draw 2 polyline. sorry for my bad English. Quote
lucas3 Posted March 5, 2014 Posted March 5, 2014 I mean when I used the lisp it's draw sometimes 2 line and sometimes draw 2 polyline.sorry for my bad English. Convert Lines, Arcs and Splines to polylines [Yes/No]? y Enter an option [Close/Open/Join/Width/Fit/Spline/Decurve/Ltype gen/Reverse/Undo]: j Join Type = Extend Enter fuzz distance or [Jointype] : 12 segments added to 2 polylines Quote
mostafa badran Posted March 5, 2014 Author Posted March 5, 2014 Convert Lines, Arcs and Splines to polylines [Yes/No]? yEnter an option [Close/Open/Join/Width/Fit/Spline/Decurve/Ltype gen/Reverse/Undo]: j Join Type = Extend Enter fuzz distance or [Jointype] : 12 segments added to 2 polylines OK, thanks Mr lucas3 for your help. Quote
mostafa badran Posted March 5, 2014 Author Posted March 5, 2014 Convert Lines, Arcs and Splines to polylines [Yes/No]? yEnter an option [Close/Open/Join/Width/Fit/Spline/Decurve/Ltype gen/Reverse/Undo]: j Join Type = Extend Enter fuzz distance or [Jointype] : 12 segments added to 2 polylines I noticed when I press ESC button in the end of command it makes line, when I press Enter button it makes polyline. thank Mr. for your effort. Quote
BIGAL Posted March 6, 2014 Posted March 6, 2014 A simpler alternative would be to draw a series of lines remember the end points then draw a pline offset as many times and L&R as required delete original pline as a finish, either pre-programmed offset or use +3 -3 for left & right 3 units. (setq pt1 (getpoint)) (while etc (setq pt2 (getpoint pt1)) ; rubber band appears (setq pt1 pt2) ) ; end while Quote
JamCAD Posted March 6, 2014 Posted March 6, 2014 mostafa, I created a quick lisp that will draw a multi line as normal. I then made a very slight modification to Lee Macs code to convert it to polylines. Unfortunately I couldn't get the mline to preview as it was being drawn. Once the lisp is loaded type mpline to start. (defun c:mpline (/ pt1 pt2) (setq pt1 (getpoint "\nSelect first point: ")) (progn (command "_.mline" "_non" pt1 (progn (while (setq pt2 (getpoint pt1 "\nSelect next point:")) (command "non" pt2) (setq pt1 pt2) ) ) "" ) (c:ml2pl) ) ) ;;Below is a slightly modified version of Lee Macs Mline to Pline routine ;;--------------=={ Multilines to LWPolylines }==-------------;; ;; ;; ;; Converts a selection of Multiline (MLINE) objects into ;; ;; LWPolylines. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2012 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;------------------------------------------------------------;; ;; Version 1.1 - 10-06-2012 ;; ;;------------------------------------------------------------;; (defun c:ml2pl (/ *error* doc el en i s1 s2 val var ) (defun *error* ( msg ) (if val (mapcar 'setvar var val)) (if doc (LM:endundo doc)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) var '("CMDECHO" "PEDITACCEPT" "QAFLAGS") val (mapcar 'getvar var) ) (if (setq s1 (ssadd) s1 (ssadd (entlast)) ) ;;Line of code modified to select the mline just created (progn (LM:startundo doc) (mapcar 'setvar var '(0 1 0)) (repeat (setq i (sslength s1)) (setq en (ssname s1 (setq i (1- i))) el (entlast) s2 (ssadd) ) (command "_.explode" en) (while (setq el (entnext el)) (ssadd el s2) ) (command "_.pedit" "_M" s2 "" "_J" "" "") (setq s2 nil) ) (mapcar 'setvar var val) (LM:endundo doc) ) ) (princ) ) (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) (vl-load-com) (princ "\nType mpline to start\n") (princ) Quote
BIGAL Posted March 6, 2014 Posted March 6, 2014 Lots of lines of code above look below 3 lines !! Thinking about this out loud pick points then multiple plines at any offset +&-ve and any width in one go, why not ! enter 3 goes 3 right 0 width enter 3,0.25 goes 3 width 0.25 enter -73,2.5 goes 73 left width 2.5 maybe this -73,5,0 goes left 73 width starts 5 ends 0 (princ "\nPick st pt enter to finish") (command "_pline") (while (= (getvar "cmdactive") 1 ) (command pause) ) Quote
mostafa badran Posted March 9, 2014 Author Posted March 9, 2014 mostafa, I created a quick lisp that will draw a multi line as normal. I then made a very slight modification to Lee Macs code to convert it to polylines. Unfortunately I couldn't get the mline to preview as it was being drawn. Once the lisp is loaded type mpline to start. (defun c:mpline (/ pt1 pt2) (setq pt1 (getpoint "\nSelect first point: ")) (progn (command "_.mline" "_non" pt1 (progn (while (setq pt2 (getpoint pt1 "\nSelect next point:")) (command "non" pt2) (setq pt1 pt2) ) ) "" ) (c:ml2pl) ) ) ;;Below is a slightly modified version of Lee Macs Mline to Pline routine ;;--------------=={ Multilines to LWPolylines }==-------------;; ;; ;; ;; Converts a selection of Multiline (MLINE) objects into ;; ;; LWPolylines. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2012 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;------------------------------------------------------------;; ;; Version 1.1 - 10-06-2012 ;; ;;------------------------------------------------------------;; (defun c:ml2pl (/ *error* doc el en i s1 s2 val var ) (defun *error* ( msg ) (if val (mapcar 'setvar var val)) (if doc (LM:endundo doc)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) var '("CMDECHO" "PEDITACCEPT" "QAFLAGS") val (mapcar 'getvar var) ) (if (setq s1 (ssadd) s1 (ssadd (entlast)) ) ;;Line of code modified to select the mline just created (progn (LM:startundo doc) (mapcar 'setvar var '(0 1 0)) (repeat (setq i (sslength s1)) (setq en (ssname s1 (setq i (1- i))) el (entlast) s2 (ssadd) ) (command "_.explode" en) (while (setq el (entnext el)) (ssadd el s2) ) (command "_.pedit" "_M" s2 "" "_J" "" "") (setq s2 nil) ) (mapcar 'setvar var val) (LM:endundo doc) ) ) (princ) ) (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) (vl-load-com) (princ "\nType mpline to start\n") (princ) Sorry for the delay thanks j0nat for your effort, it is a good idea to do this task thank you again. 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.