.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Active Document - eNotFromTh isDocument error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello Forum,
the following code gives me an eNotFromThisDocument error:
[LispFunction("MyFunction")]
public ResultBuffer MyFunction(ResultBuffer rbParameter)
{
...
objDocument = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.Open(strPath, false);
if (!objDocument.IsReadOnly)
{
using (objDocumentLock = objDocument.LockDocument())
{
Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument = objDocument;
objDocument.Database.TileMode = true; // = eNotFromThisDocument.
}
objDocument.CloseAndSave(strPath);
objDocument.Dispose();
}
...
}I think it is because the Editor does not get linked to the newly opened drawing. In other words, I can not change tilemode of objDocument, because the drawing from which I called this function is still the active/current drawing. How can I tell AutoCAD that objDocument should be the active/current drawing, so I can change the tilemode, and use Editor functionality, such as SendString()?
Thank you.
Solved! Go to Solution.
Re: Active Document - eNotFromTh isDocument error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
as a guess: in LISP you get lost if the document changed as LISP-code it runs document-based. If you start a LISP in A.DWG you can start to load B.DWG but the lisp-code will not continue in B.DWG.
That you load a drawing and make the this other drawing active within a LISP-function may be the source of the problem.
- alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Active Document - eNotFromTh isDocument error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
See if this works for yoy, tested on A2010
<code>
[LispFunction("MyFunction")]
public ResultBuffer MyFunction(ResultBuffer rbParameter)
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
string strPath = .....;
using (DocumentLock objDocumentLock = doc.LockDocument())
{
Document objDocument = Autodesk.AutoCAD.ApplicationServices.Application.D
if (!objDocument.IsReadOnly)
{
using (DocumentLock pDocumentLock = objDocument.LockDocument())
{
Database pdb = HostApplicationServices.WorkingDatabase;
if (pdb.TileMode == true)
pdb.TileMode = false;
//Autodesk.AutoCAD.ApplicationServices.Application
}
objDocument.CloseAndSave(strPath);
objDocument.Dispose();
}
}
return new ResultBuffer(new TypedValue((int)LispDataType.Nil));
}
</code>
C6309D9E0751D165D0934D0621DFF27919
Re: Active Document - eNotFromTh isDocument error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

