**Using Autocad Electrical 2011
So here is what i have come up with:
I have 4 lisps, all saved in one file (new_project.lsp)...Not very original but i am just testing
I have them called out as
(defun 120VAC () (my lisp))
(defun 120VAC2 () (my lisp))
(defun 120to24 () (my lisp))
(defun 24vdc2 () (my lisp))
I created a macro calling a script file that i created for each lisp.
^C^C_.script;"t:/acad_autolisps/scripts/New_Project_Scripts/120VAC_Incoming.scr"
^C^C_.script;"t:/acad_autolisps/scripts/New_Project_Scripts/120VAC_Second.scr"
^C^C_.script;"t:/acad_autolisps/scripts/New_Project_Scripts/120VAC_to_24VDC.scr"
^C^C_.script;"t:/acad_autolisps/scripts/New_Project_Scripts/24VDC_Second.scr"
Everything works great. other than one thing.
In my script file I have the following setup:
filedia 0
_.open "t:\acad_autolisps\testing\test_project\000-00-07.dwg"
(load "new_project.lsp" nil)
(if 120vac (120vac))
My question is, is there a way to open a file in a script using a variable i set using the following command
(setq dwgname (car (c:wd_proj_getdwgnam (ace_getactiveproject) 6 0)))
I tried _.open dwgname...but this doesn't work,
I can also put in
(car (c:wd_proj_getdwgnam (ace_getactiveproject) 6 1)) which if i typed this into the command line it will open the 7th drawing in the project.
Iv'e tried a bunch of various ways that will open the drawing through the command line but not through script.
any ideas on how to make this work??
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Try messing around with this:
(Defun c:foo () (startapp (strcat "explorer /select, " (getvar "dwgprefix") (getvar "dwgname") ", /e")) )
and this:
(strcat (getvar "dwgprefix")(getvar "dwgname"))
HTH
Try
(vl-string-translate "/" "\\"" (car (c:wd_proj_getdwgnam (ace_getactiveproject) 6 0)))
should work...
HTH
Henrique
@gcsjlewis wrote:
This doesn't work either.... Here are my results
Command: (vl-string-translate "/" "\\"" (car (c:wd_proj_getdwgnam
(ace_getactiveproject) 6 0)))
("_>
("_> *Cancel*
; error: Function cancelled
...
First of all, sorry manamalewis, I couldn't test it and and had a typo...
what I had thought was
(vl-string-translate "\\" "/" (car (c:wd_proj_getdwgnam (ace_getactiveproject) 6 0)))
at the command line I think it works, in a .scr file, I don't know because at the moment I am out of the office and can't test ...
Henrique
Not the answer you expect, but can be a work around
Untested...
(defun c:MyScr (/ DWGNAME SCR SCRFILE) (if (setq dwgname (car (c:wd_proj_getdwgnam (ace_getactiveproject) 6 0))) (progn (setq scrfile "C:\\Windows\\temp\\MyScr.scr") (setq scr (open scrfile "w")) (write-line (strcat "filedia\n0") scr) (write-line (strcat "_open\n\"" dwgname "\"") scr) (write-line "(load \"new_project.lsp\" nil)" scr) (write-line "(if 120vac (120vac))" scr) (close scr) (command "_.SCRIPT" scrfile) );; progn );; if (princ) );; MyScrcr
HTH
Henrique
AWESOME!!! Thanks, I had to modify my lisp/script/macros alittle bit, but it works. I've read multiple times and places that user input cannot be used across different drawings and using different lisps all rolled into one project but this little bit of code that you did for me solved that problem... Thanks again