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

Determining the ACAD Application "WindowState" with AutoLISP

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
dmfrazier
1415 Views, 11 Replies

Determining the ACAD Application "WindowState" with AutoLISP

Okay, so after some searching I figured out that I can get the "WindowState" of AutoCAD with this code:

 

(vlax-get-property (vlax-get-acad-object) "WindowState")

 

This returns "3" when the window is maximized, and "1" when the window is "restored down" to something less than maximum.

 

I assume it would return "0" if the window were minimized to the taskbar (but I haven't tested that yet).

[Correction: it appears that minimized is "2".]

 

This is fantastic, but how (where) do I find out what are all the possible values of "WindowState" and their meanings?

 

What I mostly need to know is what that value would be if AutoCAD were running in "hidden" mode.

 

Also (bonus question), somewhere I saw a list of "VL" functions that includes VLAX-GET-WINDOWSTATE.  If such function exists, why doesn't this work?:

 

(vlax-get-WindowState (vlax-get-acad-object))

; error: no function definition: VLAX-GET-WINDOWSTATE

11 REPLIES 11
Message 2 of 12
Gary_J_Orr
in reply to: dmfrazier


@dmfrazier wrote:

Okay, so after some searching I figured out that I can get the "WindowState" of AutoCAD with this code:

 

(vlax-get-property (vlax-get-acad-object) "WindowState")

 

This returns "3" when the window is maximized, and "1" when the window is "restored down" to something less than maximum.

 

I assume it would return "0" if the window were minimized to the taskbar (but I haven't tested that yet).

[Correction: it appears that minimized is "2".]

 

This is fantastic, but how (where) do I find out what are all the possible values of "WindowState" and their meanings?

 

What I mostly need to know is what that value would be if AutoCAD were running in "hidden" mode.

 

Also (bonus question), somewhere I saw a list of "VL" functions that includes VLAX-GET-WINDOWSTATE.  If such function exists, why doesn't this work?:

 

(vlax-get-WindowState (vlax-get-acad-object))

; error: no function definition: VLAX-GET-WINDOWSTATE


 

For your "bonus question" (note the lack of an "x" in the second of the following two calls)

(Vlax-get-property obj <propertyname>) was the precursor to (Vla-get-<proprety name> obj)

for your original question: look into the "Visible" property (or is visible a method???? hmmm...)

to answer that question do this:

(vlax-dump-object (vlax-get-acad-object) T)

(the last argument of "T") on the dump object call tells the return to include methods as well as just properties.

 

-Gary

Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 3 of 12
dmfrazier
in reply to: Gary_J_Orr

"For your "bonus question" (note the lack of an "x"..."

 

Gotcha. Thanks.  (I have to be more careful when I search through that list of functions... it might help if I understood what the "X" means.)

 

"...look into the "Visible" property (or is visible a method?)"

 

"Visible" is indeed a property, and it probably is the right property, so thanks for that.  (I think I would have gotten there eventually - the "V" properties are a long way down the list...)

 

Help states that the Visible property can be either "true" or "false", and this appears to be supported by what this code returns when App window is "visible":

 

Command: (vla-get-Visible (vlax-get-acad-object))
:vlax-true

 

This is probably not going to impact my ability to use this info, but I am confused by the results of "dump-object", which includes this line:

 

;   Visible = -1

 

I'm used to 1 or 0 representing "true" or "false".  What would -1 indicate?

 

Thanks, again.

 

 

Message 4 of 12
Gary_J_Orr
in reply to: dmfrazier

While I don't pretend to understand the logic or reasons why the answer is:
-1 = :vlax-true
0 = :vlax-false

this is true for and T/F property returned by dump object
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 5 of 12
dmfrazier
in reply to: Gary_J_Orr

"this is true for and T/F property returned by dump object"

 

I think you meant ":vlax-true". Smiley Wink"

 

Thanks, again.

Message 6 of 12
dmfrazier
in reply to: dmfrazier

I still wonder where one would go to find out what are all the possible values of a non-binary (true/false) application/document/object/(etc.) property (such as "WindowState") and their meanings.

Message 7 of 12
Gary_J_Orr
in reply to: dmfrazier

The answer to that used to be: in the help file...

It should still be that simple. It isn't. You can't even go to the ADesk website and search for the required help with any reliability (unless doing that is what you do for a living and you know the exact search string to get exactly what you want, and the exact page that you need to be on to get the proper results)

So my response (before others chime in and start providing links to this specific version of ActiveX and that one, and you begin to go through all such...) is to contact your reseller and, if you have subscription, contact ADesk there) and ask them that question.

When Adesk started really pushing the "in-process" .net interface the ActiveX references disappeared from the help system and must be downloaded/found via other means... even worse, since 2013 the ability to truly navigate the help system went away, everything is search based with no manual navigation option. and trying to work with the "off-line" version is even more ridiculous...

Sorry, had to rant... this has been a sore spot for me for a while now... I actually have the old .chm help files from 2009 copied onto an external hard drive so I can look up something specific... just so I look up an "exact term" to help me figure out what I need to "search" for...

-G
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 8 of 12
hmsilva
in reply to: dmfrazier

Instead of

(vlax-get-WindowState (vlax-get-acad-object))

try

(vla-get-WindowState (vlax-get-acad-object))

return

1 = acNorm (normal window, not minimized or maximized)
2 = acMin (window minimized)
3 = acMax (window maximized)

hope that helps
Henrique

EESignature

Message 9 of 12
dmfrazier
in reply to: hmsilva

Thanks, Henrique.  (Gary sorted that out for me.)

Message 10 of 12
hmsilva
in reply to: dmfrazier

You're welcome, dmfrazier

Henrique

EESignature

Message 11 of 12
aqdam1978
in reply to: dmfrazier

hi,

 

just for clarification!:

 

(setq app (vlax-get-acad-object))
(setq doc (vla-get-activedocument app))

;for current drawing window
(vla-put-windowstate doc acmin)
(vla-put-windowstate doc acmax)
(vla-put-windowstate doc acnorm)

;for AutoCAD 
(vla-put-windowstate app acmin)
(vla-put-windowstate app acmax)
(vla-put-windowstate app acnorm)

 Abbas

 

 

 

Message 12 of 12
dmfrazier
in reply to: aqdam1978

Thank you, Abbas.

It turns out what I really needed was the "Visible" property.

This code retrieves the info I need: (vla-get-Visible (vlax-get-acad-object))

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

Post to forums  

Autodesk Design & Make Report

”Boost