Jump to content

I Have A Big Request!!


TheNewGuy

Recommended Posts

I have a big request for a big lisp program. It needs to calculate and draw a series or circle arrays inside a big circle. Then plot 5 points for each circle in each array, and then transfer those points into a table. :oThis is for our EDM machine, and will save the operator a lot of time. I was hoping to learn lisp and do this myself but we need it sooner than 3 years from now. So... any one want to save my tail?:oops: Just ask if you need more info. Thanks in advance.

Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    23

  • TheNewGuy

    19

How are these circles to be arrayed?

 

Could you post a diagram/drawing (in 2004 format) to illustrate what needs to be achieved :)

 

Thanks

 

Lee

Link to comment
Share on other sites

Try this.

 

A few notes;-

 

  • The spacing between the circles is the minimum, hence the circles are evenly spaced, so the spacing between them may be greater than that specified.

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:cCut  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] doc spc cEnt tNum tmp1 tmp2
                 tmp3 tmp4 bsRad cCen cNum cAng i[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-Acad-Object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] :vlax-true[b][color=RED])[/color][/b]
               [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b]
               [b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] cut:out [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:out [b][color=#009999]0.05[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] cut:spc [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:spc [b][color=#009999]0.007[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] cut:row [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:row [b][color=#009999]0.02[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] cut:cir [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:cir [b][color=#009999]0.125[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Base Circle: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"CIRCLE"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tNum [b][color=#009999]0.[/color][/b] col [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp1 [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Spacing from Edge <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] cut:out[b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] tmp1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:out tmp1[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp2 [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Circle Spacing <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] cut:spc[b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] tmp2[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:spc tmp2[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp3 [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Row Spacing <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] cut:row[b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] tmp3[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:row tmp3[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]initget[/color][/b] [b][color=#009900]6[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp4 [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\nSpecify Inner Circle Radius <"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] cut:cir[b][color=RED])[/color][/b] [b][color=#ff00ff]"> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] tmp4[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cut:cir tmp4[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] bsRad [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]40[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] cut:out cut:cir[b][color=RED])[/color][/b]
           cCen  [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]minusp[/color][/b] bsRad[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]<[/color][/b] cut:cir bsRad[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cNum [b][color=RED]([/color][/b][b][color=BLUE]fix[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]2[/color][/b] pi bsRad[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]2[/color][/b] cut:cir[b][color=RED])[/color][/b] cut:spc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
             cAng [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]2[/color][/b] pi[b][color=RED])[/color][/b] cNum[b][color=RED])[/color][/b]
             i    [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]<[/color][/b] i cNum[b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]vla-put-color[/color][/b]
           [b][color=RED]([/color][/b][b][color=BLUE]vla-addCircle[/color][/b] spc
             [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b]
               [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] cCen [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] i cAng[b][color=RED])[/color][/b] bsRad[b][color=RED])[/color][/b][b][color=RED])[/color][/b] cut:cir[b][color=RED])[/color][/b] col[b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b] tNum [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] tNum[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] bsRad [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] bsRad [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]2[/color][/b] cut:cir[b][color=RED])[/color][/b] cut:row[b][color=RED])[/color][/b] col [b][color=RED]([/color][/b][b][color=BLUE]abs[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] col [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n<< Number of Circles: "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] tNum [b][color=#009900]2[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]" >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Link to comment
Share on other sites

Thank you! That is perfect.:D I can't believe how quick you are with this! Is it possible to make a table that records the points I illustrated in my drawing? And If that was not enough.. Now the EDM operator is saying that he also would like to know the incremental distance of each point from the center of it's respective circle.....So in all He wants the table to record the absolute distance from the center of the base circle(0,0,0) to all the six points I drew in the drawing for each arrayed circle. AND the Incremental distance of the five points surrounding each arrayed circle to the center of that arrayed circle. :oops:........Does that make sense? I know that is asking an awfull lot and I would not blame you for not doing it however with out your help I got no other options. I am not even close to being able to give him what he needs.So......Thank you in advance?....o:)

Link to comment
Share on other sites

Hmmm.. I'm a little confused by such requests.

 

The distance from the center of each circle to any point on the circle is always going to be equal to the radius.

 

The distance from the center of the main circle to the center of each circle will be the same as that to the point on each side.

 

So why are these points needed?

 

As in the pic below:

 

All the Cyan Lines are equal as are the Green lines - so why are all these points needed?

example.jpg

Link to comment
Share on other sites

Yea I guess you are right, let me talk to the edm operator again and get back with you. I think him and I have had a misunderstanding.

Link to comment
Share on other sites

OK I think I understand what he needs. From a CNC programing perspective he needs the straight up y distance and the straight over x distance. You are correct that a lot of the info can be figured out from the drawing quickly and some of the info will be the same for each arrayed circle. So I trust you to remove any unneeded info from the table. And if this is to much to ask for I understand that as well. Thanks again for all your help. Also he was getting his hopes up that your amazing programing will save him from doing abunch of adding and subtracting.

edm program help v2-2004.dwg

Link to comment
Share on other sites

OK I think I understand what he needs. From a CNC programing perspective he needs the straight up y distance and the straight over x distance.

 

 

OK, so before I get started - just to confirm.

 

He needs the x and y relative to the center of the main circle to each of the points that you have illustrated?

 

Am I somewhere near the mark?

Link to comment
Share on other sites

Oh, and one more thing -

 

With regards to the two base points at the bottom of the circle, how is the position of these determined?

 

I have seen your drawing, but I assume that will only apply for that particular radius of circle?

 

Lee

Link to comment
Share on other sites

Based on your initial requests (and my assumptions!)

 

(defun c:cCut  (/ doc spc cEnt root ofile tNum tmp1 tmp2
                 tmp3 tmp4 bsRad cCen cNum cAng i cPt str)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (setvar "PDMODE" 3)      ; Point Style
 (setvar "PDSIZE" 0.01)  ; Point Size

 (or cut:out (setq cut:out 0.05))
 (or cut:spc (setq cut:spc 0.007))
 (or cut:row (setq cut:row 0.02))
 (or cut:cir (setq cut:cir 0.125))

 (if (and (setq cEnt (car (entsel "\nSelect Base Circle: ")))
          (eq "CIRCLE" (cdr (assoc 0 (entget cEnt)))))
   (progn
     (setq root (strcat (getvar "DWGPREFIX")
                        (substr (getvar "DWGNAME") 1
                                (- (strlen (getvar "DWGNAME")) 4)))
           tNum 0. col 1
           ofile (open (strcat root "_BASE.csv") "w"))
     (write-line "Centre,Top,Right,Left,Bottom Right,Bottom Left" ofile)
     (initget 4)
     (setq tmp1 (getreal (strcat "\nSpecify Spacing from Edge <" (rtos cut:out) "> : ")))
     (or (not tmp1) (setq cut:out tmp1))
     (initget 4)
     (setq tmp2 (getreal (strcat "\nSpecify Circle Spacing <" (rtos cut:spc) "> : ")))
     (or (not tmp2) (setq cut:spc tmp2))
     (initget 4)
     (setq tmp3 (getreal (strcat "\nSpecify Row Spacing <" (rtos cut:row) "> : ")))
     (or (not tmp3) (setq cut:row tmp3))
     (initget 6)
     (setq tmp4 (getreal (strcat "\nSpecify Inner Circle Radius <" (rtos cut:cir) "> : ")))
     (or (not tmp4) (setq cut:cir tmp4))
     (setq bsRad (- (cdr (assoc 40 (entget cEnt))) cut:out cut:cir)
           cCen  (cdr (assoc 10 (entget cEnt))))
     (while (and (not (minusp bsRad))
                 (< cut:cir bsRad))
       (setq cNum (fix (/ (* 2 pi bsRad) (+ (* 2 cut:cir) cut:spc)))
             cAng (/ (* 2 pi) cNum)
             i    0 str "")
       (while (< i cNum)
         (vla-put-color
           (vla-addCircle spc
             (vlax-3D-point
               (setq cPt (polar cCen (* i cAng) bsRad))) cut:cir) col)
         (foreach x (list cPt (polar cPt (/ pi 2) cut:cir)
                              (polar cPt 0  cut:cir)
                              (polar cPt pi cut:cir)
                              (polar (polar cPt 0  0.0396) (/ (* 3 pi) 2) 0.1186)
                              (polar (polar cPt pi 0.0396) (/ (* 3 pi) 2) 0.1186))
           (vla-addPoint spc (vlax-3D-point x))
           (setq str (strcat str (vl-princ-to-string x) (chr 44))))
         (write-line str ofile)
         (setq i (1+ i) tNum (1+ tNum) str ""))
       (setq bsRad (- bsRad (* 2 cut:cir) cut:row) col (abs (- col 3))))
     (princ (strcat "\n<< Number of Circles: " (rtos tNum 2 0) " >>"))
     (close ofile))
   (princ "\n<!> Incorrect Selection <!>"))
 (princ))

Link to comment
Share on other sites

First off I really appreciate all your hard work and I hope I can some day return the favor some how.

 

OK, so before I get started - just to confirm.

 

He needs the x and y relative to the center of the main circle to each of the points that you have illustrated?

 

Am I somewhere near the mark?

Yes you are near the mark. That is what he needs. And he would like to have the relative x and y distance from the center of each arrayed circle to each of the points also. As you pointed out some of the distances will be the same for each circle so you can remove them from the table if it makes it easier.

 

Oh, and one more thing -

 

With regards to the two base points at the bottom of the circle, how is the position of these determined?

 

I have seen your drawing, but I assume that will only apply for that particular radius of circle?

 

Lee

 

These two points should Ideally be .050 apart (This is so that the circle does not drop out when cut from the base circle until he is ready. Then when he is ready it is a short .05 cut to remove the circle.)

The other points should simply be at the top of each arrayed circle and two points at either side.

 

Also I attached a drawing showing how he is going to make his cuts. This may help to clarify things up. Pleas don't hesitate to ask if you need more info or if I have confused you.

(I know he has confused me!)

Thanks again

 

--edit-- The drawing I attached is not to scale or positioned properly it is just to illustrate the movements of his machine....

edm program help v3-2004.dwg

Link to comment
Share on other sites

First off I really appreciate all your hard work and I hope I can some day return the favor some how.

 

Thanks, it is always nice when a person is appreciative of the work + time :)

 

