Scalable Array???

Discussion in 'AutoCAD' started by JRodriguez, May 21, 2004.

  1. JRodriguez

    JRodriguez Guest

    I'm looking for some sort of LISP routine & I am still a newbie in the whole LISP routine process. I want to create a LISP that can both array and scale a set of circles. I need to draw hundreds of circles that the diameter of each circle changes by -.097938mm (as in gets smaller each time) for each array of 19mm. I hope this makes sense. I'll do my best to further discribe it. I have a circle. I need another circle 19mm above it that the diameter changes by -.097938. Every 19mm would be another circle scaling down in size.

    Any help either with a LISP routine or how I would go about creating a routine for this would be greatly appreciated. Please reply to this if I didn't make my self entirely clear.

    Thanks so much for your time,
    JRodriguez
     
    JRodriguez, May 21, 2004
    #1
  2. JRodriguez

    JRodriguez Guest

    Shoot. I also meant to add that the 19mm array is from center points. So that would be a constant 19mm.
     
    JRodriguez, May 21, 2004
    #2
  3. JRodriguez

    Jason Wilder Guest

    Are you picking an existing circle, and that array's 'up/north' and scales
    down as you describe? Or is the first circle placed at a fixed diameter?

    whole LISP routine process. I want to create a LISP that can both array and
    scale a set of circles. I need to draw hundreds of circles that the
    diameter of each circle changes by -.097938mm (as in gets smaller each time)
    for each array of 19mm. I hope this makes sense. I'll do my best to
    further discribe it. I have a circle. I need another circle 19mm above it
    that the diameter changes by -.097938. Every 19mm would be another circle
    scaling down in size.
    routine for this would be greatly appreciated. Please reply to this if I
    didn't make my self entirely clear.
     
    Jason Wilder, May 21, 2004
    #3
  4. JRodriguez

    Jason Wilder Guest

    crude and quick, but here you go:

    (defun c:car ( / )
    (setq dch 0.97938)
    (setq cir (entget (car (entsel))))
    (setq pt (cdr (assoc 10 cir)))
    (setq diam (* 2 (cdr (assoc 40 cir))))
    (while (> diam 0.5)
    (progn
    (command "_copy" "L" "" pt "@0,19")
    (setq cir (entget (entlast)))
    (setq pt (cdr (assoc 10 cir)))
    (setq sclr (/ (- diam dch) diam))
    (command "_scale" "L" "" pt sclr)
    (setq diam (- diam dch))
    );progn
    );while
    );defun

    This assumes the first circle is already drawn.
     
    Jason Wilder, May 21, 2004
    #4
  5. JRodriguez

    Jason Wilder Guest

    bah, this isn't the 'cleanest' way to do it using (command), i'd have to
    spend a little more time to make it more proper.
     
    Jason Wilder, May 21, 2004
    #5
  6. I'd try just drawing the circles at successively smaller sizes, rather than
    copying them and scaling them down one at a time -- makes a shorter routine,
    and seems more direct. Starting from Jason's, and changing a term or two
    for clarity, maybe something like:
    (defun c:car ( / )
    (setq cir (entget (car (entsel))));select circle [that already exists]
    (setq circenter (cdr (assoc 10 cir)));store center location
    (setq cirradius (cdr (assoc 40 cir)));store radius
    (while (> cirradius 0.5)
    (progn
    (setq circenter (list (car circenter) (+ (cadr circenter) 19)));locate
    center of next circle up
    (setq cirradius (- cirradius 0.48969));reduce radius value from
    previous circle
    (command "circle" circenter cirradius)
    );progn
    );while
    );defun

    [You don't need to set a decrement value "dch" if it's only going to be used
    once. And you don't need to calculate the diameter when assoc 40 is the
    radius and that's what the circle command wants to know anyway, but you do
    need to divide JRodriguez's diameter decrement value in half for a radius
    decrement value.]

    Kent Cooper, AIA
     
    Kent Cooper, AIA, May 21, 2004
    #6
  7. JRodriguez

    Jason Wilder Guest

    well, like i said - crude & quick :)

    If i spent more than 5 minutes on it, i would have done something more
    efficient.

    Reason I tend to assign one time values to variables like 'dch', is that
    some routines turn into one I want to use for diff values, so it's already
    set to receive a variable, I don't have to 'recode' too much.

     
    Jason Wilder, May 21, 2004
    #7
  8. JRodriguez

    T.Willey Guest

    (defun c:CirArr(/ ArrayAmount FirstCircle DistFac CircleCen CircleRAd NewAng NewCen NewRad)

    (setq ArrayAmount (getreal "\nEnter number of addition circle to create: "))


    (if (setq FirstCircle (entsel "\nSelect circle: "))
    (progn
    (setq DistFac 19)
    (setq FirstCircle (entget (car FirstCircle)))
    (setq CircleCen (cdr (assoc 10 FirstCircle)))
    (setq CircleRad (cdr (assoc 40 FirstCircle)))

    (while (not (setq NewDir (getpoint CircleCen"\nSelect direction to create new circles: "))))
    (setq NewAng (angle CircleCEn NewDir))
    (repeat (fix ArrayAmount)
    (setq NewCen (polar CircleCEn NewAng DistFac))
    (setq NewRad (- CircleRad (/ 0.097938 2)))
    (command "circle" NewCen NewRad)
    (setq CircleCen NewCen)
    (setq CircleRad NewRad)
    ); end repeat
    ); end progn
    ); end ir

    (princ)

    )
     
    T.Willey, May 21, 2004
    #8
  9. JRodriguez

    Jason Wilder Guest

    Sure, get all fancy with it. ;)
     
    Jason Wilder, May 21, 2004
    #9
  10. JRodriguez

    T.Willey Guest

    Just trying to get better. I writing lisp routines better than doing the cad work I have to.

    Thanks.... I take that as a compliment.

    Tim
     
    T.Willey, May 21, 2004
    #10
  11. JRodriguez

    T.Willey Guest

    Ooops... I "like" writing.... missed the like

    Tim
     
    T.Willey, May 21, 2004
    #11
  12. JRodriguez

    JRodriguez Guest

    I have the starting circle already drawn. So it would be a selection
     
    JRodriguez, May 21, 2004
    #12
  13. JRodriguez

    JRodriguez Guest

    WOW thanks so much guys. I'll try them out and let you know how your work turned out.

    Seriously, Thanks so much,
    JRodriguez
     
    JRodriguez, May 21, 2004
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.