TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jaydee on November 20, 2013, 08:49:07 PM

Title: Help needed to make Acad command prompt active after LM:open
Post by: jaydee on November 20, 2013, 08:49:07 PM
Hi.
Need help and work around how to make Acad command promt active again.
Im using Lee Mac open routine http://www.lee-mac.com/open.html (http://www.lee-mac.com/open.html) to open window explorer folder after keyin to create pdf and
trying to get back to cad and continue keyins, the problem is after using LM:open to set the current drawing active, i still could not type anything in the command prompt line.
A short version of my routine below.
(defun c:PrPdf ()
 (setq currentdwg (strcat (getvar "dwgprefix")(getvar "dwgname")))
 (command "print" ........................)
 (LM:Open "C:\\PDF-FILES")
 (LM:Open currentdwg)
;;also using this but not working
(vla-activate (vla-item (vla-get-documents (vlax-get-acad-object)) (getvar "dwgname"))
)

I believe using (LM:Open currentdwg) should set the current drawing active, but its not or atlease the command prompt is not.

Running Acad2012

Thankyou




Title: Re: Help needed to make Acad command prompt active after LM:open
Post by: ribarm on November 21, 2013, 03:07:13 AM
Just a thought : Why would you open already open current drawing twicely?... Why just not set it active after you opened other DWG?
Title: Re: Help needed to make Acad command prompt active after LM:open
Post by: Lee Mac on November 21, 2013, 06:54:46 AM
You could try using the appactivate method of the Windows Script Host object (WSH) to switch focus to the AutoCAD application, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:prpdf ( )
  2.     ;(command "print" ........................)
  3.     (LM:open "C:\\PDF-FILES")
  4.     (LM:appactivate (vla-get-caption (vlax-get-acad-object)))
  5.     (princ)
  6. )
  7.  
  8. ;; App Activate  -  Lee Mac
  9. ;; A wrapper for the appactivate method of the WSH
  10. ;; str - [str] Application title or Process ID
  11.  
  12. (defun LM:appactivate ( str / rtn wsh )
  13.     (if (setq wsh (vlax-create-object "wscript.shell"))
  14.         (progn
  15.             (setq rtn (vl-catch-all-apply 'vlax-invoke-method (list wsh 'appactivate str)))
  16.             (vlax-release-object wsh)
  17.             (if (vl-catch-all-error-p rtn)
  18.                 (prompt (vl-catch-all-error-message rtn))
  19.                 rtn
  20.             )
  21.         )
  22.     )
  23. )
Title: Re: Help needed to make Acad command prompt active after LM:open
Post by: jaydee on November 21, 2013, 08:20:40 PM
Hi Marko
The great things about Lee's LM:open routine is it won't open an App/folder/drawing if its already opened, it just set it active i believe.
What I want to achieve is keyin commands print Pdf, LM:open a explorer folder where the pdf was printed to, than continues with more keyin commands. The issue is after LM:open a folder and the folder become active therefore I want to switch it back to current drawing where i could type on the command line without using the mouse clicking on the acad window or CTR+Tab to acad app to set it active. So offten Im using a series of Lisp commands and the LM:open interrupting the keyins of the current drawing.
Cheers
Title: Re: Help needed to make Acad command prompt active after LM:open
Post by: jaydee on November 21, 2013, 08:25:30 PM
Hi Lee.
thankyou for your help.
(LM:appactivate (vla-get-caption (vlax-get-acad-object)))
does not work for me, I did as suggested and no errors.
Title: Re: Help needed to make Acad command prompt active after LM:open
Post by: Lee Mac on November 22, 2013, 07:50:03 AM
Hi Lee.
thankyou for your help.
(LM:appactivate (vla-get-caption (vlax-get-acad-object)))
does not work for me, I did as suggested and no errors.

That's a shame - it was worth a shot  :|