Author Topic: Auto Circle Placement . . .  (Read 2043 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Auto Circle Placement . . .
« on: May 11, 2017, 07:03:26 AM »
Another wonderful morning and another crazy question. Im curious if there is a way that I can get a circle drawn in between 2 parallel lines or polylines? something like this |o|. So if there are several hundreds of these parallel lines, it could place a circle in the middle of them.

If not possible, it was sure worth the question. Thanks guys, have a great day!
Civil3D 2020

ChrisCarlson

  • Guest
Re: Auto Circle Placement . . .
« Reply #1 on: May 11, 2017, 07:48:38 AM »
It's really just a circle between two points. Select line1, select line2, wambam circle.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #2 on: May 11, 2017, 10:20:49 AM »
Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ a b d i p ss x)
  2.   ;; RJP - 05.11.2017
  3.   ;; Places circles between parallel lines and 2 pt polylines
  4.   ;; Not the fastest code in the world, but faster than doing by hand :P
  5.   (if (and (setq ss (ssget '((-4 . "<OR")
  6.                              (0 . "line")
  7.                              (-4 . "<AND")
  8.                              (0 . "lwpolyline")
  9.                              (90 . 2)
  10.                              (-4 . "AND>")
  11.                              (-4 . "OR>")
  12.                             )
  13.                     )
  14.            )
  15.            (setq d (getdist "\nEnter MAX distance to search: "))
  16.       )
  17.     (progn
  18.       (setq ss
  19.              (mapcar
  20.                '(lambda (x)
  21.                   (list
  22.                     (angle (setq a (vlax-curve-getstartpoint x)) (setq b (vlax-curve-getendpoint x)))
  23.                     (polar a (angle a b) (* 0.5 (distance a b)))
  24.                     x
  25.                   )
  26.                 )
  27.                (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  28.              )
  29.       )
  30.       (while (setq i (car ss))
  31.         (setq ss (cdr ss))
  32.         (mapcar
  33.           '(lambda (x)
  34.              (and
  35.                (<= (distance (cadr i) (setq p (vlax-curve-getclosestpointto (last x) (cadr i)))) d)
  36.                (or (equal (car i) (car x) 1e-8) (equal (+ pi (car i)) (car x) 1e-8))
  37.                (entmakex
  38.                  (list
  39.                    '(0 . "circle")
  40.                    (assoc 8 (entget (last i)))
  41.                    (cons
  42.                      10
  43.                      (polar (cadr x) (angle (cadr x) (cadr i)) (* 0.5 (distance (cadr x) (cadr i))))
  44.                    )
  45.                    (cons 40 (* 0.5 (distance p (vlax-curve-getclosestpointto (last i) p))))
  46.                  )
  47.                )
  48.                ;; (setq ss (vl-remove x ss))
  49.              )
  50.            )
  51.           ss
  52.         )
  53.       )
  54.     )
  55.   )
  56.   (princ)
  57. )
« Last Edit: May 12, 2017, 09:27:35 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Auto Circle Placement . . .
« Reply #3 on: May 11, 2017, 02:13:36 PM »
lol. That is sweet. Do you think they can do it in a row? All in all that is awesome stuff Ron. (As usual)!
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #4 on: May 11, 2017, 02:18:24 PM »
Comment out line 49 (setq ss (vl-remove x ss)) :)
« Last Edit: May 11, 2017, 02:21:38 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Auto Circle Placement . . .
« Reply #5 on: May 11, 2017, 02:47:04 PM »
Ninja!

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #6 on: May 11, 2017, 02:58:23 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Auto Circle Placement . . .
« Reply #7 on: May 11, 2017, 04:53:38 PM »
just got to dive into this bad boy. I hope I have OE errors on my part. lol. Anyways that's usually what it is. This is the drawing I am working with polylines evenly spaced.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #8 on: May 11, 2017, 11:30:11 PM »
You should post a sample drawing with all of your questions. That's a bit more involved than |0|... *edit* actually simple if you just array the circle.
« Last Edit: May 11, 2017, 11:34:20 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Auto Circle Placement . . .
« Reply #9 on: May 12, 2017, 08:07:43 AM »
You right. Sorry. Usually I come up with the idea and then go.. .wait can it do this. My wonderful mind is no conventional. lol. I saw that, and said, that be cool if you could select a bunch of stalls and it puts circles in there for counting. But still I do like what you came up with! Great job.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #10 on: May 12, 2017, 09:26:13 AM »
You right. Sorry. Usually I come up with the idea and then go.. .wait can it do this. My wonderful mind is no conventional. lol. I saw that, and said, that be cool if you could select a bunch of stalls and it puts circles in there for counting. But still I do like what you came up with! Great job.
No worries .. just saying the more info you provide in the initial question, the more likely you'll get an answer that suits your needs.  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Auto Circle Placement . . .
« Reply #11 on: May 12, 2017, 09:31:20 AM »
Slick!
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Auto Circle Placement . . .
« Reply #12 on: May 12, 2017, 09:34:04 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC