LISP to display .txt in autocad dialog box

LISP to display .txt in autocad dialog box

Nathan_Tigner
Advocate Advocate
3,064 Views
10 Replies
Message 1 of 11

LISP to display .txt in autocad dialog box

Nathan_Tigner
Advocate
Advocate

Hey guys,

 

Currently I have a button in a tool palette that opens a read only lisphelp.txt document. This document holds all the lisps I autoload into my user computers and gives them the command and description of the lisp. This works fine except:

 

1. I can't control the font that each user has selected for notepad, so it looks different on everyone's machines.

2. It opens a second program other than CAD. I am using notepad instead of word or a pdf, because of it's speed, but it would be better if the button opened a dialog box that would read my text from lisphelp.txt.

 

I use a lee-mac lisp, Tip of the Day, to do exactly that and the pop-up box he uses in that lisp is perfect. I would like to create a lisp, that opens up that exact box (preferably one I can control the dimensions, like in his lisp) that reads from my lisphelp.txt doc. 

 

Any help would be greatly appreciated, I will attach the lee-mac tip of the day lisp below.

0 Likes
Accepted solutions (1)
3,065 Views
10 Replies
  • Lisp
Replies (10)
Message 2 of 11

john.uhden
Mentor
Mentor

I have a very old VIEWFILE.lsp that reads a file and displays the lines in a dialog box.  But it's not very friendly.  Lines of text are often longer than the width of the box.  I think I provided a horizontal scroll bar for that, but it's nothing as easy as reading an e-mail.

Oh, no.  I found it.  It displays up to 20 lines of text at a time with horizontal and vertical scroll bars + PgUp, PgDn, Home, and End.

Of course AutoLisp will read any ^Z as an end-of-file marker, so reading binary files is basically pointless.

I'll wrap it up for you if you want.  I certainly have no need for it

John F. Uhden

0 Likes
Message 3 of 11

Nathan_Tigner
Advocate
Advocate

I would greatly appreciate that. Thank you!

 

0 Likes
Message 4 of 11

CodeDing
Advisor
Advisor
Accepted solution

@Nathan_Tigner ,

 

Another Suggestion... Take that text file, wrap it in some HTML tags, save as .html extension, then just open that file in a browser. 

 

Then, the formatting would look the same on everybody's computer and they could still all be able to open the file.

 

You can either open it in their default browser:

(startapp "explorer" "c:\\users\\me\\desktop\\help.html")

...or in a Modal window in AutoCAD:

(showhtmlmodalwindow "c:\\users\\me\\desktop\\help.html")

 

Sample HTML file:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Here's Your Title</title>
</head>
<body>
  <h1>Here's your Header</h1>
  <p>Here's a basic sentence.</p>
</body>
</html>

 

Best,

~DD

Message 5 of 11

Kent1Cooper
Consultant
Consultant

How about an ALERT box?  It's all within AutoCAD, and unaffected by anyone's font settings in other software, etc.

 

I made up a sample of something like what it sounds like you're describing -- a listing of just some of my custom command names with brief descriptions [attached LispHelp.lsp so you can see how it's structured], with a (strcat) function stringing it all into one long text string and a "\n" for a new line at the start of each entry.  And I put into a Tool Palette button just this:

  (load "LispHelp")

which brings this up on-screen:

Kent1Cooper_0-1615917336414.png

The width of it is determined by the longest line in it, which can be quite a bit longer than these [limited by the width of your drawing area, perhaps?].

 

I'm not sure what happens if there are more lines than the screen can accommodate, vertically.  If you have too many for one Alert box, you could have "classes" of command names with separate Tool Palette buttons for each category.

 

Kent Cooper, AIA
Message 6 of 11

CodeDing
Advisor
Advisor

I agree with Kent that the (alert ...) box should be the FIRST method of popup information. In my mind I think I had assumed we had eliminated that route, but I should not be assuming that. Sometimes the alert box can not accomplish the desired end state for information you want to convey to the user, and ONLY in that scenario would I recommend stepping into other suggested options.

 

Best,

~DD

0 Likes
Message 7 of 11

john.uhden
Mentor
Mentor

Here ya go.  Files attached.

But I must say that I like @CodeDing 's answer a lot better.

John F. Uhden

0 Likes
Message 8 of 11

Sea-Haven
Mentor
Mentor

I agree use Alert, if you have a long winded file then just open notepad and the file.

 

(startapp "NOTEPAD" "d:\\lisp\\2d-door-help.txt")

 

 

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... if you have a long winded file then just open notepad and the file. ....


[That's what they've been doing, but see Message 1, "except" item 1.]

Kent Cooper, AIA
0 Likes
Message 10 of 11

Nathan_Tigner
Advocate
Advocate

I had tried using a browser and wasn't a fan but the modal window worked perfectly. Plus, having the ability to format it how I want is a big plus. 

 

I tried the alert box as well mentioned below and it definitely worked, but the modal window is fast, looks good and does exactly what I wanted.

 

Kudos to you and thanks for the help.

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

Sorry kent was meant for Nathan but as requested not font friendly, so attempt 2.

(command "shell" "d:\\alan\\lisp\\help34.bat")

This is help34.bat, you must have pause else  will open then close.

type  "d:\alan\lisp\help34.txt"
Pause

This is  

0 Likes