limfx Posted November 10, 2023 Posted November 10, 2023 Is there a way to get the x parameter located in '(42 . x) of the lwpolyline list data set at a Param position that I pick into the pline to edit? Thanks! Quote
Steven P Posted November 10, 2023 Posted November 10, 2023 '42' is a part of each segment in the polyline, so there might be many of then in the description Usually the assoc function will get unique data or the first occurrence in a list, for example (cdr (assoc 42 (entget (car (entsel))))) will get the first occurance. OF course reverse the list to get the last: (cdr (assoc 42 (reverse (entget (car (entsel)))))) And in between these something like mAssoc will return the list of all of them - I tend to use Lee Macs, I trust what he posts generally. In this case 'key' will be 42 and lst will be the entity definition list from for example (entget (car (entsel))) Quote
limfx Posted November 10, 2023 Author Posted November 10, 2023 2 hours ago, Steven P said: '42' is a part of each segment in the polyline, so there might be many of then in the description Usually the assoc function will get unique data or the first occurrence in a list, for example (cdr (assoc 42 (entget (car (entsel))))) will get the first occurance. OF course reverse the list to get the last: (cdr (assoc 42 (reverse (entget (car (entsel)))))) And in between these something like mAssoc will return the list of all of them - I tend to use Lee Macs, I trust what he posts generally. In this case 'key' will be 42 and lst will be the entity definition list from for example (entget (car (entsel))) Thank you very much! Quote
Lee Mac Posted November 10, 2023 Posted November 10, 2023 I'd typically opt for something like - (nth <param> (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 42 (car x))) <dxf-data>))) 3 Quote
limfx Posted November 18, 2023 Author Posted November 18, 2023 I am writing a lisp to create a circular arc for a pline according to a given radius R. I originally intended to "entmod bulge" with Get '(42 . x) at Param in list data lwpolyline; but things are not as simple as I thought. So I went in another direction. Can someone help me complete the lisp I'm writing for the purpose as shown below. Sincerely thank you! (defun c:BOR () (while (setq pl (entsel "\nSelect pline: ")) (setq r (getR)) (setq plo (vlax-ename->vla-object (car pl))) (setq pt (vlax-curve-getclosestpointto plo (cadr pl))) (setq n (vlax-curve-getparamatpoint plo pt)) (setq p2 (vlax-curve-getpointatparam plo (setq par (fix (+ 0.5 n))))) (setq p1 (vlax-curve-getpointatparam plo (1- par))) (setq l21 (- (vlax-curve-getDistAtPoint plo p2) (vlax-curve-getDistAtPoint plo p1))) (setq p3 (vlax-curve-getpointatparam plo (1+ par))) (setq l32 (- (vlax-curve-getDistAtPoint plo p3) (vlax-curve-getDistAtPoint plo p2))) (setq ang ((lambda (a) (min a (- (+ pi pi) a))) (rem (+ pi pi (- (angle p2 p1) (angle p2 p3))) (+ pi pi)) )) (setq ang (/ ang 2)) (setq lr (/ r (/ (sin ang) (cos ang)))) (while (or (> lr l21) (> lr l32)) (progn (alert "\nR too big, Enter again R: ") (setq r (getR)) (setq lr (/ r (/ (sin ang) (cos ang)))) );progn );if ;(setq lr (* r (atan (/ ang 2)))) (setq p1t (polar p2 (angle p2 p1) lr)) (setq p3t (polar p2 (angle p2 p3) lr)) (setq ptem (mapcar '(lambda (x y) (/ (+ x y) 2)) p1t p3t)) (setq Lr (sqrt (+ (expt lr 2) (expt r 2)))) (setq p2t (polar p2 (angle p2 ptem) (- Lr r))) (setq bulge ((lambda ( a ) (/ (sin a) (cos a))) (/ (+ (- pi (angle p2t p1t)) (angle p2t p3t)) 2))) (setq ocs (trans '(0 0 1) 1 0 t)) (entmake (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 2) '(070 . 0) (cons 038 (caddr (trans p1t 1 ocs))) (cons 010 (trans p1t 1 ocs)) (cons 042 bulge) (cons 010 (trans p3t 1 ocs)) (cons 210 ocs) ) ) );while (print "limfx") );end (defun getR () (if r (setq rm (getreal (strcat "\nRadius <" (rtos r 2 1) ">: "))) (setq r (getreal "\n\nEnter radius <1>: "))) (if (not r) (setq r 1) (if (not rm) (setq r r) (setq r rm))) );end Quote
BIGAL Posted November 19, 2023 Posted November 19, 2023 (edited) If I understand , so you want 2 plines ? If so easy copy pline to right fixed amount, fillet "polyline" so arcs are created, move pline back to left All done. No code needed. Else make it clearer what you want. Edited November 19, 2023 by BIGAL Quote
Steven P Posted November 19, 2023 Posted November 19, 2023 BiGAl (Weekend and my CAD is off so haven't checked) but I think the OP has a LISP that fillets the corners and now wants the reverse to unfillet the corners Quote
Steven P Posted November 19, 2023 Posted November 19, 2023 As above, my CAD is off for the weekend but what does setting all the (42 . n) to (42 . 0) do? Quote
BIGAL Posted November 20, 2023 Posted November 20, 2023 I filleted a pline using filletrad = x, Fillet, Polyline. Then just did filletrad =0, Fillet, Polyline and original returned no code needed. Quote
limfx Posted November 20, 2023 Author Posted November 20, 2023 Lisp creates circular arcs with different optional radii at the pline vertices that I pick. My goal is to create a continuous pline and two blue vertex lines as shown. Quote
BIGAL Posted November 20, 2023 Posted November 20, 2023 (edited) "two blue green vertex lines as shown". Yes / No ? This is road alignment stuff IP required. Just thinking get vertices before add radius. Pline = 4 points. Add radius's Pline vertices now 6 points. Should be able to do some form of join correct points, only problem I see is where two straights do not have a radius between. ; https://www.cadtutor.net/forum/topic/78649-get-42-x-at-param-in-list-data-lwpolyline/ (defun c:step1 ( / plent) (setq plent (entsel "\nPick pline step 1")) (if plent (setq co-ord1 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (princ co-ord1) (prompt "\nAdd your radius then run step2 ") (princ) ) (defun c:step2 ( / plent) (setq plent (entsel "\nPick pline after radius step 2 ")) (if plent (setq co-ord2 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (princ co-ord2) ; (setvar 'clayer "yourlayer") (setq x 1 y 1) (repeat (- (length co-ord1) 2) (command "line" (nth x co-ord2) (nth y co-ord1)(nth (1+ x) co-ord2) "") (setq x (+ x 2) y (1+ y)) ) Edited November 20, 2023 by BIGAL 1 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.