Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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

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

Posted

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!

Posted

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

Posted
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

  • 1 year later...
Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...