Detecting the "AutoCAD Text Window"

Detecting the "AutoCAD Text Window"

Anonymous
Not applicable
2,676 Views
14 Replies
Message 1 of 15

Detecting the "AutoCAD Text Window"

Anonymous
Not applicable

Is there a way to detect (via LISP/VisualLISP) if the "AutoCAD Text Window" is open (or closed)?

 

I'd like to have the "AutoCAD Text Window" open at all times, in addition to the "Command Line" palette. I have a multi-monitor setup where I like to have certain palette and windows residing in the auxiliary monitors.

 

You see, every time you start AutoCAD, the "AutoCAD Text Window" is not open/is shown by default.

 

When I try to putting he command "TEXTSCR" in a start up LISP, it works fine for the first drawing, but when you start a next drawing, the same command closes it ("TEXTSCR" works like a toggle).

 

What would be nice is to have a pair of commands that would open the "AutoCAD Text Window" and close the "AutoCAD Text Window", respectively. Like "COMMANDLINE" and "COMMANDLINEHIDE".

 

Is this possible? Maybe with using vlax-create-object (which I will admit, I am not entirely familiar with).

 

Thanks, a bunch!

0 Likes
2,677 Views
14 Replies
Replies (14)
Message 2 of 15

scot-65
Advisor
Advisor
If you want the text window open all the time
why not simply undock the command line,
size it the same as the text window and move
it to the other monitor?

I could not readily find the setting (if there is one) in the registry...

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 15

BeKirra
Advisor
Advisor

Would this help?

Add the line below to your acaddoc.lsp

(command "TEXTSCR")

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 4 of 15

Anonymous
Not applicable

Hi BeKirra,

 

Thanks, but that doesn't work. As I mentioned before, the command "TEXTSCR" acts like a toggle. If the "AutoCAD Text Window" is not present, the command will open it. However, if it is present, the command will close it.

 

When you start up AutoCAD, for the first time, the "AutoCAD Text Window" is always not present, so "TEXTSCR" does the job. When you open another drawing (or start a new one), this same command will then close it. 

 

If there was a way to detect if it was open, I make a condition and use the command only if there is no window present.

0 Likes
Message 5 of 15

Anonymous
Not applicable

Hey Scot,

 

Yeah.... I tried that. Thing is, I like having the command like (as a single line) in my main window. It allows me to see the options of the current command running, the grips mode, or the widget mode. 

 

Once in a while I'll run a command (or work on a LISP routine) that will spit out more than one line of info, so then I will look over to my other monitor.

 

Thanks for replying, thou!

0 Likes
Message 6 of 15

Anonymous
Not applicable

Use the built-in lisp function (textscr) to always open the Text window. This does NOT act like a toggle.  If you use the AutoCAD Command: TEXTSCR 

Then this acts like a toggle.

So what can be done to always open the Text screen is to place the lisp function in startup: (textscr)

You can run the following sequence of lisp functions to always close the Text screen:

(textscr)(command"textscr")

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store

0 Likes
Message 7 of 15

BeKirra
Advisor
Advisor

IMO a one/two letter shortcut (e.g. TS for TextScr) may fit for your goal because it is simple and handy. Obviously it is not a "detection" approach but just simply works.

 

HTH

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 8 of 15

Anonymous
Not applicable

Hi Pli,

 

This doesn't work, BECAUSE I use the "Command Line" and "AutoCAD Text Window" at the same time.

 

When you use the LISP function (TEXTSCR), it "pops" up the "Command Line" (which I have set to a single line). This function has no effect on the "AutoCAD Text Window" if the "Command Line" is present. 

 

If I were not to use the "Command Line", this would be the solution. However, as I have said before, I like having both open.

I've exhausted many command combinations with no success to this particular case. That's why I am looking for a way to detect if the "AutoCAD Text Window" is open.

 

 

0 Likes
Message 9 of 15

Anonymous
Not applicable

Hi BeKirra,

 

I'm already doing this. I have a "shortcut" to run the TEXTSCR command. And it works really well.

 

I was hoping to create a solution that would require less interaction on my part.

 

I'm wondering if the solution can be found with VBA, .NET, or ObjectARX (an area I have little knowledge of, but looking to learn)?

0 Likes
Message 10 of 15

Anonymous
Not applicable

The way you are describing your use of the commandline, it sounds like it's undocked.  

