Guest snoopy Posted August 30, 2004 Posted August 30, 2004 When I use the command props, I get all the properties of one selected item. Example: even the coordinates of the start-point of an arc are showed in this window. When I use the list command, I get also properties of one or more selected items. But it does not give alle the properties. Example: when I select the same arc, I only get a few data like 'center point' , radius,... It does not give the start- and end-point of the arc. So, How can I get a list of all properties of one or more selected items in the Text window that I get with the list command. The purpose is that I can easly copy the data, past it in a notepad-file and print it. (With the props-command I can not copy the data ) Does someone have an idea? Thanks snoopy Quote
Dommy2Hotty Posted August 30, 2004 Posted August 30, 2004 The reason you don't see some of the things that you would with just 1 entity selected is because those particular properties aren't the same between the two objects. I know that when you select 2 of the same entites, it will still show all the properties, but the ones that are different, i.e. start point, end point, radius, etc., will be displayed as *VARIES* instead of not showing up at all. Quote
fuccaro Posted August 31, 2004 Posted August 31, 2004 I think Snoopy need to export some properties to a text file. Snoopy, I can write a Lisp for this, but please write me what entities (arcs, lines...) do you need to export and what properties (end point, center point, start angle,...). Quote
Guest snoopy Posted August 31, 2004 Posted August 31, 2004 I think Snoopy need to export some properties to a text file. that's correct Snoopy, I can write a Lisp for this, but please write me what entities (arcs, lines...) do you need to export and what properties (end point, center point, start angle,...). Thanks a lot fuccaro The most things that I need is arcs and lines. The properties that I need: arc: start point, center point, end point and radius line: start point, end point and length At the moment it is enough that I can export these two entities with those properties. fuccaro, Thanks again ! snoopy Quote
fuccaro Posted August 31, 2004 Posted August 31, 2004 Snoopy Here is my try. It will return the points relative to the WCS. I don't know in what format you need the data, so I wrote the program to create a CSV file. Open that file in Excel and manipulate the data as you wish. ;| Program to export properties of ARC and LINE entities into a CSV file [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email] ---------------------------August 2004 |; (defun c:lst( / name file ss ssi enl ln ar c2s) ;---------------------------- (defun ln (l f / s e) ;To record a LINE l in the file f (setq s (cdr (assoc 10 l)) ;Start point e (cdr (assoc 11 l))) ;End point (write-line (strcat "LINE," (c2s s) (c2s e) (rtos (distance e s))) f) ) ;---------------------------- (defun ar (l f / c r s e) ;To record an ARC (setq c (cdr (assoc 10 l)) ;Center r (cdr (assoc 40 l)) ;Radius s (polar c (cdr (assoc 50 l)) r) ;Start e (polar c (cdr (assoc 51 l)) r)) ;End (write-line (strcat "ARC," (c2s s) (c2s e) "," (c2s c) (rtos r)) 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" 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) (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)) ) ) (close file) (princ) ) Quote
tlyall Posted August 31, 2004 Posted August 31, 2004 Fuccaro is the man! You really should update that website of yours with all that lisp knowledge you have pouring out of ya! What an invaluable resource that would be. BTW... Can you do a quick lisp routine for me? I need a lisp that is going to get up at 6:30 am, drive to work, function at max. capacity for 8 hours, drive back home, eat supper, have a cold beer and go to bed!!! Take care my friend! Tom Quote
fuccaro Posted September 1, 2004 Posted September 1, 2004 Fuccaro is the man!TlyallThe LST routine worked for you and in your opinion is a good one, right? Thank you for the feed-back! I need a lisp that...Yes, I can write that program but it will have 2 side effects;After work it will pick up and spend your salary and it will go in bed with your girlfriend/wife. Are you sure that you want it? You really should update that website of yours with all that lisp knowledge you have pouring out of ya!About my website: is true, I should update it. But I don't keep all the lisp routines I wrote. I keep organized the routines I frequently use. I wrote some routines for my friends and for other members (in this Forum and in others), so I let them to take care about those. Quote
fuccaro Posted September 3, 2004 Posted September 3, 2004 I modified the program to handle the circles too. Also the length is exported for all of the records. In this version as in the previous one too, you may use any selection method you wish. The program will filter out the other elements included in the selection set. Here is the code: ;| Program to export properties of ARC, CIRCLE and LINE entities into a CSV file [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email] ---------------------------August 2004 |; ;REVISIONS: September 2004 ; - Added CIRCLES to the list ; - Length calculation for all recorded entities ; - Handle the error if nothing is selected (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) ) Quote
Guest snoopy Posted September 5, 2004 Posted September 5, 2004 Fuccaro is the man! idd he is! Thanks a lot Fuccaro!! greetz snoopy Quote
vipulgos Posted December 20, 2009 Posted December 20, 2009 Dear all, I am new bee on this forum, I found out this post after 5 years!!. O.K. I have used this lsp command, works nicely. Can you please tell me how the lines are written in excel. I mean what is there in first line of CSV file? Is the line one we draw in CAD or last line we draw in CAD. How the line no 1, 2 ,3 and so on are written in CSV. Is there any sequence or it may be in random? This is very vital info for me, as I want to use this in my Estimation program which is in Excel only. Quote
fuccaro Posted December 20, 2009 Posted December 20, 2009 The program walks through the AutoCAD database and prints info about entities as it founds them. With other words: it honors the creation order. However: when copy-pasting more entities, I saw the order of pasted entities was reversed. Quote
vipulgos Posted December 21, 2009 Posted December 21, 2009 You are right, but Still confused, can I make it possible to directly communicate with these data for estimation work? and if so, from where should I started. Is there any way like keeping first line yellow, then red and so on and the same will be reflected in excel sheet by that colour or like that. I think, you can understand my point... Quote
fuccaro Posted December 22, 2009 Posted December 22, 2009 Sorry... I never did estimation work You wish to identify the exported data with the corresponding line or circle on the screen? There are only a few colors in AutoCAD -Yes, I know about true type colors, but I meant colors you can make the difference by eye. So if you export 160 object properties in the CSV file, using 16 colors you end-up with 10 red elements, 10 yellow and so on. This will still cause problems to you. How about inserting numbers? I could rewrite the lisp to place small numbers say at the middle of the lines and at the circles and arcs center point. But now I am at home. Expect urgent help from other members, or you will have to wait until the 11th of January. Quote
vipulgos Posted December 22, 2009 Posted December 22, 2009 if numbering line may help, it will be a better option. please guide accordingly. I will wait for you. In the mean while, if others can do it, it will be a great help for me thanks Quote
fuccaro Posted January 12, 2010 Posted January 12, 2010 ;| Program to export properties of ARC, CIRCLE and LINE entities into a CSV file mfuccaro@hotmail.com ---------------------------August 2004 |; ;REVISIONS: September 2004 ; - Added CIRCLES to the list ; - Length calculation for all recorded entities ; - Handle the error if nothing is selected ; ;January 2010 ; - numbering entities (defun putno(n p) (setq txtheight 3.5) (entmake (list '(0 . "TEXT") (cons 1 (rtos n)) (cons 10 p) (cons 40 txtheight) '(50 . 0.785398))) (eval n) ) (defun c:LST( / name file ss ssi enl ln ar ci c2s) ;---------------------------- (defun ln (l f n / p) ;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) (setq p (mapcar '* (mapcar '+ (cdr (assoc 10 l)) (cdr (assoc 11 l))) '(0.5 0.5 0.5))) (putno n p) ) ;---------------------------- (defun ar (l f n / 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) (putno n c) ) ;----------------------------- (defun ci (l f n / 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) (putno n (cdr (assoc 10 l))) ) ;---------------------------- (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) (setq n 1) (if ss (progn (repeat (sslength ss) (setq enl (entget (ssname ss (setq ssi (1+ ssi))))) (cond ((= "LINE" (cdr (assoc 0 enl))) (ln enl file (setq n (1+ n)))) ((= "ARC" (cdr (assoc 0 enl))) (ar enl file (setq n (1+ n)))) ((= "CIRCLE" (cdr (assoc 0 enl))) (ci enl file (setq n (1+ n)))) ) ))) ;end IF SS (close file) (princ) ) Quote
vipulgos Posted January 12, 2010 Posted January 12, 2010 Excellent! It has lot more than earlier code. In length column, there are entries which shows the difference between related fields. So, the differnece are being written as length..... Now, if this is possible, then I think, it may be possible to have line no. column also in the csv file after Typ column. Why I am interesting is because, once this is happened, then, looking to autoCAD drawing repeatedly, may be avoided.... also, the numbering is being done in drawing file as 1.0000, 2.0000, instead of 1,2 etc. Quote
fuccaro Posted January 12, 2010 Posted January 12, 2010 The Excel row number for each record is the same as the number placed in AutoCAD to the coresponding entity. As for the trailing zeros: it doesn't appear on my computer, it should be an issue of a sysvar (Luprec?). Try to change in the code: replace (rtos n) with (rtos n 2 0) Other than that I can't help you. These days I use AutoCAD only ocasionally. Quote
vipulgos Posted January 12, 2010 Posted January 12, 2010 o.k. the problem of trailing zeros has been solved by UNIT command. The row number you suggested is also very much appreciated. This much help is quite good and appreciated.... Quote
fuccaro Posted January 13, 2010 Posted January 13, 2010 I am getting old... Please forget about the RTOS command, it will try to convert a Real TO String. To convert an integer, use ITOA. Here is the code again: ;| Program to export properties of ARC, CIRCLE and LINE entities into a CSV file mfuccaro@hotmail.com ---------------------------August 2004 |; ;REVISIONS: September 2004 ; - Added CIRCLES to the list ; - Length calculation for all recorded entities ; - Handle the error if nothing is selected ; ;January 2010 ; - numbering entities (defun putno(n p) (setq txtheight 3.5) (entmake (list '(0 . "TEXT") (cons 1 (itoa n)) (cons 10 p) (cons 40 txtheight) '(50 . 0.785398))) (eval n) ) (defun c:LST( / name file ss ssi enl ln ar ci c2s) ;---------------------------- (defun ln (l f n / p) ;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) (setq p (mapcar '* (mapcar '+ (cdr (assoc 10 l)) (cdr (assoc 11 l))) '(0.5 0.5 0.5))) (putno n p) ) ;---------------------------- (defun ar (l f n / 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) (putno n c) ) ;----------------------------- (defun ci (l f n / 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) (putno n (cdr (assoc 10 l))) ) ;---------------------------- (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) (setq n 1) (if ss (progn (repeat (sslength ss) (setq enl (entget (ssname ss (setq ssi (1+ ssi))))) (cond ((= "LINE" (cdr (assoc 0 enl))) (ln enl file (setq n (1+ n)))) ((= "ARC" (cdr (assoc 0 enl))) (ar enl file (setq n (1+ n)))) ((= "CIRCLE" (cdr (assoc 0 enl))) (ci enl file (setq n (1+ n)))) ) ))) ;end IF SS (close file) (princ) ) Quote
Shivam Sharma Posted March 21, 2020 Posted March 21, 2020 can anyone modify this lisp to inset table in drawing itself instead of csv Quote
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.