Author Topic: Run a lisp without "C:Command"?  (Read 6182 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Run a lisp without "C:Command"?
« 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?

Code: [Select]
(defun C:TEST ()
 (if (findfile "C:/path/yourscript.scr")
 (command "_script" "C:/path/yourscript.scr")
 ); end if
 ); end function

Thanks for the input.
Civil3D 2020

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Run a lisp without "C:Command"?
« Reply #1 on: July 14, 2016, 09:40:14 AM »
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.

Code - Auto/Visual Lisp: [Select]
  1. (if (findfile "C:/path/yourscript.scr")
  2.   (command "_script" "C:/path/yourscript.scr")
  3. )
Speaking English as a French Frog

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Run a lisp without "C:Command"?
« Reply #2 on: July 14, 2016, 09:42:52 AM »
Just that simple? No need to for a defun:? Sweet.
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Run a lisp without "C:Command"?
« Reply #3 on: July 14, 2016, 09:58:29 AM »
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.
Civil3D 2020

squirreldip

  • Newt
  • Posts: 114
Re: Run a lisp without "C:Command"?
« Reply #4 on: July 15, 2016, 11:47:20 PM »
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.

mailmaverick

  • Bull Frog
  • Posts: 494
Re: Run a lisp without "C:Command"?
« Reply #5 on: July 19, 2016, 08:35:55 AM »
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.


MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Run a lisp without "C:Command"?
« Reply #6 on: July 19, 2016, 08:45:06 AM »
You are correct. Do you know of a way to email a script file? I have tried and it gets blocked once sent...
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Run a lisp without "C:Command"?
« Reply #7 on: July 19, 2016, 08:59:54 AM »
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)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Run a lisp without "C:Command"?
« Reply #8 on: July 19, 2016, 09:12:07 AM »
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).
Civil3D 2020

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Run a lisp without "C:Command"?
« Reply #9 on: July 19, 2016, 10:08:58 AM »
Consider what they are using AutoCAD for - unless they are a literal "CAD monkey" they should be capable of doing simple things like that.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

squirreldip

  • Newt
  • Posts: 114
Re: Run a lisp without "C:Command"?
« Reply #10 on: July 19, 2016, 12:44:18 PM »
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.

ChrisCarlson

  • Guest
Re: Run a lisp without "C:Command"?
« Reply #11 on: July 19, 2016, 01:29:43 PM »
Will they ever run this routine again? If yes, deploy a network wide CUIx file with the routine auto-loading.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Run a lisp without "C:Command"?
« Reply #12 on: July 19, 2016, 01:36:33 PM »
I also agree with the Network thing, but there might be times that they do not have any network access.
Civil3D 2020

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Run a lisp without "C:Command"?
« Reply #13 on: July 19, 2016, 02:22:36 PM »
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
Keep smile...

trogg

  • Bull Frog
  • Posts: 255
Re: Run a lisp without "C:Command"?
« Reply #14 on: July 19, 2016, 11:26:43 PM »
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
« Last Edit: March 10, 2023, 12:00:14 PM by trogg »