Author Topic: Adding a block/circle at each grip  (Read 2753 times)

0 Members and 1 Guest are viewing this topic.

Dave20165

  • Guest
Adding a block/circle at each grip
« on: May 18, 2006, 02:22:24 PM »
Has anyone heard of/written a lisp that will put a block at each grip on a polyline?  I have to put a 3' circle at each grip along a polyline(probably 2,000 grips)for a wetlands plat I am working on.  Thanks for any help.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adding a block/circle at each grip
« Reply #1 on: May 18, 2006, 03:28:13 PM »
Here is a quickie.

Code: [Select]
(defun c:circlepline (/ ent vlst pt)
  (and
    (setq ent (entsel "\nSelect pline to add circles."))
    (setq vlst (mapcar 'cdr (vl-remove-if-not
                               '(lambda (x) (= 10 (car x))) (entget (car ent)))))
    (foreach pt vlst
      (entmake (list '(0 . "CIRCLE")
                     (cons 8 "0")
                     (cons 10 pt) ; center pt
                     '(40 . 18.0) ; 18 units radius
                     ))
    )
  )
  (princ)
)
« Last Edit: May 18, 2006, 03:48:54 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adding a block/circle at each grip
« Reply #2 on: May 18, 2006, 03:46:56 PM »
OK, here is one that you can select more than one pline at a time.
Code: [Select]
(defun c:circlepline (/ ss ename i vlst pt)
  (prompt "\nSelect plines to add circles.")
  (and
    (setq ss (ssget '((0 . "*POLY*"))))
    (setq i -1)
    (while (setq ename (ssname ss (setq i (1+ i))))
      (setq vlst (mapcar 'cdr
                         (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget ename))))
      (mapcar '(lambda (pt)
                 (entmake (list '(0 . "CIRCLE")
                                (cons 8 "0")
                                (cons 10 pt) ; center pt
                                '(40 . 18.0) ; 18 units radius
                          )))
              vlst
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Adding a block/circle at each grip
« Reply #3 on: May 18, 2006, 04:05:06 PM »
I think you lost the OP Alan.  Jeff provided an answer that seems to be working for the OP on the augi site.  I like your codes though.  :lol:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adding a block/circle at each grip
« Reply #4 on: May 18, 2006, 04:13:23 PM »
Thanks, I see I'm an hour or so late. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Adding a block/circle at each grip
« Reply #5 on: May 18, 2006, 04:24:40 PM »
'course had I known he posted it in here as well as augi my response would've been here instead of there......funny thing is, I always look here for new posts before there, so why didn't I see this thread?

Alan, never too late to post good code :-) It lets everyone know that 99 times out of 100 there's more than one (or even 2 or 3) way to accomplish the same thing.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adding a block/circle at each grip
« Reply #6 on: May 18, 2006, 06:22:41 PM »
Well thank you sir.

How about one in MP style.  :-)
Code: [Select]
(defun c:circlepline3 (/ ss)
  (prompt "\nSelect plines to add circles.")
  (and
      (setq ss (ssget '((0 . "*POLY*"))))
      (mapcar
          '(lambda (ename)
               (mapcar '(lambda (pt)
                            (entmake
                                (list
                                    '(0 . "CIRCLE")
                                    (cons 8 "0")
                                    (cons 10 pt)
                                    '(40 . 18.0)
                                )
                            )
                        )
                       (mapcar
                           'cdr
                           (vl-remove-if-not
                               '(lambda (x)
                                    (= 10 (car x))
                                )
                               (entget ename)
                           )
                       )
               )
           )
          (vl-remove-if 'listp
                        (mapcar
                            (function cadr)
                            (ssnamex ss)
                        )
          )
      )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.