Results 1 to 7 of 7

Thread: Circles from a list

  1. #1
    Member
    Join Date
    2004-05
    Posts
    24
    Login to Give a bone
    0

    Default Circles from a list

    Hi,
    I've got a list of circles in a file. Each circle has a line in which X Y D (coordinates and diameter) are specified:
    Example

    1000 1000 10
    2000 -1000 15
    500 -2000 10

    I would like to have a lisp command that reads the file list and creates the drawing of circles in Autocad.
    Thanks in advance.

  2. #2
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Circles from a list

    Try something like this:

    Code:
    (defun c:circlesfromfile ( / i file line )
        (if
            (and
                (setq file (getfiled "Select Data File" "" "txt" 16))
                (setq file (open file "r"))
            )
            (progn
                (setq i 0)
                (while (setq line (read-line file))
                    (if
                        (and
                            (setq line (LM:str->lst line " "))
                            (= 3 (length line))
                            (setq line (mapcar 'distof line))
                            (vl-every 'numberp line)
                            (setq i (1+ i))
                        )
                        (entmakex
                            (list
                                (cons 0 "CIRCLE")
                                (list 10 (car line) (cadr line) 0.0)
                                (cons 40 (/ (caddr line) 2.0))
                            )
                        )
                    )
                )
                (setq file (close file))
                (princ (strcat "\n" (itoa i) " Circle(s) Created."))
            )
        )
        (princ)
    )
    
    ;;-------------------=={ String to List }==-------------------;;
    ;;                                                            ;;
    ;;  Separates a string into a list of strings using a         ;;
    ;;  specified delimiter string                                ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  str - string to process                                   ;;
    ;;  del - delimiter by which to separate the string           ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  A list of strings                               ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:str->lst ( str del / pos )
      (if (setq pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
        (list str)
      )
    )
    Uses my String to List function.

  3. #3
    Member
    Join Date
    2004-05
    Posts
    24
    Login to Give a bone
    0

    Default Re: Circles from a list

    Hi Lee Mac.
    your code is OK!
    Thanks a lot !!
    Bye
    Luigi
    Last edited by lugligino; 2011-10-20 at 09:10 AM.

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Circles from a list

    If you did not have access to lisp (AutoCAD LT for example), you could also do this with a script file.

    Example:
    Code:
    ._multiple
    ._circle
    1000,1000 10
    2000,-1000 15
    500,-2000 10
    60,60 30
    100,100 8.23
    R.K. McSwain | CAD Panacea |

  5. #5
    Member
    Join Date
    2004-05
    Posts
    24
    Login to Give a bone
    0

    Default Re: Circles from a list

    Quote Originally Posted by rkmcswain View Post
    If you did not have access to lisp (AutoCAD LT for example), you could also do this with a script file.

    Example:
    Code:
    ._multiple
    ._circle
    1000,1000 10
    2000,-1000 15
    500,-2000 10
    60,60 30
    100,100 8.23
    Yes, it works but you need to modify the list (comma between first and second field).
    It's good for short lists only. I deal lists with more than 1000 rows.
    Thanks.

  6. #6
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Circles from a list

    Quote Originally Posted by lugligino View Post
    Yes, it works but you need to modify the list (comma between first and second field).
    It's good for short lists only. I deal lists with more than 1000 rows.
    Thanks.
    With the proper software, creating the necessary syntax on each line would be trivial.
    LT users would have to use it.
    R.K. McSwain | CAD Panacea |

  7. #7
    Member
    Join Date
    2004-05
    Posts
    24
    Login to Give a bone
    0

    Default Re: Circles from a list

    Quote Originally Posted by rkmcswain View Post
    With the proper software, creating the necessary syntax on each line would be trivial.
    LT users would have to use it.
    Yes. I agree.
    Bye

Similar Threads

  1. circles within circles...
    By IamMichaelPacker747327 in forum AutoCAD General
    Replies: 9
    Last Post: 2012-04-30, 08:03 PM
  2. Circles Masking
    By ekolto in forum AutoCAD General
    Replies: 3
    Last Post: 2011-10-25, 07:33 PM
  3. dimensioning circles
    By david.smith770435 in forum AutoCAD General
    Replies: 1
    Last Post: 2011-04-15, 11:05 AM
  4. Circles & Boxes.....
    By ronie_ernanto in forum AutoCAD Gallery
    Replies: 13
    Last Post: 2009-05-05, 09:03 AM
  5. Aligning circles
    By brakware in forum Revit Architecture - General
    Replies: 12
    Last Post: 2007-03-23, 05:10 PM

Posting Permissions

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