TheSwamp

Code Red => .NET => Topic started by: MickD on June 21, 2006, 11:36:59 PM

Title: Strange anomoly (?)
Post by: MickD on June 21, 2006, 11:36:59 PM
Have a look at this simple function to display the current drawing filename with path,

Code: [Select]
[CommandMethod("FILENAME")]
public static void TestFilename()
{
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
ed.WriteMessage("\nCurrent drawing is {0}:",db.Filename);
}

Works ok but leave your drawing for long enough for autosave to kick in and run it again.
On my machine it displays the name of the 'temp' save folder and drg name???

Is this normal behaviour? I ask as I want to use a file that is stored in the same folder as the current drg but if this can sometimes be the result it will not be good.
The only work around I can see is to save the file in code before getting its file name.

Any thoughts?
Title: Re: Strange anomoly (?)
Post by: Kerry on June 22, 2006, 12:34:44 AM
Mick,
Can you email to me a complete Project/solution on this with comments.
If I can duplicate it, I'll pass it on through the ADN system.

... looks like a weird one for sure !!
Title: Re: Strange anomoly (?)
Post by: MickD on June 22, 2006, 02:19:12 AM
A piccy of the anomoly -
Title: Re: Strange anomoly (?)
Post by: Glenn R on June 22, 2006, 02:37:56 AM
Mick,

Your database file name has changed but the DOCUMENT that's associated to the database hasn't.
A database does not necessarily have to have the same name as the document - you can have a database that's not associated with a document at all - remember ReadDwgFile?

Use either the file name property off the document or DWGPREFIX, DWGNAME and DWGTITLED sysvars.
Title: Re: Strange anomoly (?)
Post by: MickD on June 22, 2006, 03:08:02 AM
Thanks Glenn that makes perfect sense, will give it a shot now.
Title: Re: Strange anomoly (?)
Post by: Kerry on June 22, 2006, 03:57:12 AM
Great !