And he would like to have the relative x and y distance from the center of each arrayed circle to each of the points also. As you pointed out some of the distances will be the same for each circle so you can remove them from the table if it makes it easier.

 

Still not too sure about this - do you mean from each circle to every other circle in the grid?

 

 

These two points should Ideally be .050 apart (This is so that the circle does not drop out when cut from the base circle until he is ready. Then when he is ready it is a short .05 cut to remove the circle.)

The other points should simply be at the top of each arrayed circle and two points at either side.

 

I based this initially on the drawing you posted, but I shall update the LISP to make it 0.05 every time (for all radii) :)

Link to comment
Share on other sites

Still not too sure about this - do you mean from each circle to every other circle in the grid?

 

Sorry I meant from the center of each arrayed circle to the points on that circle.... does that help?

Link to comment
Share on other sites

Sorry I meant from the center of each arrayed circle to the points on that circle.... does that help?

 

Yes, obviously this will be the same for each circle - so I shall include it as a separate line on the bottom of the file.

 

Anything else that needs raising about the posted LISP above? (#12)

Link to comment
Share on other sites

I did notice that in the posted lisp the bottom 2 points do not follow the circle when a radius other than .125 is used. They appear to stay in the location that they would be in for a circle with a .125 radius. I am not complaining but I would hate to ask you to redo any of your hard work. Thanks again!

Link to comment
Share on other sites

I did notice that in the posted lisp the bottom 2 points do not follow the circle when a radius other than .125 is used. They appear to stay in the location that they would be in for a circle with a .125 radius. I am not complaining but I would hate to ask you to redo any of your hard work. Thanks again!

 

That is expected, as I wasn't sure of the positions, but I just wondered if there was anything else that needed changing. :)

Link to comment
Share on other sites

No, other than the table for all the distances we talked about the posted lisp is exactly what I was wanting! I am amazed how quickly you can produce these programs!

Link to comment
Share on other sites

OK, I have made a few changes in this version:

 

  • All points are relative - no matter where you draw your circle in your drawing, the points written to file will be relative to the Center of respective circles.

  • The Bottom Left, and bottom right points will be spaced at 0.05, irrelevant of the radius of the circle.

  • The Points relative the smaller circles are written beneath the main results as a one-liner.

(defun c:cCut  (/ doc spc cEnt root ofile tNum tmp1 tmp2 theta
                 tmp3 tmp4 bsRad cCen cNum cAng i cPt str)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (setvar "PDMODE" 3)      ; Point Style
 (setvar "PDSIZE" 0.01)  ; Point Size

 (or cut:out (setq cut:out 0.05))
 (or cut:spc (setq cut:spc 0.007))
 (or cut:row (setq cut:row 0.02))
 (or cut:cir (setq cut:cir 0.125))

 (if (and (setq cEnt (car (entsel "\nSelect Base Circle: ")))
          (eq "CIRCLE" (cdr (assoc 0 (entget cEnt)))))
   (progn
     (setq root (strcat (getvar "DWGPREFIX")
                        (substr (getvar "DWGNAME") 1
                                (- (strlen (getvar "DWGNAME")) 4)))
           tNum 0. col 1
           ofile (open (strcat root "_BASE.csv") "w"))
     (write-line "Centre,Top,Right,Left,Bottom Right,Bottom Left" ofile)
     (initget 4)
     (setq tmp1 (getreal (strcat "\nSpecify Spacing from Edge <" (rtos cut:out) "> : ")))
     (or (not tmp1) (setq cut:out tmp1))
     (initget 4)
     (setq tmp2 (getreal (strcat "\nSpecify Circle Spacing <" (rtos cut:spc) "> : ")))
     (or (not tmp2) (setq cut:spc tmp2))
     (initget 4)
     (setq tmp3 (getreal (strcat "\nSpecify Row Spacing <" (rtos cut:row) "> : ")))
     (or (not tmp3) (setq cut:row tmp3))
     (initget 6)
     (setq tmp4 (getreal (strcat "\nSpecify Inner Circle Radius <" (rtos cut:cir) "> : ")))
     (or (not tmp4) (setq cut:cir tmp4))
     (setq bsRad (- (cdr (assoc 40 (entget cEnt))) cut:out cut:cir)
           cCen  (cdr (assoc 10 (entget cEnt))))
     (while (and (not (minusp bsRad))
                 (< cut:cir bsRad))
       (setq cNum (fix (/ (* 2 pi bsRad) (+ (* 2 cut:cir) cut:spc)))
             cAng (/ (* 2 pi) cNum)
             i    0 str "")
       (while (< i cNum)
         (vla-put-color
           (vla-addCircle spc
             (vlax-3D-point
               (setq cPt (polar cCen (* i cAng) bsRad))) cut:cir) col)
         (setq theta (atan
                       (/ (/ 0.025 cut:cir)
                          (sqrt
                            (- 1. (expt (/ 0.025 cut:cir) 2))))))
         (foreach x (mapcar '(lambda (x) (mapcar '- x cCen))
                  (list cPt (polar cPt (/ pi 2) cut:cir)
                              (polar cPt 0  cut:cir)
                              (polar cPt pi cut:cir)
                              (polar cPt (+ (/ (* 3 pi) 2) theta) cut:cir)
                              (polar cPt (- (/ (* 3 pi) 2) theta) cut:cir)))
           (vla-addPoint spc (vlax-3D-point (mapcar '+ cCen x)))
           (setq str (strcat str (vl-princ-to-string x) (chr 44))))
         (write-line str ofile)
         (setq i (1+ i) tNum (1+ tNum) str ""))
       (setq bsRad (- bsRad (* 2 cut:cir) cut:row) col (abs (- col 3))))
     (princ (strcat "\n<< Number of Circles: " (rtos tNum 2 0) " >>"))
     (write-line "Points Rel. Inner Circle:" ofile)
     (write-line (strcat "(0 0 0),(0 " (rtos cut:cir) " 0),("
                         (rtos cut:cir) " 0 0),(" (rtos (* -1. cut:cir))
                         " 0 0),(" (rtos (* cut:cir (sin theta))) (chr 32)
                         (rtos (* -1. cut:cir (cos theta))) " 0),("
                         (rtos (* -1. cut:cir (sin theta))) (chr 32)
                         (rtos (* -1. cut:cir (cos theta))) " 0)") ofile)                          
     (close ofile))
   (princ "\n<!> Incorrect Selection <!>"))
 (princ))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...