Jump to content
tmelancon

Enter a Donut at two ends of a line. Please Help! Appreciated!

Recommended Posts

tmelancon

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:

attachment.php?attachmentid=54451&cid=1&stc=1

 

new routine: (what I would like to try and get it to do)

attachment.php?attachmentid=54454&cid=1&stc=1

current cmark.jpg

new cmark.jpg

new cmark.jpg

Share this post


Link to post
Share on other sites
Lee Mac

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)
       )
   )
)

Share this post


Link to post
Share on other sites
tmelancon

Again, another brilliant piece of work. Thank you so much Lee. Blessings! Worked like a charm! :shock::notworthy:

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome :thumbsup:

Share this post


Link to post
Share on other sites
BIGAL

You could do the same with a pline just stepping through the vertices to work out the new donut points. Lee ?

Share this post


Link to post
Share on other sites
Lee Mac
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)
       )
   )
)

Share this post


Link to post
Share on other sites
tmelancon

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!

Share this post


Link to post
Share on other sites
BIGAL

All credit to Lee it was just obvious that the next question would be plines.

Share this post


Link to post
Share on other sites
Lee Mac
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

Share this post


Link to post
Share on other sites
deepanrajrv

This is the lisp which is close what i need, can someone help and modify this for my requirement.

Share this post


Link to post
Share on other sites
BIGAL
my requirement

 

Where is my crystal ball.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×