Jump to content

I Have A Big Request!!


TheNewGuy

Recommended Posts

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    23

  • TheNewGuy

    19

I'm sorry, I didn't know you posted the finished version. Which post is it?

 

--edit-- I found your newest version.. I'll let you know shortly..

Link to comment
Share on other sites

I'm sorry, I didn't know you posted the finished version. Which post is it?

 

See post #20 :D

 

I thought that might have been the case o:)

Link to comment
Share on other sites

Yes! that is great. And I tried generating a table with the table command and it actually worked almost exactly the way we where hoping. Would it be rude of me if I asked for a few additions. I understand If you need to spread your help around. Thank you so much for all your hard work! I do not think that most people would have worked this hard for free, for a perfect stranger! You are one of a kind. Thank you.

Also the table I made had more than 2000 data points, so I am Realizing that this is bigger than I expected. Let me know if you feel like tweaking it, and if so help me to keep from asking for a feature that requires a lot of work on your part.

Link to comment
Share on other sites

With regards to the table I am realizing that what would be best is if a table could be made actively so that as I click on a point the distances are inserted into the table. That way I could have them in the table in the order that he needs them, without all the unneeded data. The EDM operator is drawing up a diagram of what his dream table would look like and what data would be in it. So let me talk to him and create an example of our dream table to show you, and if it would not require to much added work and you feel compelled to help even more you can. But I believe this does have everything required in it that he needs. Thank you, Thank you.

 

 

----EDIT----- I messed up!!! do not right anything else untill I get back with you.

Link to comment
Share on other sites

No problem - I'm glad it performed as needed :D

 

As for the table - are we talking about the csv file here? or a table in AutoCAD? Because if its the latter, then I can't really help you all that much, as '04 doesn't have this capability, and I have never created tables in LISP.

 

But, if its the csv file, then yes, I could create a code for you :)

Link to comment
Share on other sites

Your going to be mad at me! :(It appears that I gave you inaccurate info explaining what we needed.(I am blaming it on the EDM operator! He is not the sharpest tool in the shed) But it turns out that the points where supposed to rotate so that they always point toward the center of the base circle. AND the two "side" points are not simply at the side, they need to be in a straight line between the centers of two adjacent arrayed circles! I am really sorry! I messed this up bad!:oops: Here is an example.

As for the table, I don't know what a csv is. So, I'll worry about that later.

I messed up!.dwg

Link to comment
Share on other sites

Ohhh that is a big change... :P

 

As for what a csv file is, its the type of excel file that the data is written to. a "Comma Separated Value" file.

Link to comment
Share on other sites

Yea, I'm real sorry. It may not look like it would make a difference, and yes the circles could be cut out but apparently it would take much longer, as he says it takes about 2 min. to cut a distance of .05" so it would add up to much longer cut time..... I know,I know. I'll slap him for you. Trust me!

Link to comment
Share on other sites

OK, I have this so far - am I on the right track?

 

(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 (* i cAng) cut:cir)
                                (polar cPt (+ (* i cAng) (/ (+ pi cAng) 2.)) cut:cir)
                                (polar cPt (- (* i cAng) (/ (+ pi cAng) 2.)) 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))

 

EDIT: the points written to file will obviously be incorrect, but are the points in the right place on the drawing?

Link to comment
Share on other sites

Yes! he says the points there are in the right place! I am guessing you meant to leave out the two points on the bottom.(the ones that are spaced .05) Those two points should also rotate. like in my example.(Your probably bloody tired of this Yank by now, huh?)Thanks again.

Link to comment
Share on other sites

Yes! he says the points there are in the right place! I am guessing you meant to leave out the two points on the bottom.(the ones that are spaced .05) Those two points should also rotate. like in my example.(Your probably bloody tired of this Yank by now, huh?)Thanks again.

 

Yeah, I'm working on the two bottom points, they are a bit trickier to place :)

Link to comment
Share on other sites

OK, this should place the two lower points too.

 

(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 (* i cAng) cut:cir)
                                (polar cPt (+ (* i cAng) (/ (+ pi cAng) 2.)) cut:cir)
                                (polar cPt (- (* i cAng) (/ (+ pi cAng) 2.)) cut:cir)
                                (polar cPt (+ (* i cAng) pi theta) cut:cir)
                                (polar cPt (- (+ (* i cAng) pi) 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) " >>"))                  
     (close ofile))
   (princ "\n<!> Incorrect Selection <!>"))
 (princ))


Link to comment
Share on other sites

That is it! You got it!:D You are amazing. That took you about 20 min by my watch! Thank you so much for bearing with me.

With what I have now I can get all the distances that I need using the DISTANCE command in 2009. So we could be done. So do you want to move on to creating a kind of table? I was always planning to copy and past the table into excel any way so that would be fine. I need to sign off my computer so my boss can check his email so I will be off line for about 10 min.

Thanks again for all your hard work. If I am ever in London I'll buy you a pint!8).

Link to comment
Share on other sites

As for the table in Excel, a .csv file (see above for what it is!), is created in the same path as the drawing with all the distances already in there :)

Link to comment
Share on other sites

Ohhh, I wandered way these excel files with the name of my autocad drawings started to appear on my desktop! However I just did a test and I am not sure how I generated that file. I saved a new acad file with the name "csv test" and there is no csv file with that name. Also Is there an order that the values are generated in the csv...So I can tell what value aplies to what point in the drawing?

Link to comment
Share on other sites

Ohhh, I wandered way these excel files with the name of my autocad drawings started to appear on my desktop! However I just did a test and I am not sure how I generated that file. I saved a new acad file with the name "csv test" and there is no csv file with that name. Also Is there an order that the values are generated in the csv...So I can tell what value aplies to what point in the drawing?

 

The filename will be "_BASE.csv" (this can be changed).

 

As for which point is which, they will start at, 0 degrees (horizontal), and move counter-clockwise, row by row.

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...