Hallo Stefan
vieleicht hilft Dir das weiter. Zu finden unter http://www.autodesk.com/cgi-bin/external.pl?url=http://pointa.autodesk.com/gotoPointA.jsp?dest=cc
Opening a read-only DWG with AutoLISP and ActiveX
ID 53780
Applies to: AutoCAD
Date 6/6/2000
Question
How do I use AutoLISP to open a read-only drawing ? I've tried various
combinations of (command "OPEN" ..), but the OPEN command locks up when the
Read-Only Warning dialog displays and prompts for user input.
Answer
The solution to this depends on the document mode.
In SDI mode, setting the EXPERT system variable to 5.
In MDI mode, the easiest way to open a read-only drawing is to use the ActiveX
interface.
The following code demonstrates both approaches:
(defun OpenAReadOnlyDWG ()
(setq MDImode (getvar "SDI"))
(setq aDwgFile (findfile "Junk.Dwg"))
(if aDwgFile
(if (= MDImode 0)
(progn ; Multiple Document Mode
(vl-load-com)
(setq acadApplication (vlax-get-acad-object))
(setq acadDocuments (vla-Get-Documents acadApplication))
(vla-Open acadDocuments aDwgFile :vlax-True)
)
; in SDI mode it's not possible to use ActiveX
(progn
(setq oldexpert (getvar "EXPERT"))
(setvar "EXPERT" 5)
(command "OPEN" aDwgFile)
(if (> (getvar "CMDACTIVE") 0) (command "Y") )
(setvar "EXPERT" oldexpert)
)
)
(princ (strcat "\nDrawing File: " aDwgFile " was not found !"))
)
(princ)
)
Note that when SDI = 1, in the first release of AutoCAD 2000, there's a problem
that causes AutoCAD to abort when you try to run either a VBA macro, or an
ActiveX function from Lisp that attempts to open a drawing. The capability to
use the Open Method when SDI = 1, has been disabled in a later release.
Another way to open a readonly file would be by using a script, for instance
this accomplishes the same thing as the lisp code, but in SDI mode:
SDI
1
FILEDIA
0
CMDDIA
0
EXPERT
5
OPEN
JUNK
Y
FILEDIA
1
CMDDIA
1
EXPERT
0
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP