- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We have an external tool that uses a pipe to communicate with AutoCAD
When I click something in that external tool, we get it to run a function in our AutoCAD plugin
However, when i try to run the ed.SendCommand() method, i get the "eInvalidInput" error
I know this error is related to not being in the document context, and is usually because the CommandFlags.Session has been set. But in my case, this isn't set (my method isn't even defined as an AutoCAD command), but I'm assuming that because of the way the function has been called, I'm in the application mode by default?
Ive tried Giles suggestion here, but that doesn't seem to bring me back into the document context
https://forums.autodesk.com/t5/net/switching-contexts/m-p/7328422/highlight/true#M54887
I would prefer to get this method working rather than use SendStringToExecute() if possible
Anything else I'm missing?
public static void PlaceBlock(string filepath, string blockName)
{
try
{
var doc = Application.DocumentManager.MdiActiveDocument;
Application.MainWindow.Focus();
using(doc.LockDocument())
{
var ed = doc.Editor;
ed.Command("-insert", @"C:\path\to\block\I_Furn_Misc_Pingpong.dwg");
}
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Solved! Go to Solution.