Author Topic: Lisp to open a note pad  (Read 13900 times)

0 Members and 2 Guests are viewing this topic.

CadFrank

  • Guest
Lisp to open a note pad
« on: November 17, 2011, 01:28:15 PM »
Hi, I would like to know if a lisp routine exist for the fallowing explanation.

Ok well i have a Notepad saved as TimeTracker.txt in my desktop.

Would it be possible that when i press CTRL+S in AutoCad drawing that the file .txt open.

I would also like to know how i keep a .lsp loaded in a .dwt file.

Thx alot for all the help.

Cheers & Beers

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #1 on: November 17, 2011, 01:34:09 PM »
Code: [Select]
(startapp "notepad" "C:\\YourFilename.txt")

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #2 on: November 17, 2011, 01:39:20 PM »
Ok, lets say I do not know how to creat a lisp routine.

where would i put the script you posted?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #3 on: November 17, 2011, 01:45:30 PM »
At the point in your program at which you want the Text file to open, for example:

Code: [Select]
(defun c:test ( )
    (getstring "\nPress Enter to open Notepad...")
    (startapp "notepad")
    (princ)
)

Or, as a better example:

Code: [Select]
(defun c:test ( / file )
    (if (setq file (getfiled "Select Text File to Open" "" "txt" 16))
        (startapp "notepad" file)
    )
    (princ)
)

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #4 on: November 17, 2011, 01:45:59 PM »
Would this work?

Quote
(defun c:timet()

(startapp "notepad" "C:\\TimeTracker.txt")

)

(princ)

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #5 on: November 17, 2011, 01:46:56 PM »
So this would make it start when i press Ctrl+s or Save

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #6 on: November 17, 2011, 01:48:34 PM »
So this would make it start when i press Ctrl+s or Save

No, for that you would need to alter your cui.

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #7 on: November 17, 2011, 01:50:37 PM »
Would altering my cui. be hard or creat problems?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #8 on: November 17, 2011, 01:57:50 PM »
Would altering my cui. be hard or creat problems?

Not too difficult...

Type CUI at the command-line, navigate to 'Keyboard Shortcuts' > 'Shortcut Keys' > 'Save'

Alter the macro to call the LISP function before (or after) executing the 'qsave' command, e.g.:

Code: [Select]
^C^C(c:test);_.qsave

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #9 on: November 17, 2011, 02:11:02 PM »
Ok it works when i Save.. But if the text file i only want to open is TimeTracker.txt and i want it to open when i press Ctrl+S what should i change in the routine.

Code: [Select]
(defun c:timet ( / file )
    (if (setq file (getfiled "Select Text file To Open" "" "txt" 16))
        (startapp "notepad" file)
    )
    (princ)
)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Lisp to open a note pad
« Reply #10 on: November 17, 2011, 02:12:28 PM »
You can also do this from the commandline by default (defined in acad.pgp). just type NOTEPAD
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #11 on: November 17, 2011, 02:14:42 PM »
Ok it works when i Save.. But if the text file i only want to open is TimeTracker.txt and i want it to open when i press Ctrl+S what should i change in the routine.

Code: [Select]
(defun c:timet ( / file )
    (if (setq file (getfiled "Select Text file To Open" "" "txt" 16))
        (startapp "notepad" file)
    )
    (princ)
)

Hint:

Code: [Select]
(startapp "notepad" "C:\\YourFilename.txt")

You can also do this from the commandline by default (defined in acad.pgp). just type NOTEPAD

That's a new one for me, thanks.  :-)

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #12 on: November 17, 2011, 02:21:42 PM »
So it writes impossible to open file

Code: [Select]
(defun c:timet ( / file )
        (startapp "notepad" "C:\\Timetracker.txt")
    (princ)
)

Where should i put my .txt file for it to be found?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Lisp to open a note pad
« Reply #13 on: November 17, 2011, 02:42:07 PM »
Where should i put my .txt file for it to be found?

Anywhere - as long as the filepath in the startapp expression matches the location of the text file.

Code: [Select]
(startapp "notepad" <filepath of textfile>)

CadFrank

  • Guest
Re: Lisp to open a note pad
« Reply #14 on: November 17, 2011, 02:42:14 PM »
well i found the problem i guess i took out one of the 2 "\" int the C:\\TimeTracker.txt and it worked :D

Well Thx alot for your help Lee

Cheers & Beers !