Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp inputbox, Browse & Run button

8 REPLIES 8
Reply
Message 1 of 9
JCprog
661 Views, 8 Replies

Lisp inputbox, Browse & Run button

Hello EveryoneSmiley Happy

 

I've seen this done through lisp (e.g. custom input box) just have no idea how to go about what I intend to do.

 

Situation:

I have a folder (C:\folder1\scripts) that contains hundreds of .scr files which I browse through using script command and click open.

 

What I need is a lisp that invokes a popup with input box, browse and run button. Once browsed for the file, the exact path (e.g. C:\folder1\scripts\scr001.scr) remains in the input box till its browsed again but retains previous browsed files (think input box pull-down) and the run button will simply run the script that is in the input box and clear button should clear the dropdown lists. Hope I explained it well 🙂

 

I'd rather not deal with dcl or .net and do this strictly on lsp.

 

Thanks in advance Smiley Happy

8 REPLIES 8
Message 2 of 9
paullimapa
in reply to: JCprog

Quick routine to get what you are looking for without DCL:

 

; runscr function shows file selection window to select script to run
(princ"\nLoading...")(princ)
(defun c:runscr ()
 (if (null file_nam) (setq file_nam ""))
 (setq file_nam (getfiled "Select a Scripte File to Run" file_nam "scr" 2))
 (if file_nam                         ; Got filename?
  (command"_.Script" file_nam)
 )
)
(princ"\nRunScr command ready.")(princ)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 9
JCprog
in reply to: paullimapa

Thanks for the reply pli.....

 

That worked well!!!! However, I need it to point to my scr directory everytime it launch rather than "My Documents".

 

*It does retain my scr directory if I choose to run something from that directory but if I press cancel it goes back to "My Documents".

and also needs to retain the prvious run in the box.

Message 4 of 9
paullimapa
in reply to: JCprog

Then include in the lisp function the path and the first script file name ie: C:\folder1\scripts\scr001

This way, the lisp function will always show your script folder and if the selection window is cancelled, it'll set it back to the first script file as the default selection.

 

; runscr function shows file selection window to select script to run
(princ"\nLoading...")(princ)
(defun c:runscr (/ set_file)
 (defun set_file ()
  (if (null file_nam) (setq file_nam "C:\\folder1\\scripts\\scr001s"))
 )
 (set_file)
 (setq file_nam (getfiled "Select a Scripte File to Run" file_nam "scr" 2))
 (if file_nam                         ; Got filename?
  (command"_.Script" file_nam)
  (set_file)
 )
)
(princ"\nRunScr command ready.")(princ)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 9
paullimapa
in reply to: paullimapa

Oops...I accidentally included extra letter "s" in this line:
(if (null file_nam) (setq file_nam "C:\\folder1\\scripts\\scr001s"))
This line should instead be:
(if (null file_nam) (setq file_nam "C:\\folder1\\scripts\\scr001"))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 9
JCprog
in reply to: paullimapa

That didn't work either. Its really no different with the script command, it only differs from the dialogue box presentation.
Message 7 of 9
paullimapa
in reply to: JCprog

That's odd because the lisp routine should always come up with the default script file selected assuming it's named scr001.scr and located in folder: C:\folder1\scripts

Also the lisp routine will save the last script file selected when ran again as long as you don't close out of the current drawing session.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 8 of 9
hmsilva
in reply to: paullimapa

If you change
"C:\\folder1\\scripts\\scr001s"))
to
"C:\\folder1\\scripts\\"))
If no file was selected yet, the "c\\...\\" will be the start directory, if a .scr file was already selected in this drawing session, it will be shown as default.

 

Henrique

EESignature

Message 9 of 9
paullimapa
in reply to: hmsilva

Of course...I thought that the lisp routine would be an improvement compared to the standard SCRIPT command to have a default script file already selected instead of just showing the folder with no script file selected.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost