gazzalp23 Posted August 30, 2020 Posted August 30, 2020 I've tried searching the forums but haven't found anything that does exactly what i want. I'm hoping there's a LISP routine where i can select two items - text and a line, and the lisp will output the results into an excel table. So for example: 1. Run Lisp 2. Select text 3. select line 4. repeat steps 2 & 3 until done. 5. LISP routine will output the outcome into an excel file with two Columns, one being the text value, and one being the line length. Does anyone know if this is possible/has already been done? Quote
gazzalp23 Posted August 31, 2020 Author Posted August 31, 2020 Thankyou dlanorh, that is exactly what i was after! To better suit what we are doing, are the following items possible: 1. Adding a column to excel for "start number" so when we first run the script it asks us for the start number, then as we pick each line, they are all numbered in the order we pick (but sometimes the start number might be 1, or it might be 200) 2. Give us the option of selecting the line text (sometime this is not needed, so sometimes we only need to select the line itself and get the length only) Thanks so much already for what you have already given me. Quote
dlanorh Posted September 3, 2020 Posted September 3, 2020 On 31/08/2020 at 23:23, gazzalp23 said: Thankyou dlanorh, that is exactly what i was after! To better suit what we are doing, are the following items possible: 1. Adding a column to excel for "start number" so when we first run the script it asks us for the start number, then as we pick each line, they are all numbered in the order we pick (but sometimes the start number might be 1, or it might be 200) 2. Give us the option of selecting the line text (sometime this is not needed, so sometimes we only need to select the line itself and get the length only) Thanks so much already for what you have already given me. Apologies for missing this. I will look at this tomorrow (well later today actually). Questions 1. (above) does this option require the line to be numbered in the drawing? 2. A better explanation as it seems you want to sometimes select text and a line and othertimes just a line which may be numbered or not. Probably better to ask for method and pick line first 3. why an extra excel column, what goes into it? 1 Quote
BIGAL Posted September 3, 2020 Posted September 3, 2020 Thought that is interesting how to do exists in multi radio buttons. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 1)) (setq ans (ah:butts but "V" (list (strcat "File : " cfile " already exists") "Append" "New File" "Overwrite") )) Quote
gazzalp23 Posted September 3, 2020 Author Posted September 3, 2020 Thanks heaps dlanorh! To make it clearer, what we typically have is 3 items: a line, a line number (lets say 150, 151, 152 etc) and a number parameter for that line (usually 3, 4 or 5) So using this script we are currently able to get the length of the line, and relate it to the number parameter (3/4/5). So if the script can ask what the "start number" I can input for this job the start number is "150". Then the first line and text i pick is for start number 150, then the next ones are 151, then 152 etc. The reason for this is because every job is different - the next job the start number might be 200, or 1, or 250 etc. Very minor issue, but would help greatly. Number 2 you are correct, sometimes we don't need to know the number parameter, just the line length; and like above, hopefully we can relate that to the line number. The extra column is for the line number (IE 150, 151, 152 as per above). So the final script would hopefully be: 1. Run lisp 2. Ask for start number. User inputs start number (say 150) 3. Ask if Number parameter (3, 4, 5) is needed. user inputs Y or N 4a. if answer is Y, it will be pick number, pick line, pick number, pick line and so on 4b if the answer is no, it will be pick line, pick line, pick line 5a . Excel output if answer is yes: Column A "start number" Column B "Number parameter" Column C "Line length" 5b. If the answer is No: Column A "start number" Column B "N/A" Column C "Line length" Hopefully this makes sense. If not happy to try and explain better to make it clearer. Quote
gazzalp23 Posted September 3, 2020 Author Posted September 3, 2020 For some reason i cant edit or delete the post above, but i think the below will make things easier to understand Thanks heaps dlanorh! To make it clearer, what we typically have is 3 items: a line, a line number (lets say 150, 151, 152 etc) and a number parameter for that line (usually 3, 4 or 5) So using this script we are currently able to get the length of the line, and relate it to the number parameter (3/4/5). So if the script can ask what the "start number" I can input for this job the start number is "150". Then the first line and text i pick is for line number 150, then the next ones are 151, then 152 etc. The reason for this is because every job is different - the next job the start number might be 200, or 1, or 250 etc. Very minor issue, but would help greatly. Number 2 you are correct, sometimes we don't need to know the number parameter, just the line length; and like above, hopefully we can relate that to the line number. The extra column is for the line number (IE 150, 151, 152 as per above). So the final script would hopefully be: 1. Run lisp 2. Ask for start number. User inputs start number (say 150) 3. Ask if Number parameter (3, 4, 5) is needed. user inputs Y or N 4a. if answer is Y, it will go pick number, pick line, pick number, pick line and so on 4b if the answer is no, it will go pick line, pick line, pick line 5a . Excel output example if answer is yes: Column A "start number" Column B "Number parameter" Column C "Line length" 150 3 2250 151 3 2400 152 5 1800 5b. If the answer is No: Column A "start number" Column B "Number parameter" Column C "Line length" 150 N/A 2250 151 N/A 2400 152 N/A 1800 So really the only difference is we have the option to choose whether we want to pick the number parameter (because to be honest a lot of the time we don't, so it means we are doing one extra click per line for no reason) and that we are giving the start number - as opposed to opening an excel file and the length just being in the first excel row - it will now have a number associated with it. 1 Quote
dlanorh Posted September 3, 2020 Posted September 3, 2020 OK, try the attached. I have tested (and it is working. I have switched to selecting the line first as this is the common to both options. It will allow you to select "LINES", "LWPOLYLINES", "POLYLINES" and "3DPOLYLINES" for the line and "TEXT" or "MTEXT" for the text. It should ignore any MTEXT in line formatting To exit the loop select a blank area of the screen on the "Select Line : " prompt and answer "Yes" to the prompt (default is "No") to allow for missed lines. Making a blank selection at the "Select Text : " prompt will display a "Missed" alert and then just loop back to the "Select Text" prompt. Line lengths are currently decimal to 3 decimal places. xpd.lsp 1 Quote
gazzalp23 Posted September 3, 2020 Author Posted September 3, 2020 (edited) That is awesome, exactly what i was after! Thankyou so much for doing that Actually there is one more thing that would be quite handy if possible, when selecting each line, is it possible to show us in the command line what number line we are selecting? For example, we input our start number as 100, then instead of saying "select line" click on line 100, "select line" click on line 101, it would actually prompt us and say "select line 100" click on line 100, "select line 101" click on line 101. Reason being we can have 150 or so lines, and it will be very easy to miss one or forget where we are up to. Otherwise no issues, it has saved us a heap of time, thanks! Edited September 3, 2020 by gazzalp23 Quote
dlanorh Posted September 3, 2020 Posted September 3, 2020 (edited) 28 minutes ago, gazzalp23 said: That is awesome, exactly what i was after! Thankyou so much for doing that Actually there is one more thing that would be quite handy if possible, when selecting each line, is it possible to show us in the command line what number line we are selecting? For example, we input our start number as 100, then instead of saying "select line" click on line 100, "select line" click on line 101, it would actually prompt us and say "select line 100" click on line 100, "select line 101" click on line 101. Reason being we can have 150 or so lines, and it will be very easy to miss one or forget where we are up to. Otherwise no issues, it has saved us a heap of time, thanks! A simple modification, so : Find this line (setq sel (entsel "\nSelect Line : ")) And change it to this (setq sel (entsel (strcat "\nSelect Line " (itoa snum) " : "))) Pretty sure this should do what you want, but I can't test as I only have a LT version with me at the moment. If it doesn't work let me know and I can sort tomorrow. if you need to do the same for the text (when applicable) Change (setq sel (entsel "\nSelect Line Text : ")) ;TO (setq sel (entsel (strcat "\nSelect Line " (itoa snum) " Text : "))) Edited September 3, 2020 by dlanorh added code for text if required 2 Quote
gazzalp23 Posted September 3, 2020 Author Posted September 3, 2020 That works, thanks heaps! that's it for now, no more changes haha. Thankyou 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.