gazzalp Posted December 10, 2008 Share Posted December 10, 2008 Hi everyone, im wondering if theres a way in autocad 2007/2009, to be able to click on a straight line and autocad givoing me the length, without doing a distance and selecting the two end points. Ideally i want to be able to click on 50 different lines all differnet lengths and have autocad tell me how long they are (i want to do this quickly, so clicking on a line one by one and looking at properties isnt really an option.. Also if this is possible is there a way to get autocad to make a quick table, IE: line 1= 500mm, line 2=470mm. or even better if it could put it into an excel file. Thanks Quote Link to comment Share on other sites More sharing options...
Ritch7 Posted December 10, 2008 Share Posted December 10, 2008 i would just type DISTANCE or re-assign the command to d like what iv'e done because if im right d is for Dia. as default (Note only when drawing circles) it brings up the dim style manager as default! Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 10, 2008 Author Share Posted December 10, 2008 Thanks, but that doesn't really help. I know how to do a distance to get the length of a line, but with what im doing ill have 50-100 lines drawn, all of varying lengths. Rather than typing D, then clicking the start of the first line, then the end of the line and it telling me the distance, and then repeating those steps for the other lines, i want to be able to click on a line once, and autocad tell me the length of the line. Then continue this for the other hundred or so lines and hopefully have autocad either list down all the lengths to the side, or put it into an excel file. Even having the properties menu up doesnt make this process any quicker, because id still have to click on a line, look at the length and write it down, press escape (to deselect that line) then select the next line. Hope this clarifies what im looking for. Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 10, 2008 Author Share Posted December 10, 2008 Found out how to do it everyone, no need to reply now thanks Quote Link to comment Share on other sites More sharing options...
LifeoRiley0 Posted December 10, 2008 Share Posted December 10, 2008 Are you going to share this piece of info with us? I know I will probably need to do this at some point. Thanks Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 10, 2008 Author Share Posted December 10, 2008 Sure, i didnt think about putting it in here because i found it on this site (after quite a bit of searching) Im not sure how to do it in the box most people use, but this is what the code is: (defun c:LST( / name file ss ssi enl ln ar ci c2s) ;---------------------------- (defun ln (l f) ;To record a LINE l in the file f (write-line (strcat "LINE," (c2s (cdr (assoc 10 l))) (c2s (cdr (assoc 11 l))) (rtos (distance (cdr (assoc 10 l)) (cdr (assoc 11 l))))) f) ) ;---------------------------- (defun ar (l f / c r u1 u2) ;Record an ARC (setq c (cdr (assoc 10 l)) ;Center r (cdr (assoc 40 l)) ;Radius u1 (cdr (assoc 50 l)) ;Start... u2 (cdr (assoc 51 l)) ;...and End angle ) (write-line (strcat "ARC," (c2s (polar c u1 r)) (c2s (polar c u2 r)) (rtos (* r (abs (- u2 u1)))) "," (c2s c) (rtos r)) f) ) ;----------------------------- (defun ci (l f / r) ;To record a CIRCLE (setq r (cdr (assoc 40 l))) ;Radius (write-line (strcat "CIRCLE,,,,,,," (rtos (* 2 PI r)) "," (c2s (cdr (assoc 10 l))) (rtos (cdr (assoc 40 l)))) f) ) ;---------------------------- (defun c2s (x) ;Used to transform Coords in String (strcat (rtos (car x)) "," (rtos (cadr x)) "," (rtos (caddr x)) ",") ) ;---------------------------- (setq name (getvar "dwgname")) (if (= "." (substr name (- (strlen name) 3) 1)) (setq name (substr name 1 (- (strlen name) 4)))) (setq file (open (getfiled "Output file..." name "CSV" 1) "w") ss (ssget) ssi -1) (write-line "Typ,Start X,Start Y,Start Z,End X,End Y,EndZ,Length,cen X,cen Y,cenZ,Radius" file) (if ss (progn (repeat (sslength ss) (setq enl (entget (ssname ss (setq ssi (1+ ssi))))) (cond ((= "LINE" (cdr (assoc 0 enl))) (ln enl file)) ((= "ARC" (cdr (assoc 0 enl))) (ar enl file)) ((= "CIRCLE" (cdr (assoc 0 enl))) (ci enl file)) ) ))) ;end IF SS (close file) (princ) ) that will put the info in a seperate excel sheet. Now that ive done that, im wondering if anyonhe could help me with another two things: I want the code to be able to add another column on the end of the excel spreadsheet (after line length) which multiplies the length by 6.2 IE: length shows up as 200mm, the end column will say 1240. Also With what im doing each line represents a number of lines, ie one line is drawn but it represents between 2-5 lines. Id like the code to be able to ask me how many lines each represents after i click on each line. so the excel spreadsheet by the end will have everything it does now, as well as a column which multilpies the length by 6.2 and a column which has the number of lines that it represents. Hope that makes sense and any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 10, 2008 Share Posted December 10, 2008 Just as a side point, could you post your code in [ code] [/ code] brackets, as it makes it easier to read. Cheers Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 10, 2008 Author Share Posted December 10, 2008 Will do from now on, i didnt realise it was just the code tags that needed to be selected, im still new to this Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 11, 2008 Share Posted December 11, 2008 No probs gazzalp Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 11, 2008 Author Share Posted December 11, 2008 Does anyone know how to get the code to add a cell to the spreadsheet that would multiply the line length by 6.2? thanks for any help Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 12, 2008 Share Posted December 12, 2008 just multiply your lines by the amount you want before sending to excel (rtos (distance (rtos (* 6.2 (distance Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks, but that doesnt exactly help me. Im completely new to lisp, never looked at how they work or tried writing even the simplest of routines. Where exactly do i put that? thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 12, 2008 Share Posted December 12, 2008 Something like this: (defun c:LST (/ name file ss ssi enl ln ar ci c2s) ;---------------------------- (defun ln (l f) ;To record a LINE l in the file f (write-line (strcat "LINE," (c2s (cdr (assoc 10 l))) (c2s (cdr (assoc 11 l))) [b] [color=Red](rtos (* 6.2 (distance[/color][/b] (cdr (assoc 10 l)) (cdr (assoc 11 l)) ) ;_ end distance ) ;_ end * ) ;_ end rtos ) ;_ end strcat f ) ;_ end write-line ) ;_ end defun ;---------------------------- (defun ar (l f / c r u1 u2) ;Record an ARC (setq c (cdr (assoc 10 l)) ;Center r (cdr (assoc 40 l)) ;Radius u1 (cdr (assoc 50 l)) ;Start... u2 (cdr (assoc 51 l)) ;...and End angle ) ;_ end setq (write-line (strcat "ARC," (c2s (polar c u1 r)) (c2s (polar c u2 r)) (rtos (* r (abs (- u2 u1)))) "," (c2s c) (rtos r) ) ;_ end strcat f ) ;_ end write-line ) ;_ end defun ;----------------------------- (defun ci (l f / r) ;To record a CIRCLE (setq r (cdr (assoc 40 l))) ;Radius (write-line (strcat "CIRCLE,,,,,,," (rtos (* 2 PI r)) "," (c2s (cdr (assoc 10 l))) (rtos (cdr (assoc 40 l))) ) ;_ end strcat f ) ;_ end write-line ) ;_ end defun ;---------------------------- (defun c2s (x) ;Used to transform Coords in String (strcat (rtos (car x)) "," (rtos (cadr x)) "," (rtos (caddr x)) ",") ) ;_ end defun ;---------------------------- (setq name (getvar "dwgname")) (if (= "." (substr name (- (strlen name) 3) 1)) (setq name (substr name 1 (- (strlen name) 4))) ) ;_ end if (setq file (open (getfiled "Output file..." name "CSV" 1) "w") ss (ssget) ssi -1 ) ;_ end setq (write-line "Typ,Start X,Start Y,Start Z,End X,End Y,EndZ,Length,cen X,cen Y,cenZ,Radius" file ) ;_ end write-line (if ss (progn (repeat (sslength ss) (setq enl (entget (ssname ss (setq ssi (1+ ssi))))) (cond ((= "LINE" (cdr (assoc 0 enl))) (ln enl file)) ((= "ARC" (cdr (assoc 0 enl))) (ar enl file)) ((= "CIRCLE" (cdr (assoc 0 enl))) (ci enl file)) ) ;_ end cond ) ;_ end repeat ) ;_ end progn ) ;end IF SS (close file) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks alot for your help Lee, i can see your going to a bit of trouble to help me its much appreciated. I tried that above code, but for some reason it only did the same thing it had done before and didnt add the extra cell. Any idea why this might be? anyway now that our company has found out we can do that, we want to take it one step further. If you see the picture attached, what we ultimately want to do is kind of have 3 things linked to the excel spreadsheet. We want to be able to click on the line, and the length be taken to excel, but not only that but for it to somehow realise that each line is linked to one of the balloons and one of the numbers. so in the excel spreadsheet id like to see: Line 100 - 32.6m - 4, Line 101 - 14.7m - 4, Line 102 -18.4m - 5. Does this seem possible? I cant make the 3 items a block (because we want to be able to stretch it etc) so im not sure if this is too difficult ( also would be easier if each time we clicked on a line we didnt have to input the number, and instead the code realises what its linked to). Any help would be appreciated. Thanks heaps Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 12, 2008 Share Posted December 12, 2008 Sorry, I didn't make my earlier post clear - I just stumbled upon the last post asking how to incorporate the 6.2 factor and just showed you where to put it. Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 12, 2008 Author Share Posted December 12, 2008 argh i really dont think im the person to be trying lisps, now i get this error: ; error: malformed list on input I think i may hold off that part anyway, and see if the last thing i asked for can be done, that will save us alot more time. Anyone have any ideas how to do it? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 13, 2008 Share Posted December 13, 2008 Malformed list on input normally means you have simply left off a right parenthesis Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 13, 2008 Author Share Posted December 13, 2008 Still can't seem to get it working... ANyway i think ill hold off until i see if there's a way to link all 3 things together (like in one of my previous posts). Does anyone know how to do it? thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 13, 2008 Share Posted December 13, 2008 I think the user would have to select all three items, and not just the line for ACAD to be able to recognise what to do with them. Using the ssget function, one could quite easily deal with the data once the user has selected the items, but I cannot see how ACAD would recognise which line belonged to which circle and text.. etc etc Quote Link to comment Share on other sites More sharing options...
gazzalp Posted December 13, 2008 Author Share Posted December 13, 2008 So you dont think there is a way in autocad that it could kind of be a block, without actually being a block? IE i would have thought i could create a button that when selected, it asks for the start of a line, end of the line, bubble position and bubble number. Then once that is done it recognises that those 3 things were input at once so they are all connected. So in a way its like a block, but obviously i cant make it a block because i need to be able to lengthen/shorten the line etc. Otherwise if worse comes to worse maybe i will just select all 3 items (the line, bubble number, and number outside the bubble). So if the code could be something like: "select first line": (click on the first line) "enter number" (enter 100) "enter bubble number" (type in 4); "select second line" (click second line) "enter bubble number" (type in 4) and have the code realise that if the first number is 100, the next will be 101, then 102 etc, so after the first line im only clicking on the line, then typing in the bubble number. Anyone have any ideas on how to do this? 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.