.NET

Reply
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 1 of 8 (294 Views)
Accepted Solution

Getting autocad application details

294 Views, 7 Replies
05-16-2012 11:44 PM

Hi,

 

Could you please any one help me on below issue.

 

How i can retrieve the autocad application details like autocad file type like ( drawing file or dwt file) and file extension of active open autocad file using c#.

 

Regards,

Raman

Hi,

 

>> what is the application name. like "autocad drawing" file.

>> I think, you got my point.

Sorry, not any word, as I don't know how an application name could be "AutoCAD Drawing" or "AutoCAD Drawing File".

 

If you think about the caption of the application-window, then the property is called "Caption".

 

- alfred -

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 8 (291 Views)

Re: Getting autocad application details

05-17-2012 12:39 AM in reply to: RamanSBV

Check FileInfo property, e.g.:

        using System.IO;

...................................
        [CommandMethod("cfile")]
        public static void CheckExtension()
        {
            FileInfo fi = new FileInfo(@"C:\Test\MyFile.dwg");
            if (fi.Exists)
            {
                MessageBox.Show(fi.Extension);
            }
        }

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 3 of 8 (289 Views)

Re: Getting autocad application details

05-17-2012 12:45 AM in reply to: RamanSBV

 

yes, in this way we can get the file info.

 

But I need to get the autocad active file details , like type (dwg or dwt) of the autocad file either it is saved or not. and application name like (Autocad drawing file) or (Autocad template file)

 

using autocad APIs

 

Regards,

Raman

*Expert Elite*
Alfred.NESWADBA
Posts: 9,378
Registered: ‎06-29-2007
Message 4 of 8 (277 Views)

Re: Getting autocad application details

05-17-2012 05:51 AM in reply to: RamanSBV

Hi,

 

>> I need to get the autocad active file details

You find all properties of the current open file under this object:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

There you have all "Document"-based infos and on hierarchie deeper:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database

you have all "Database"-relevant info (also .Filename for knowing about DWT or DWG)

 

Is there anything missing then?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 5 of 8 (252 Views)

Re: Getting autocad application details

05-17-2012 10:12 PM in reply to: Alfred.NESWADBA

 

 

Thanks for your post this issue.

 

But I am unable to get the details as you mentioned. Could you please help on this.

 

Regards,

Raman

*Expert Elite*
Alfred.NESWADBA
Posts: 9,378
Registered: ‎06-29-2007
Message 6 of 8 (247 Views)

Re: Getting autocad application details

05-17-2012 11:28 PM in reply to: RamanSBV

Hi,

 

>> But I am unable to get the details

At the moment I don't know what details you are looking for, what is "the details" for you? The only one you mentioned (I understood) is you want to know if a DWT or a DWG is opened.

For that check the extension (last three characters) of:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.FileName

 

If you need any other properties (and you don't find them by Intellisense under the two statements in my previous post) then let us know what properties (exactly) you look for.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 7 of 8 (246 Views)

Re: Getting autocad application details

05-17-2012 11:47 PM in reply to: Alfred.NESWADBA

 

Thanks for your quick reply...

 

 

Apart from this file type, i would like to know what is the application name. like "autocad drawing" file.

 

why I need this data from application is same addin is going to install in inventor and micro station.

So, i need to show application type.

 

I think, you got my point.

 

Regards,

Raman

 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,378
Registered: ‎06-29-2007
Message 8 of 8 (243 Views)

Re: Getting autocad application details

05-17-2012 11:57 PM in reply to: RamanSBV

Hi,

 

>> what is the application name. like "autocad drawing" file.

>> I think, you got my point.

Sorry, not any word, as I don't know how an application name could be "AutoCAD Drawing" or "AutoCAD Drawing File".

 

If you think about the caption of the application-window, then the property is called "Caption".

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!