.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Runtime.Exception on a SendStringToExecute in C# in Autocad 2009

3 REPLIES 3
Reply
Message 1 of 4
wperaud
2805 Views, 3 Replies

Runtime.Exception on a SendStringToExecute in C# in Autocad 2009

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
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: wperaud

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
Message 3 of 4
jan_tappenbeck
in reply to: Anonymous

hi !

 

it looks like i have the same Problem - but the link http://www.caddzone.com/CommandLine.vb is dead.

 

could anyone give the Information for this problem again?

 

regards Jan

Message 4 of 4
_gile
in reply to: jan_tappenbeck

Hi,

 

If I remenber well, CommandLine was a wrapper written by Tony "DiningPhilosopher" Tanzillo to P/Invoke the acedCmd() unmanaged method to be able to call AutoCAd commands synchronously.

This is obsolète since AutoCAD 2015 which brings the managed Editor.Command() method. For prior version, you shoud rather use another wrapper, also written by Tony, see this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost