I obtained this from CadDesk magazine..
But this routine utilises a global variable that contains the file name that you
want to open. It may be of interest to you...
^C^C^P(setq pmv:tmp (findfile "ACAD.PGP"))(startapp
"C:/windows/notepad.exe"
pmv:tmp)(princ)
Also I have inserted the following that
enables Autocad to open up other drawings. R2000 is a little different to R14.
Again it might interest
you....
;;;----------------CODING STARTS
HERE---------------------------
;;; ( GEN:OpenDwgFile filename bit )
;;; Function discerns which Acad version and applies appropriate command.
;;; Bit controls as follows
;;; 0 = Open file if Acad2000 or separate session if Acad14
;;; 1 = Open file - Don't save current drawing
;;; 2 = Open file - Save current drawing.
( defun GEN:OpenDwgFile ( filenm bit / cmd
f )
;;; local functions
( defun OpenDwgFileR15 ( f / cmd )
; string together the cmd expression and send to VBASTMT e.g.
; ( command "vbastmt" "AcadApplication.Documents.Open
\"x:/ADG/templates/ControlledSurveys.dwt\"")
( setq cmd ( strcat "AcadApplication.Documents.Open \"" f
"\"" ))
( command "vbastmt" cmd )
) ; local defun
( defun OpenDwgFileR14 ( f bit / cmd )
( command "pan" "0.0,1.0,0.0" "0.0,0.0,0.0" ) ;
force prompt
( if ( = bit 1 )
( command "_.open" "n" f ) ; save changes
( command "_.open" "y" f ) ; don't save changes
)
) ; local defun
( defun OpenDwgFile>0 ( f )
( alert "When using this file either SAVEAS and edit file \n OR
\nCUT and PASTE but don't overwrite original." )
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn
( setvar "SDI" 0 ) ; turn on multiple document interface
( OpenDwgFileR15 f ) ; if R2000 open dwg otherwise start separate
session of Acad.
); progn
( startapp "acad.exe" f)
)
); local defun
( defun OpenDwgFile>1 ( filenm / f ) ; don't save changes
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn ( OpenDwgFileR15 filenm ));progn
( OpenDwgFileR14 filenm 0 )
)
); local defun
( defun OpenDwgFile>2 ( filenm / f ) ;save changes
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn ( OpenDwgFileR15 filenm ));progn
( OpenDwgFileR14 filenm 1 )
)
); local defun
; main function
( if ( setq f ( findfile filenm )) ; locate file
( progn
( cond
(( = bit 0 )( OpenDwgFile>0 f )); access another drawing
(( = bit 1 )( OpenDwgFile>1 f )); don't save changes
(( = bit 2 )( OpenDwgFile>2 f )); save changes
);cond
);progn
( alert ( strcat "AutoCad cannot find " filenm ))
)
) ; defun
;;;----------------CODING ENDS
HERE---------------------------
Kind regards
Paul Matthews.
|