cadshekar Posted December 11, 2012 Posted December 11, 2012 Dear all, Please provide me lisp to convert pline to 3dpoly by taking z valves from the points snapped to the pline. for more understanding, I have attached the dwg file. All replay will be appreciated. cadshekar@gmail.com convert pline to 3dpoly.dwg Quote
cadshekar Posted December 11, 2012 Author Posted December 11, 2012 I need some thing like if we select the pline, lisp shall extract x and y valve from the pline and z valve shall be considred by the points on which pline has snapped. Please help... Quote
SLW210 Posted December 11, 2012 Posted December 11, 2012 I created a new thread for your question. Welcome to CADTutor! Quote
marko_ribar Posted December 11, 2012 Posted December 11, 2012 Try this : (defun plvertlst ( entpl / ptlst ) (setq ptlst (mapcar '(lambda ( a ) (list (car a) (cadr a) (cdr (assoc 38 (entget entpl))))) (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget entpl))))) ptlst ) (defun nodpt ( entpt / pt ) (setq pt (cdr (assoc 10 (entget entpt)))) pt ) (defun c:pl23dplbyneanods ( / plptlst entpl sspt n nodptlst elev 3dplpt 3dplptlst ) (setq plptlst (plvertlst (setq entpl (car (entsel "\nPick LWPOLYLINE"))))) (setq sspt (ssget "_X" '((0 . "POINT")))) (setq n (sslength sspt)) (while (> n 0) (setq nodptlst (append nodptlst (list (nodpt (ssname sspt (setq n (1- n))))))) ) (foreach plpt plptlst (setq elev (caddr (car (vl-sort nodptlst '(lambda ( a b ) (<= (distance a plpt) (distance b plpt))))))) (setq 3dplpt (list (car plpt) (cadr plpt) elev)) (setq 3dplptlst (cons 3dplpt 3dplptlst)) ) (setq 3dplptlst (reverse 3dplptlst)) (entmake (list '(0 . "POLYLINE") '(100 . "AcDbEntity") '(100 . "AcDb3dPolyline") '(66 . 1) '(62 . 3) '(10 0.0 0.0 0.0) (cons 70 (+ 8 (cdr (assoc 70 (entget entpl))))) '(210 0.0 0.0 1.0) ) ) (foreach pt 3dplptlst (entmake (list '(0 . "VERTEX") '(100 . "AcDbEntity") '(100 . "AcDbVertex") '(100 . "AcDb3dPolylineVertex") (cons 10 pt) '(70 . 32) ) ) ) (entmake (list '(0 . "SEQEND") '(100 . "AcDbEntity") ) ) (princ) ) (defun c:ptpl3dpl nil (c:pl23dplbyneanods)) (prompt "\nInvoke with : ptpl3dpl") (princ) M.R. Quote
cadshekar Posted December 12, 2012 Author Posted December 12, 2012 This is the programme I have wrtiten to extract z value of point which is laying at the start point. But it is not at all working. Can any one help me in this...please.... Please see the attached in the prevoius replay . Convert pline to 3dpoly. dwg. (defun c:3pl() (setq file "d:\3dpoly.csv") (setq f (open file "w")) (setvar "cmdecho" 0) (setq a (entsel "\nselect polyline:")) (setq b (car a)) (setq c (entget b)) (setq v (cdr (nth 9 c))) (setq p 14) (setq d1 (nth p c)) (Setq x (cadr d1)) (setq y (caddr d1)) (setq x1 (- x 0.02)) (setq y1 (+ y 0.02)) (setq x2 (+ x 0.05)) (setq y2 (- y 0.05)) (setq w (list x1 y1)) (setq W1(list x2 y2)) (Setq z2(strcat "(" (rtos x) "," (rtos y) ")")) (setq z3 (getpoint "\nselect point:" "node" z2))) ) Quote
SLW210 Posted December 12, 2012 Posted December 12, 2012 cadshekar, Please read the CODE POSTING GUIDELINES and edit your post to include Code Tags (you will need to use the "Go Advanced" option when in edit mode)! Quote
drdownload18 Posted December 19, 2018 Posted December 19, 2018 On 12/11/2012 at 5:02 PM, marko_ribar said: Try this : (defun plvertlst ( entpl / ptlst ) (setq ptlst (mapcar '(lambda ( a ) (list (car a) (cadr a) (cdr (assoc 38 (entget entpl))))) (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget entpl))))) ptlst ) (defun nodpt ( entpt / pt ) (setq pt (cdr (assoc 10 (entget entpt)))) pt ) (defun c:pl23dplbyneanods ( / plptlst entpl sspt n nodptlst elev 3dplpt 3dplptlst ) (setq plptlst (plvertlst (setq entpl (car (entsel "\nPick LWPOLYLINE"))))) (setq sspt (ssget "_X" '((0 . "POINT")))) (setq n (sslength sspt)) (while (> n 0) (setq nodptlst (append nodptlst (list (nodpt (ssname sspt (setq n (1- n))))))) ) (foreach plpt plptlst (setq elev (caddr (car (vl-sort nodptlst '(lambda ( a b ) (<= (distance a plpt) (distance b plpt))))))) (setq 3dplpt (list (car plpt) (cadr plpt) elev)) (setq 3dplptlst (cons 3dplpt 3dplptlst)) ) (setq 3dplptlst (reverse 3dplptlst)) (entmake (list '(0 . "POLYLINE") '(100 . "AcDbEntity") '(100 . "AcDb3dPolyline") '(66 . 1) '(62 . 3) '(10 0.0 0.0 0.0) (cons 70 (+ 8 (cdr (assoc 70 (entget entpl))))) '(210 0.0 0.0 1.0) ) ) (foreach pt 3dplptlst (entmake (list '(0 . "VERTEX") '(100 . "AcDbEntity") '(100 . "AcDbVertex") '(100 . "AcDb3dPolylineVertex") (cons 10 pt) '(70 . 32) ) ) ) (entmake (list '(0 . "SEQEND") '(100 . "AcDbEntity") ) ) (princ) ) (defun c:ptpl3dpl nil (c:pl23dplbyneanods)) (prompt "\nInvoke with : ptpl3dpl") (princ) Why i can't run this lisp? Im getting this error when i select polyline Pick LWPOLYLINE; error: bad argument type: lselsetp nil Quote
Roy_043 Posted December 19, 2018 Posted December 19, 2018 @drdownload18 Maybe there are no points in your dwg? Please test with the dwg in the OP first. 1 Quote
drdownload18 Posted November 6, 2019 Posted November 6, 2019 On 12/19/2018 at 10:39 PM, Roy_043 said: @drdownload18 Maybe there are no points in your dwg? Please test with the dwg in the OP first. Tnx it works now. Is it possible to enable multiple polyline selection for conversion? Quote
BIGAL Posted November 7, 2019 Posted November 7, 2019 (edited) The other option is to use a ssget to look for a "POINT" at the pline vertice much easier in particular OP wants to do multiple only problem may be if you are missing a point. Something like this p1 is pline vertice. (setq p2 (polar p1 (* pi 0.25) scalef)) (setq p3 (polar p1 (* pi 1.25) scalef)) (setq ss2 (ssget "CP" (list p2 p3)(list (cons 0 "Point")) )) Looking at your sample dwg what I have suggested with code would result in "You have a pline vertice with no corresponding point now exiting" How are you making the points in the 1st place from a csv ptnum,x,y,desc then there are better ways to do the line work from the point file. For fun triangulated with Civ3d Edited November 7, 2019 by BIGAL 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.