TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on July 14, 2016, 09:30:22 AM
-
Is there a way I can run a lisp without needing to type in a command to execute it? More like, drag and drop in AutoCAD and it runs?
(defun C:TEST ()
(if (findfile "C:/path/yourscript.scr")
(command "_script" "C:/path/yourscript.scr")
); end if
); end function
Thanks for the input.
-
Hi,
If you save the following code as runscript.lsp and you drag and drop this file from the explorer into the AutoCAD window the expression will evaluate.
(command "_script" "C:/path/yourscript.scr") )
-
Just that simple? No need to for a defun:? Sweet.
-
Just wanted to share alittle more on this. If you take this LSP and email it to a co-worker or so; drag the lisp from the email to a desktop, then to the AutoCAD window. It will automatically run.
-
You can also copy all the text (^C) then paste (^V) in the command line.
I do this all the time when testing code snippets.
-
Instead of dragging and dropping the LISP file which in turn calls the script file, it is simplest to drag and drop the Script File directly.
Drag and Drop of script file runs it directly.
-
You are correct. Do you know of a way to email a script file? I have tried and it gets blocked once sent...
-
You are correct. Do you know of a way to email a script file? I have tried and it gets blocked once sent...
Change the extension. (myscript.notscr)
-
I could email someone a script file with a (script-name.notscr) extension. Then request that they drag the file to their desktop, rename the extension to (script-name.scr). Finally, drag into AutoCAD and be done. Is that to many steps for a user? (Just doing the email thing).
-
Consider what they are using AutoCAD for - unless they are a literal "CAD monkey" they should be capable of doing simple things like that.
-
For attachments in emails I will often use 7-Zip and create .7z which most email servers will pass. Other than that I +1 to the renaming the extension.
-
Will they ever run this routine again? If yes, deploy a network wide CUIx file with the routine auto-loading.
-
I also agree with the Network thing, but there might be times that they do not have any network access.
-
you can also create a new shortcut with /b switch parameter allowing to execute script file.
see:
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-8E54B6EC-5B52-4F62-B7FC-0D4E1EDF093A
for more detail
-
Is there a way I can run a lisp without needing to type in a command to execute it? More like, drag and drop in AutoCAD and it runs?
As a CAD Admin, I have needed this approach as well. Here is what I do:
You simply need to only add the defined command after the closing parenthesis as shown below.
Make sure that the command is enclosed in its own parentheses)
~Greg
Edit: Make sure that the 'C:' is included as the prefix to the defun.
Thanks Kdub
-
Hi Trogg
The final line would need to be (C:CPR), surely ?
-
Hi Trogg
The final line would need to be (C:CPR), surely ?
I'm sorry, I should have made that more clear.
Don't remove the defined command at the top of the lisp. Leave that alone.
The only thing that I change in the routine is adding the command wrapped in parentheses at the end of the routine.
Updated in 2023...
I totally missed kerry's point with my response. Yes. The C: is included before the command as Kerry pointed out.
I have updated the image to be correct (after all these years...)
~Greg
-
Hi,
If you save the following code as runscript.lsp and you drag and drop this file from the explorer into the AutoCAD window the expression will evaluate.
(command "_script" "C:/path/yourscript.scr") )
I've Checked other file names and can say that every file name acts the same as runscript .
Every lisp file acts when drag and droped in AutoCAD.