Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 I am amazed how quickly you can produce these programs! Thanks, its just practice Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 Did my LISP perform as required? *Just curious * Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 21, 2009 Author Share Posted May 21, 2009 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.. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 I'm sorry, I didn't know you posted the finished version. Which post is it? See post #20 I thought that might have been the case Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 21, 2009 Author Share Posted May 21, 2009 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. Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 21, 2009 Author Share Posted May 21, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 No problem - I'm glad it performed as needed 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 ----EDIT----- I messed up!!! do not right anything else untill I get back with you. Now this I want to hear... :P Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 22, 2009 Author Share Posted May 22, 2009 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! 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 Ohhh that is a big change... As for what a csv file is, its the type of excel file that the data is written to. a "Comma Separated Value" file. Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 22, 2009 Author Share Posted May 22, 2009 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! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 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? Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 22, 2009 Author Share Posted May 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 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)) Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 22, 2009 Author Share Posted May 22, 2009 That is it! You got it! 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!. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
TheNewGuy Posted May 22, 2009 Author Share Posted May 22, 2009 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 This probably explains it better: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.