.NET

Reply
Active Contributor
wperaud
Posts: 29
Registered: ‎03-31-2009
Message 1 of 24 (1,393 Views)

How to open DWG file in Autocad 2009 in C# ?

1393 Views, 23 Replies
06-12-2009 08:47 AM
Hello,

I'm developping a dll for Autocad 2009.

I would like to know, how to open a DWG file ?

I tried :
Database db = new Database();
db.ReadDwgFile(file.Path, FileOpenMode.OpenForReadAndAllShare, true, "");
---> does nothing

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context.

Thank you
*Joe Sutphin
Message 2 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 10:52 AM in reply to: wperaud

Here's how you would do it in VB - I'll leave it to
you to convert.

 

Joe ...

 


size=2>
 


size=2>Imports
oAcadApp =
Autodesk.AutoCAD.ApplicationServices.Application


oAcadApp.DocumentManager.Open(


color=#a31515 size=2>"C:\Drawing1.dwg"
,
color=#0000ff size=2>False

size=2>,

size=2>""
)



style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
Hello,
I'm developping a dll for Autocad 2009. I would like to know, how to open a
DWG file ? I tried : Database db = new Database(); db.ReadDwgFile(file.Path,
FileOpenMode.OpenForReadAndAllShare, true, ""); ---> does nothing
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context. Thank you
*Tony Tanzillo
Message 3 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 11:52 AM in reply to: wperaud
You can't open a drawing file from a command handler unless
you specify CommandFlags.Session in the CommandMethod
attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6200812@discussion.autodesk.com...
Hello, I'm developping a dll for Autocad 2009. I would like to know, how to
open a DWG file ? I tried : Database db = new Database();
db.ReadDwgFile(file.Path, FileOpenMode.OpenForReadAndAllShare, true,
""); ---> does nothing
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context. Thank you
*Tony Tanzillo
Message 4 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 11:52 AM in reply to: wperaud
{quote}

Joe Sutphin wrote:

Here's how you would do it in VB - I'll leave it to you to convert.

{quote}

He doesn't have to convert it, because what you posted is the
C# code from his original post, converted to VB.NET, exactly.

ROTFL

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
*Joe Sutphin
Message 5 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 12:58 PM in reply to: wperaud
You may have to do that in C# but not in VB.

Joe ...

"Tony Tanzillo" wrote in message
news:6201005@discussion.autodesk.com...
You can't open a drawing file from a command handler unless
you specify CommandFlags.Session in the CommandMethod
attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6200812@discussion.autodesk.com...
Hello, I'm developping a dll for Autocad 2009. I would like to know, how to
open a DWG file ? I tried : Database db = new Database();
db.ReadDwgFile(file.Path, FileOpenMode.OpenForReadAndAllShare, true,
""); ---> does nothing
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context. Thank you
*Joe Sutphin
Message 6 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 01:02 PM in reply to: wperaud
You must have seen yourself in the mirror - I'd be laughing too.

Joe ...


"Tony Tanzillo" wrote in message
news:6201006@discussion.autodesk.com...
{quote}

Joe Sutphin wrote:

Here's how you would do it in VB - I'll leave it to you to convert.

{quote}

He doesn't have to convert it, because what you posted is the
C# code from his original post, converted to VB.NET, exactly.

ROTFL

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
*Tony Tanzillo
Message 7 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 02:22 PM in reply to: wperaud
Wrong again, Bozo.

AutoCAD has no idea what langauge a .NET program was written in.

You're about as dumb as they get.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Joe Sutphin" wrote in message
news:6201060@discussion.autodesk.com...
You may have to do that in C# but not in VB.

Joe ...

"Tony Tanzillo" wrote in message
news:6201005@discussion.autodesk.com...
You can't open a drawing file from a command handler unless
you specify CommandFlags.Session in the CommandMethod
attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6200812@discussion.autodesk.com...
Hello, I'm developping a dll for Autocad 2009. I would like to know, how to
open a DWG file ? I tried : Database db = new Database();
db.ReadDwgFile(file.Path, FileOpenMode.OpenForReadAndAllShare, true,
""); ---> does nothing
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context. Thank you
*Tony Tanzillo
Message 8 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 02:33 PM in reply to: wperaud
What's wrong Joe, err... I mean 'steve', you don't like it
when someone points out just how helpless you actually are?

You don't know what you're doing, and everyone around
here knows it, so just give it up.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Joe Sutphin" wrote in message
news:6201061@discussion.autodesk.com...
You must have seen yourself in the mirror - I'd be laughing too.

Joe ...


"Tony Tanzillo" wrote in message
news:6201006@discussion.autodesk.com...
{quote}

Joe Sutphin wrote:

Here's how you would do it in VB - I'll leave it to you to convert.

{quote}

He doesn't have to convert it, because what you posted is the
C# code from his original post, converted to VB.NET, exactly.

ROTFL

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
*Joe Sutphin
Message 9 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 03:14 PM in reply to: wperaud
Obviously you're shooting off your mouth again without knowing what you're
talking about.

I run my code before I post it. Enough said?

It works just fine the way I posted. Once again you don't everything [or
even anything for that matter] especially when it comes to VB.


Joe ...


"Tony Tanzillo" wrote in message
news:6201116@discussion.autodesk.com...
Wrong again, Bozo.

AutoCAD has no idea what langauge a .NET program was written in.

You're about as dumb as they get.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Joe Sutphin" wrote in message
news:6201060@discussion.autodesk.com...
You may have to do that in C# but not in VB.

Joe ...

"Tony Tanzillo" wrote in message
news:6201005@discussion.autodesk.com...
You can't open a drawing file from a command handler unless
you specify CommandFlags.Session in the CommandMethod
attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6200812@discussion.autodesk.com...
Hello, I'm developping a dll for Autocad 2009. I would like to know, how to
open a DWG file ? I tried : Database db = new Database();
db.ReadDwgFile(file.Path, FileOpenMode.OpenForReadAndAllShare, true,
""); ---> does nothing
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(file.Path);
--> Error concerning Execution Context. Thank you
*Joe Sutphin
Message 10 of 24 (1,393 Views)

Re: How to open DWG file in Autocad 2009 in C# ?

06-12-2009 03:16 PM in reply to: wperaud
You lame ass moron - you're the one that does know what they're talking
about.

Guess it's time for you to get up off the floor and figure out what you did
wrong.

Joe ...


"Tony Tanzillo" wrote in message
news:6201120@discussion.autodesk.com...
What's wrong Joe, err... I mean 'steve', you don't like it
when someone points out just how helpless you actually are?

You don't know what you're doing, and everyone around
here knows it, so just give it up.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Joe Sutphin" wrote in message
news:6201061@discussion.autodesk.com...
You must have seen yourself in the mirror - I'd be laughing too.

Joe ...


"Tony Tanzillo" wrote in message
news:6201006@discussion.autodesk.com...
{quote}

Joe Sutphin wrote:

Here's how you would do it in VB - I'll leave it to you to convert.

{quote}

He doesn't have to convert it, because what you posted is the
C# code from his original post, converted to VB.NET, exactly.

ROTFL

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.