Jump to content

F2 function as lisp command


MJLM

Recommended Posts

This may be a rather lame question but how can I bring up the "Autocad Text Window" using autolisp instead of the 'manual' F2 key?

 

The idea is to throw a couple of prompt commands to report results in the text window but it seems I cant find something to call and open this window out of an Autolisp routine.

 

Anyone knows?

Link to comment
Share on other sites

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • Deby Ferdian

    12

  • Lee Mac

    7

  • MJLM

    3

  • guigonse

    3

Why not try an (Alert "message") box

 

cause the data returned are too many, you need to scroll to review all.

Link to comment
Share on other sites

  • 1 year later...

How to make both of them (toggle function as textscr hide/show) in full LISP? I try with this sample that I get this example from somewhere when I'm browsing..

 

 

(defun c:TS ()
(if (dos_istextscr)
(graphscr)
(textscr)))



(defun c:TW ()
(if (zerop (getvar "opmstate"))
(command "textscr")
(command "graphscr")
)
(princ)
)

Link to comment
Share on other sites

Try the following:

(defun-q c:ts nil
   (graphscr)
   (setq c:ts (vl-list* '() (if (equal '(graphscr) (cadr c:ts)) '(textscr) '(graphscr)) (cddr c:ts)))
   (princ)
)

Link to comment
Share on other sites

Hi, How to we including the "AI_DESELECT" to that code after graphscr done ?

 

Try the following:

(defun-q c:ts nil
   (progn (graphscr) (sssetfirst nil nil))
   (setq c:ts (vl-list* '() (if (equal '(textscr) (cadr c:ts)) '(progn (graphscr) (sssetfirst nil nil)) '(textscr)) (cddr c:ts)))
   (princ)
)

Link to comment
Share on other sites

How about for this code, I forgot where is I got this LISP code from.. ???

But All I know is this LISP code for a function to look a properties from the object we are select, looking this:

 

(defun c:Q ()
(if (zerop (getvar "opmstate"))
(command ".properties")
(command ".propertiesclose")
)
(princ)
)

And How to put the "AI_DESELECT" this on into the above the code I write ?

Edited by Deby Ferdian
Fix first line!
Link to comment
Share on other sites

Wow.. It's so fast response @Lee Mac! It's fully really helfully really.. But nobody to good response me on my another thread. If you mind, would you ???

 

See on this link at the same forum;

http://www.cadtutor.net/forum/showthread.php?96188-Create-a-LISP-as-a-function-for-Section-Plan-gt-View-to-the-section-gt-UCS-to-the-current&p=657622

http://www.cadtutor.net/forum/showthread.php?96183-Instead-of-quot-ESC-quot-Buttion!&p=657602

Edited by Deby Ferdian
Insert Awesome word!
Link to comment
Share on other sites

How about to change "graphscr" with a something like we send a key to it "% h" (alt+h to hide a textscr). is this possible????

Link to comment
Share on other sites

How about to change "graphscr" with a something like we send a key to it "% h" (alt+h to hide a textscr). is this possible????

 

Perhaps something like this:

(defun-q c:ts nil
   (graphscr-action)
   (setq c:ts (vl-list* '() (if (equal '(textscr) (cadr c:ts)) '(graphscr-action) '(textscr)) (cddr c:ts)))
   (princ)
)
(defun graphscr-action nil
   (if (= :vlax-true (LM:appactivate "AutoCAD Text Window"))
       (LM:sendkeys "%(H){ESC}{ESC}")
   )
   (sssetfirst nil nil)
)

;; App Activate  -  Lee Mac
;; A wrapper for the appactivate method of the WSH
;; str - [str] Application title or Process ID

(defun LM:appactivate ( str / rtn wsh )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (setq rtn (vl-catch-all-apply 'vlax-invoke-method (list wsh 'appactivate str)))
           (vlax-release-object wsh)
           (if (vl-catch-all-error-p rtn)
               (prompt (vl-catch-all-error-message rtn))
               rtn
           )
       )
   )
)

;; Send Keys  -  Lee Mac
;; A wrapper function for the SendKeys method of the WSH
;; Reference: http://msdn.microsoft.com/en-us/library/8c6yea83%28v=vs.85%29.aspx

(defun LM:sendkeys ( str / wsh rtn )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (setq rtn (vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys str)))
           (vlax-release-object wsh)
           rtn
       )
   )
)

(vl-load-com) (princ)

Link to comment
Share on other sites

Hi, @Lee Mac the code actually does not work at all, in fact what happens is hiding and showing the palettes(autocad) and start menu windows(the left corner of taskbar)! While intended only hiding behind the windows of AutoCAD. I have look at a similar code and it seems also posted by you look at this;

 

(defun _graphscr ( / wsh )
   (setq wsh (vlax-create-object "WScript.Shell"))
   (vlax-invoke wsh 'appactivate
       (strcat "AutoCAD Text Window - "
           (if (eq (getenv "ShowFullPathInTitle") "1")
               (getvar 'DWGPREFIX)
               ""
           )
           (getvar 'DWGNAME)
       )
   )
   (vlax-invoke wsh 'sendkeys "% H")
   (vlax-release-object wsh)
   (princ)
)


(defun c:CTW ( / wsh )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (textscr)
           (vl-catch-all-apply
              '(lambda ( )
                   (vlax-invoke wsh 'appactivate "AutoCAD Text Window")
                   (vlax-invoke wsh 'sendkeys "% H")
               )
           )
           (vlax-release-object wsh)
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

 

and they was same, they were just hiding and showing the palettes and start menu windows!

Do you have an any idea? or is it supposed be changed first by me before I running it of all. Right???

Edited by Deby Ferdian
There are so a lot of miss words!
Link to comment
Share on other sites

Of mine is AutoCAD 2013 x64, version of G.55.0.0, I'm not sure about the language. It might besure my region is Indonesia so it will be corresponding to my country too. Right???

Edited by Deby Ferdian
Just make a bold to several word of my written!
Link to comment
Share on other sites

Of mine is AutoCAD 2013 x64, version of G.55.0.0, I'm not sure about the language. It might besure my region is Indonesia so it will be corresponding to my country too. Right???

 

Essentially, what is the caption of your text window?

 

For English versions, this is:

 

AutoCAD Text Window

 

The above posted code relies on using this caption to identify the appropriate window to activate (using the appactivate method) before issuing the Alt+H keystroke (using the sendkeys method).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...