The way you're going about it is not reliable.
Define your own command using the CommandMethod
attribute. In your command method you can execute
AutoCAD commands synchronously using this code:
http://www.caddzone.com/CommandLine.cs
There is also a VB.NET version:
http://www.caddzone.com/CommandLine.vb
Then, when the document opens, use SendStringToExecute()
to run your CommandMethod, and have the code in it do the
work with the -XREF command.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message news:6402001@discussion.autodesk.com...
Hi,
I'm facing a problem when I want to Send a String to execute.
I want to modify XRefs when a file opens.
For each of a list of XRef to modify, I send a command thanks to the following
method :
Autodesk.AutoCAD.ApplicationServices.Document.SendStringToExecute(String
command, Boolean activate, Boolean wrapUpInactiveDoc, Boolean echoCommand)
Here is the command I send :
-XREF Path xrefName\n PathToTheFile\n
Most of the time, the command is successful, but sometimes, a error occurs :
Autodesk.AutoCAD.Runtime.Exception: eNoDocument
at Autodesk.AutoCAD.Runtime.Interop.ThrowExceptionForErrorStatus(Int32
errorStatus)
at Autodesk.AutoCAD.ApplicationServices.Document.SendStringToExecute(String
command, Boolean activate, Boolean wrapUpInactiveDoc, Boolean echoCommand)
My command works, when I run when I paste it in autocad.
I don't understand where this error comes from. Could someone help me please ?
Thank you in advance,
Wilhelm