If you dock the commandline (ie: drag it all the way till it touches the AutoCAD window border) even if it's showing a single line, (textscr) will still bring up the Text Screen.

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store

Message 11 of 15

DannyNL
Advisor
Advisor

Don't make the (textscr) command part of a LISP that is loaded by the startup suite, but put it in the S::STARTUP definition of the ACAD.LSP. That way it will only be executed once at startup and not with every drawing like the startup suite or ACADDOC.LSP which will toggle the text window.

Remains the problem that (textscr) will not open the text window when the commandline is not docked. You will need a LISP that will send the key combination CTRL+F2 to force the text window to open. See below.

Make sure the ACAD.LSP is located in one of the folders of your support paths as configured in your profile in the Options and to make the folder part of the trusted locations to prevent security warnings on loading.

 

Example ACAD.LSP

(defun TextWindow (/ SendKey)

   (defun SendKey (SK_Key / SK_WsObject)
      (if
         (setq SK_WsObject (vlax-create-object "Wscript.Shell"))
         (progn
            (vl-catch-all-apply 'vlax-invoke (list SK_WsObject 'sendkeys SK_Key))
            (vlax-release-object SK_WsObject)           
         )
      )
   )
   
  (SendKey "^{F2}")
)

(defun-q S::STARTUP ()
   (TextWindow)
   (princ)
)  

 

Message 12 of 15

Anonymous
Not applicable

Hi Pli,

 

Yes. You are right. My "Command Line" was not docked.

 

Your idea works, if I dock the "Command Line". However, I do not want to dock my "Command Line". When docked, it's "fat" and takes up space from my drawing area. Not by much, but I am fairly stingy with my drawing space, especially in the vertical direction.

 

Currently, I have the "Command Line" resting at the bottom of my drawing space with (almost) maximum transparency. Not only is it skinnier, it bears minimal interference my drawing space.

 

Thanks for the idea.

0 Likes
Message 13 of 15

Anonymous
Not applicable

Hi DannyNL,

 

This almost works.

 

First, I need to point out that the system variable ACADLSPASDOC needs to be set to '0'. For some reason, mine was set to '1', and ACAD.LSP was loading for every drawing.

 

Your "TextWindow" routine effectively does the same thing as using (command "textscr"), when adding it to the S::STARTUP routine, in ACAD.LSP. 

 

And it does work... almost.

 

When you close all the drawings (leaving AutoCAD open), the "AutoCAD Text Window" closes.

When you open/start a new  drawing from this point, ACAD.LSP will not run, and it will not open the "AutoCAD Text Window".

 

 

I know. I sound like I am being really picky here. While Pli and DannyNL have provided solutions that almost address my specific situation, it really doesn't answer my original question: "Can you detect if the AutoCAD Text Window is open?"

 

Thanks, everyone, for trying to help.

0 Likes
Message 14 of 15

scot-65
Advisor
Advisor
(graphscr)(textscr)

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 15 of 15

DannyNL
Advisor
Advisor

Yes, you are right; ACADLSPASDOC should be 0, but in any correctly configured AutoCAD environment this should be the case. ACAD.LSP is for loading once at AutoCAD startup, while ACADDOC.LSP is for loading in each opened/created drawing, so there is really no reason why ACADLSPASDOC should be 1.

 

And as ACAD.LSP is only loaded and executed during AutoCAD startup, it will not be executed again if you close all drawings but leave the AutoCAD session open and then open/create a drawing. That is as designed and expected behavior.

 

If you say the TextWindow function functions the same as using (command "TEXTSCR") and is not influenced by if the commandline is docked or not, I believe you on your word. I myself do not use something similar, so I cannot confirm nor deny if it's the same.

 

But as far as I know you cannot detect with LISP or VBA if the text window is open or not, so unless someone else comes up with a different solution you are stuck with the solutions as already in place or presented above.

And to be honest, I think your quest and time to find a solution to this problem is not justified,  since pressing CTRL+F2 on your keyboard takes less than a second to open up the text window if you find the text window closed.

Automating stuff is nice and fun, but should payoff compared to the time it takes do it manually.

 

But if you insist, you can probably do it like @scot-65 above suggests, only put the code in an ACADDOC.LSP (so it will be loaded and executed with each drawing) and change the function S::STARTUP to this

(defun-q S::STARTUP ()
   (grapschr)
   (TextWindow)
   (princ)
) 
0 Likes