TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: laison on July 19, 2009, 06:55:30 AM

Title: Macro for Notepad in Autocad
Post by: laison on July 19, 2009, 06:55:30 AM
I have been searching a macro that would launch notepad in AutoCad. I ran across this below. It brings up another window. If there is any other macros that would launch notepad can you post it.
 
Thank you
 
^C^Cshell;notepad;

Title: Re: Macro for Notepad in Autocad
Post by: CAB on July 19, 2009, 08:15:30 AM
Have you tried:
Code: [Select]
(startapp "notepad" "File Name")
Title: Re: Macro for Notepad in Autocad
Post by: VVA on July 20, 2009, 08:59:23 AM
and
Autocad is waiting for the completion of the program (notepad.exe)
Code: [Select]
;;Variant 1
;;Autocad is waiting for the completion of the program (notepad.exe)
(setq file-name "C:\\TEST.TXT")
(vl-load-com)
(vlax-invoke-method
    (setq ws (vlax-get-or-create-object "wscript.shell"))
    "run"
    (strcat "notepad.exe\ " file-name)
    1
    [color=red]:vlax-true[/color]
) ;_ end of vlax-invoke-method
(vlax-release-object ws)

;;Variant 2
;;Autocad isn't waiting for the completion of the program (notepad.exe)
(setq file-name "C:\\TEST.TXT")
(vl-load-com)
(vlax-invoke-method
    (setq ws (vlax-get-or-create-object "wscript.shell"))
    "run"
    (strcat "notepad.exe\ " file-name)
    1
[color=red]    :vlax-false[/color]
) ;_ end of vlax-invoke-method
(vlax-release-object ws)
Title: Re: Macro for Notepad in Autocad
Post by: Patrick_35 on July 21, 2009, 07:46:55 AM
Hi

An another ;)

Code: [Select]
(defun xopen(name / di na sh)
  (and (setq name (findfile name))
(setq sh (vlax-create-object "Shell.Application"))
(setq di (vlax-invoke sh 'Namespace (vl-filename-directory name)))
(setq na (vlax-invoke di 'parsename (strcat (vl-filename-base name) (vl-filename-extension name))))
(vlax-invoke-method na 'invokeverbex "open")
  )
  (vlax-release-object sh)
  na
)

Code: [Select]
(setq my_file (xopen "c:/test.txt"))
or
(setq my_file (xopen c:/test.avi"))

@+