+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Forum Newbie
    Discipline
    Civil
    Using
    AutoCAD 2016
    Join Date
    Dec 2016
    Posts
    2

    Default Draw circles in multiple points

    Registered forum members do not see this ad.

    Hi,
    I want to make a script who draw circles in multiple Points. The Points are automaticly made in a extension to autocad. All the Points are in same layers. It´s around 200 to 1000 Points in the drawing.
    My first issue is to find a commando who draw circles, with basepoints in all Points.
    Does anyone know the appropriate command for me?


    Regards,
    Emil

  2. #2
    Super Member
    Using
    not specified
    Join Date
    Dec 2004
    Location
    YUL
    Posts
    587

    Default

    This is what I use.

    Code:
    (defun c:ic (/ a b c r d n p d1 d2 e1 cl oerr osn)
    
      (setq osn (getvar "osmode"))
      (setvar "cmdecho" 0)
    
      (setq cl (getvar "clayer"))
      (if c
        ()
        (setq c 1.0)
      )
      (princ "\n Circle diameter < ")
      (princ c)
      (princ " > ? ")
      (setq b (getdist))
      (if (= b nil)
        (setq b c)
        (setq c b)
      )
      (setq r (/ b 2))
      (princ "\n Select nodes ")
      (setq a (ssget '((0 . "POINT"))))
      (setq d (sslength a))
      (setq d1 d)
      (repeat d
        (setq d2 (1- d1))
        (setq n (ssname a d2))
        (setq e1 (entget n))
        (setq p (cdr (assoc 10 e1)))
        (entmake (list (cons 0 "CIRCLE")
    		   (cons 6 "BYLAYER")
    		   (cons 8 cl)
    		   (cons 10 p)
    		   (cons 40 r)
    		   (cons 210 (list 0.0 0.0 1.0))
    	     )
        )
    
        (entdel n)
        (setq d1 d2)
      )
      (setvar "osmode" osn)
      (princ)
    )

  3. #3
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,725

    Default

    Maybe a slight simplification of code

    Code:
    (setq d (sslength a))
      (setq d1 d)
      (repeat d
        (setq d2 (1- d1))
        (setq n (ssname a d2))
        (setq e1 (entget n))
     
      (repeat (setq d2 (sslength a)))
        (setq e1 (entget (ssname a (setq d2 (- d2 1)))))
    A man who never made mistakes never made anything

  4. #4
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    430

    Default

    Another one
    Code:
    (defun c:test (/ a b i)
      (if (and (setq a (ssget '((0 . "point"))))
    	   (setq b (getdist "\nSpecify Circle Radius : "))
          )
        (repeat (setq i (sslength a))
          (entmakex
    	(list (cons 0 "CIRCLE")
    	      (assoc 10 (entget (ssname a (setq i (1- i)))))
    	      (cons 40 b)
    	)
          )
        )
      )
      (princ)
    )
    Last edited by satishrajdev; 22nd Dec 2016 at 07:18 am.
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    @Satish, Note that:
    Code:
    (cons 10 (cdr (assoc 10 <list>))) == (assoc 10 <list>)
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,063

    Default

    I remember someone wrote an algorithm for spacing circles within range (not sure if it was Marko).
    Can't seem to find it right now.

  7. #7
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    430

    Default

    Quote Originally Posted by Lee Mac View Post
    @Satish, Note that:
    Code:
    (cons 10 (cdr (assoc 10 <list>))) == (assoc 10 <list>)
    Thanks you sir. I need to be more focused on this

    BTW I have updated the code.
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  8. #8
    Forum Newbie
    Discipline
    Civil
    Using
    AutoCAD 2016
    Join Date
    Dec 2016
    Posts
    2

    Default

    Thanks so much.
    It works good!


    Quote Originally Posted by satishrajdev View Post
    Another one
    Code:
    (defun c:test (/ a b i)
      (if (and (setq a (ssget '((0 . "point"))))
           (setq b (getdist "\nSpecify Circle Radius : "))
          )
        (repeat (setq i (sslength a))
          (entmakex
        (list (cons 0 "CIRCLE")
              (assoc 10 (entget (ssname a (setq i (1- i)))))
              (cons 40 b)
        )
          )
        )
      )
      (princ)
    )

  9. #9
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    430

    Default

    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    Registered forum members do not see this ad.

    FWIW, here's another version which will retain the original properties of the points, and will account for points constructed in any UCS plane:
    Code:
    (defun c:p2c ( / c i r s x )
        (if (and (setq s (ssget '((0 . "POINT"))))
                (progn
                    (initget 6)
                    (setq r (getdist "\nSpecify circle radius: "))
                )
            )
            (repeat (setq i (sslength s))
                (setq x (reverse (entget (ssname s (setq i (1- i)))))
                      c (assoc 10 x)
                )
                (entmake
                    (subst '(0 . "CIRCLE") '(0 . "POINT")
                        (subst (cons 10 (trans (cdr c) 0 (cdr (assoc 210 x)))) c
                            (reverse
                                (cons (cons 40 r)
                                    (vl-remove-if '(lambda ( x ) (member (car x) '(50 102 360))) x)
                                )
                            )
                        )
                    )
                )
            )
        )
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Convert multiple circles into points
    By LEIGH in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 22nd Jan 2016, 06:36 am
  2. Circles to Points
    By big daddy in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 9th Apr 2009, 10:00 pm
  3. Circles to Points
    By big daddy in forum AutoCAD General
    Replies: 2
    Last Post: 24th Dec 2008, 07:57 pm
  4. Going in circles trying to draw an arc in 3D
    By Gerhard van Eeden in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 5th Jun 2008, 05:38 pm
  5. draw circles through points
    By motee-z in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 12th Jul 2006, 05:50 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts