tmelancon Posted June 3, 2015 Posted June 3, 2015 I really need a lisp to find the ends of the lines then offset from those ends by [.25] and insert a solid "donut" at the ends of a line or multiple lines. I have the donut lisp we are currently using as well as another lisp I found on the web that is verrrrrry close to what I am needing. See below for the lisp and pics of what the current code does and what I am looking for. THANKS IN ADVANCE to everyone in the forums, your help is greatly appreciated! Here is the Solid Donut command I use. We call them bb's. (defun c:bb () (command "donut" "0" ".0670")(PRINC)) Here is the lisp I found that is sort of close. Courtesy of KENT1COOPER via AutoDesk Forums: (DEFUN C:CMARK (/ CRAD SS LN) (SETQ CRAD 0.0335) (SETQ SS (SSGET "X" '((0 . "LINE")))) (REPEAT (SSLENGTH SS) (SETQ LN (ENTGET (SSNAME SS 0))) (ENTMAKE (LIST '(0 . "CIRCLE") (ASSOC 10 LN) (CONS 40 CRAD) ) ) (ENTMAKE (LIST '(0 . "CIRCLE") (CONS 10 (CDR (ASSOC 11 LN))) (CONS 40 CRAD) ) ) (SSDEL (SSNAME SS 0) SS) ) ) current routine: new routine: (what I would like to try and get it to do) Quote
Lee Mac Posted June 3, 2015 Posted June 3, 2015 Try something like this: (defun c:dlines ( / e i p q s ) (if (setq s (ssget '((0 . "LINE")))) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i)))) p (cdr (assoc 10 e)) q (cdr (assoc 11 e)) ) (LM:donut (polar p (angle p q) 0.25) 0.0 0.0335) (LM:donut (polar q (angle q p) 0.25) 0.0 0.0335) ) ) (princ) ) ;; Donut - Lee Mac ;; cen - [lst] Donut center ;; rd1 - [num] Inside radius ;; rd2 - [num] Outside radius (defun LM:donut ( cen rd1 rd2 / ocs thk ) (setq thk (abs (- rd2 rd1)) ocs (trans '(0 0 1) 1 0 t) ) (entmakex (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 2) '(070 . 1) (cons 43 thk) (cons 10 (polar (trans cen 0 ocs) pi (+ rd1 (/ thk 2.0)))) '(042 . 1) (cons 10 (polar (trans cen 0 ocs) 0 (+ rd1 (/ thk 2.0)))) '(042 . 1) (cons 210 ocs) ) ) ) Quote
tmelancon Posted June 3, 2015 Author Posted June 3, 2015 Again, another brilliant piece of work. Thank you so much Lee. Blessings! Worked like a charm! Quote
BIGAL Posted June 4, 2015 Posted June 4, 2015 You could do the same with a pline just stepping through the vertices to work out the new donut points. Lee ? Quote
Lee Mac Posted June 4, 2015 Posted June 4, 2015 You could do the same with a pline just stepping through the vertices to work out the new donut points. Lee ? Sure - something like: (defun c:dlines ( / e i l s ) (if (setq s (ssget '((0 . "LINE,LWPOLYLINE")))) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (if (= "LINE" (cdr (assoc 0 e))) (setq l (list (cdr (assoc 10 e)) (cdr (assoc 11 e)))) (setq l (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) e))) ) (while (cadr l) (LM:donut (polar (car l) (angle (car l) (cadr l)) 0.25) 0.0 0.0335) (LM:donut (polar (cadr l) (angle (cadr l) (car l)) 0.25) 0.0 0.0335) (setq l (cdr l)) ) ) ) (princ) ) ;; Donut - Lee Mac ;; cen - [lst] Donut center ;; rd1 - [num] Inside radius ;; rd2 - [num] Outside radius (defun LM:donut ( cen rd1 rd2 / ocs thk ) (setq thk (abs (- rd2 rd1)) ocs (trans '(0 0 1) 1 0 t) ) (entmakex (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(090 . 2) '(070 . 1) (cons 43 thk) (cons 10 (polar (trans cen 0 ocs) pi (+ rd1 (/ thk 2.0)))) '(042 . 1) (cons 10 (polar (trans cen 0 ocs) 0 (+ rd1 (/ thk 2.0)))) '(042 . 1) (cons 210 ocs) ) ) ) Quote
tmelancon Posted June 4, 2015 Author Posted June 4, 2015 Nice work. By the way Lee, I use your Layer Director to throw all kinds of different commands we run on different layers. Is there any way to manipulate this routine to throw those donuts (bbs) onto a layer we currently use called "WELD".. Much obliged and thanks BIG AL for chiming in! You da man! Quote
BIGAL Posted June 5, 2015 Posted June 5, 2015 All credit to Lee it was just obvious that the next question would be plines. Quote
Lee Mac Posted June 5, 2015 Posted June 5, 2015 Nice work. Thanks Is there any way to manipulate this routine to throw those donuts (bbs) onto a layer we currently use called "WELD" Sure, change: '(070 . 1) (cons 43 thk) to: '(070 . 1) '(008 . "WELD") (cons 43 thk) Lee Quote
deepanrajrv Posted September 29, 2016 Posted September 29, 2016 This is the lisp which is close what i need, can someone help and modify this for my requirement. Quote
BIGAL Posted September 30, 2016 Posted September 30, 2016 my requirement Where is my crystal ball. 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.