Sambuddy Posted October 21, 2019 Author Posted October 21, 2019 This the excel input; DATA_1.scr test.dwg Quote
Sambuddy Posted October 21, 2019 Author Posted October 21, 2019 I think I am messing up with the (-) negative as a start of my coordinates. By removing them and running the lisp now I am getting: rlx? could this be the cause you think? Quote
rlx Posted October 21, 2019 Posted October 21, 2019 Compared variables and couldn't find significant differences. I runned my script in your drawing and it performed as suspected. Only (stupid / silly) way could be to run your script file thru a lisp. Don't expect it to make much difference but then , you've nothing to lose... (defun c:t1 ( / fn fp cmd) (if (and (setq fn (getfiled "Select script" "" "scr" 0))(setq fp (open fn "r"))) (while (setq cmd (read-line fp))(command cmd))) (if fp (close fp)) (princ)) (defun c:t2 ( / fn fp cmd cmd-list) (if (and (setq fn (getfiled "Select script" "" "scr" 0))(setq fp (open fn "r"))) (while (setq cmd (read-line fp))(setq cmd-list (cons cmd cmd-list)))) (if fp (close fp))(mapcar 'command (reverse cmd-list)) (princ)) both codes do the same , just tried two approaches but there are more like command-s , vl-cmdf and with error checking thr vl-catch-all-apply but think that would be overkill... Quote
Sambuddy Posted October 21, 2019 Author Posted October 21, 2019 is there a way for your lisp to say: run script 1, end then run script 2, end then ... under one command, same directory? Quote
Sambuddy Posted October 21, 2019 Author Posted October 21, 2019 one last time: is it possible for a lisp to say: pline <enter>, then open content from c:/temp/DATA_1.scr or txt, then paste? can it be done? Quote
rlx Posted October 21, 2019 Posted October 21, 2019 haven't tested it but maybe : (defun c:t3 ( / fn fp cmd) (foreach fn (list "c:\\temp\\1.scr" "c:\\temp\\2.scr" "c:\\temp\\3.scr") (if (and (findfile fn)(setq fp (open fn "r"))) (while (setq cmd (read-line fp))(command cmd))) (if fp (close fp)) ) (princ) ) just change the filenames in the (list "c:\\temp".... to your own. You could play with excluding one of the script files to see if one of them is giving you trouble Quote
rlx Posted October 21, 2019 Posted October 21, 2019 13 minutes ago, Sambuddy said: one last time: is it possible for a lisp to say: pline <enter>, then open content from c:/temp/DATA_1.scr or txt, then paste? can it be done? yes this can also be done, not a bad idea , code would only be a little different from my last code but if you don't mind .... ... 2morrow you're numero uno Quote
BIGAL Posted October 21, 2019 Posted October 21, 2019 Just replace the use a list with read a file. ; create pline from a list of points ; By Alan H March 2019 (defun AHpllst ( lst / x) (command "_pline") (while (= (getvar "cmdactive") 1 ) (repeat (setq x (length lst)) (command (nth (setq x (- x 1)) lst)) ) (command "") ) ) Quote
rlx Posted October 22, 2019 Posted October 22, 2019 (edited) damn , autocad licence server is down... so good luck with this : (defun c:t4 ( / fn fp cmd cmd-list) (vl-load-com) (mapcar '(lambda (x)(setvar (car x) (cadr x))) '(("limcheck" 0)("texteval" 1)("osmode" 0))) (foreach fn (list "c:/temp/data1.txt" "c:/temp/data2.txt" "c:/temp/data3.txt" "c:/temp/data4.txt" "c:/temp/data5.txt") (if (and (findfile fn)(setq fp (open fn "r"))) (progn (prompt (strcat "\n\nProcessing data from : " fn)) ;(while (setq cmd (read-line fp))(setq cmd-list (cons cmd cmd-list))) (while (setq cmd (read-line fp))(setq cmd-list (cons (vl-string-trim " " cmd) cmd-list))) (if (vl-catch-all-error-p (setq err (vl-catch-all-apply 'vl-cmdf (cons "._pline" (reverse cmd-list))))) (prompt (strcat "\n\n* * * error executing script from " fn))) (prompt (strcat "\n\nEnding pline command from data file " fn)) (while (= 1 (logand (getvar "cmdactive") 1))(command "")) (if fp (close fp))(setq cmd-list '()) ) ) ) (vla-ZoomExtents (vlax-get-acad-object)) (princ "\n\nProcessing data files completed") (princ) ) data1.txt data2.txt data3.txt data4.txt data5.txt Edited October 22, 2019 by rlx autocad server is back online... Quote
Sambuddy Posted October 22, 2019 Author Posted October 22, 2019 rlx, You have outdone yourself once more! I thank you for all your time and effort in producing this lisp (t4). However simple it may look to you, it is amazing how you can write your codes with little to no information I have given you and then your magic of coding happens! Thank you again Quote
rlx Posted October 22, 2019 Posted October 22, 2019 ah, you make me blush... Hope I still can sit tonight with so many feathers up my... Quote
Sambuddy Posted October 22, 2019 Author Posted October 22, 2019 Thanks man! I sincerely appreciate your work! Quote
Sambuddy Posted October 24, 2019 Author Posted October 24, 2019 Hey rlx, Your LISP (T4) does magic - the userform I created in excel is all plines for the first form as below and the result is just gorgeous: now that I am doing for second userform in excel, I am facing with another problem. Below is the form: As it happens I have some circle to draw - is there a way for your second LISP (say T5) to draw that up for me? My txt files are unique for every application - so for example my txt files for these three circles are data121.txt, data122.txt and data 123.txt. Could this exception be incorporated into the LISP? I especially likes not to use pline and close in every frickin coordinate on your previous LISP. Thanks rlx again Quote
rlx Posted October 25, 2019 Posted October 25, 2019 I suppose by getting all text files in a dedicated folder and by looking at their names you would be able to say 1-99 is pline , 100-200 is circle etc. Quote
BIGAL Posted October 25, 2019 Posted October 25, 2019 (edited) Does not make sense to me just add correct command as the 1st line like Pline, Line, Circle, Arc only need 1 program as always write the same file name. Spend the extra 5 minutes writing the scr file correct. See the post page 2 by LRM draws multiple plines in one go. Edited October 25, 2019 by BIGAL Quote
rlx Posted October 25, 2019 Posted October 25, 2019 Guess it makes perfectly sense to anyone comfortable with vba and not (yet) with lisp . Also OP said he had trouble with running script directly from vba but it worked when pasted to Autocad. Thats why I read the script itself and pass the input to autocad command even though its a bit like phoning one of the kids to come over and to pass on the salt or suger from me to their mother. But hey , if it works.... We have all been there , in despair over how lisp processes names & values. Quote
BIGAL Posted October 25, 2019 Posted October 25, 2019 Rlx If you look at your own post data 1.txt only needs Pline as 1st line and save as a script learning how scripts work is not that hard, for Sambuddy get a pencil and paper and write down all the steps all the enters etc when drawing an object. It dos not make sense to me to write a program to run multiple scripts rather than "BUILD" a dwg. Excel step 1, Autocad XXX, Excel step2 Autocad xxx, not very hard. If you want a mega script, then use the "A" option in file handling which is append to a file in your excel VBA. (defun c:xxxx ( / ) (command "script" "c:\\myfiles\\somejunk\\tower.scr") ) Quote
rlx Posted October 25, 2019 Posted October 25, 2019 (edited) He already tried that , at least that's what I understood , without succes. I still dont understand why splitting up the script works and one big srcipt doesn't. But for now it is what it is. Maybe if you could sit next to his computer and looking over his shoulder you could see what's going on but we can't. Inspired by his other post on the excel sheet with hyperlinks I'm writing a routine that can hyperlink a folder / mapped network folder and place all the subfolders as a hyperlink in a worksheet. I think I'm going to call it pup (pretty useless program) because windowskey+E and ctrl-F or something like that will get you there too but just for fun. Have a project folder at work with allmost 800 folder with a projectnumber in them. Getting the right one isn't really that hard but to get explorer open up in the right folder by typing just the project number could save me a few second a day well on this side of the planet its getting late ... Edited October 26, 2019 by rlx Quote
Sambuddy Posted November 14, 2019 Author Posted November 14, 2019 Special thanks to rlx for your LISP - I just posted a message on the tower profile post. I just finished completing the excel portion and with your elegant LISP I can now bring all my data right into cad so... Thanks rlx Quote
rlx Posted November 14, 2019 Posted November 14, 2019 I'm glad we , as a forum , were able to help you 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.