.NET

Reply
*Mark Johnston
Message 1 of 12 (607 Views)

DatabaseServices ReadDwgFile

607 Views, 11 Replies
06-15-2006 09:45 AM
I am trying to open a drawing file without opening AutoCAD.
I do have AutoCAD properly installed on the computer.

I understood from a post here that the DatabaseServices library to do this.

I added a reference to acdbmgd.dll.

I tried this:
// declaration
using Autodesk.AutoCAD.DatabaseServices;

// in my procedure
Database thisdrawing = new Database(false, true);
thisdrawing.ReadDwgFile(@"C:\1114-12.dwg", System.IO.FileShare.None, false,
null);
System.Windows.Forms.MessageBox.Show(thisdrawing.Filename);

---
I get this error.

System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."
Source="acdbmgd"
StackTrace:
at AcDbDatabase.{ctor}(AcDbDatabase* , Boolean , Boolean )
at Autodesk.AutoCAD.DatabaseServices.Database..ctor(Boolean
buildDefaultDrawing, Boolean noDocument)

Can anybody help me along?
*Stuart Nathan
Message 2 of 12 (607 Views)

Re: DatabaseServices ReadDwgFile

06-15-2006 12:31 PM in reply to: *Mark Johnston
I didn't know you could
*Mark Johnston
Message 3 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-15-2006 01:12 PM in reply to: *Mark Johnston
I read it in this post.
I hope Mr. Jones doesn't mind my copying it here. I could figure out how to
add a link to his actual post.

---QUOTE---
//Create a database
Database tempDb = new Database(true, false);


//Get a database from a file :-)
public Database GetDatabaseFromFile(string fileName)
{
Database databaseFromFile = new Database(false, true);
databaseFromFile.ReadDwgFile(fileName, System.IO.FileShare.None, false,
null);
return databaseFromFile;
}

Remember that you must Dispose of any database that you create when you are
done with it.
--
Bobby C. Jones
---END QUOTE---


"Stuart Nathan" wrote in message
news:5207994@discussion.autodesk.com...
I didn't know you could
*Ed Jobe
Message 4 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-15-2006 01:31 PM in reply to: *Mark Johnston
"I could figure out how to add a link to his actual post."

Go to the web version, copy the url, and paste it into your post.

--
----
Ed
----
*CB
Message 5 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-15-2006 06:00 PM in reply to: *Mark Johnston
So you can or can't. Where you able to access the drawing? Can .net be
used to create a third party app (outside of autocad namespace) while the
drawing is open on or off screen?
--
CB


"Stuart Nathan" wrote in message
news:5207994@discussion.autodesk.com...
I didn't know you could
Contributor
Mick Duprez
Posts: 14
Registered: ‎11-19-2005
Message 6 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-15-2006 06:16 PM in reply to: *Mark Johnston
You can only use the managed wrappers from 'inside' autocad (the same as arx) ie. a dll loaded into acad at runtime. If you want to do this without AutoCAD you will have to use the COM/dbx interface.
Cheers,
Mick.
*CB
Message 7 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-16-2006 06:04 AM in reply to: *Mark Johnston
Can you access the com object model through .net? Ultimately I am trying to
figure out if it is possible to program an interface in .net that mimics
Eagle point software. I want to be able to open the app outside of AutoCAD
and manipulate the currently opened drawing. I understand that you will
need realDWG if autocad is not going to be loaded.... but if autocad is on
the client machine will .net have the ability to silently open or use the
currently open dwg and perform some drawing manipulation. I have done this
with dbx and VB6 but I have decided to switch to c# and I am finding it
difficult to get an answer to this question. I am still very new to .net
and was wondering if it is possible without spending time hacking away at
the object model for myself.
Thanks
--
CB




wrote in message news:5208394@discussion.autodesk.com...
You can only use the managed wrappers from 'inside' autocad (the same as
arx) ie. a dll loaded into acad at runtime. If you want to do this without
AutoCAD you will have to use the COM/dbx interface.
Cheers,
Mick.
*J. Daniel Smith
Message 8 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-16-2006 06:56 AM in reply to: *Mark Johnston
Yes, .NET interacts very well with COM. Depending on the particulars of the
COM API (Office, for example), VB.NET may be a little easier than C#.

The AutoCAD COM automatation API is completely different from the managed
wrappers, even though you can use either one from the same .NET language.
The .NET wrappers can only be used in one of two situtations: 1) in-process
with AutoCAD, loading a "managed ARX", or 2) (uncommon) out-of-process in
conjunction with RealDWG (aka ObjectDBX).

Dan

"CB" wrote in message
news:5208748@discussion.autodesk.com...
Can you access the com object model through .net? Ultimately I am trying to
figure out if it is possible to program an interface in .net that mimics
Eagle point software. I want to be able to open the app outside of AutoCAD
and manipulate the currently opened drawing. I understand that you will
need realDWG if autocad is not going to be loaded.... but if autocad is on
the client machine will .net have the ability to silently open or use the
currently open dwg and perform some drawing manipulation. I have done this
with dbx and VB6 but I have decided to switch to c# and I am finding it
difficult to get an answer to this question. I am still very new to .net
and was wondering if it is possible without spending time hacking away at
the object model for myself.
Thanks
--
CB




wrote in message news:5208394@discussion.autodesk.com...
You can only use the managed wrappers from 'inside' autocad (the same as
arx) ie. a dll loaded into acad at runtime. If you want to do this without
AutoCAD you will have to use the COM/dbx interface.
Cheers,
Mick.
*CB
Message 9 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-16-2006 07:56 AM in reply to: *Mark Johnston
Thanks. I guess I will have to use the limitations of the com object model
for out-of-process programming with AutoCAD if I do not want to go through
any hassle of obtaining a realdwg license.

You are right on about vb.net being easier coming from a background in VB.
I was able to pickup vb.net fairly fast but I like the code structure with
c#.
Thanks again
--
CB





"J. Daniel Smith" wrote in message
news:5208851@discussion.autodesk.com...
Yes, .NET interacts very well with COM. Depending on the particulars of the
COM API (Office, for example), VB.NET may be a little easier than C#.

The AutoCAD COM automatation API is completely different from the managed
wrappers, even though you can use either one from the same .NET language.
The .NET wrappers can only be used in one of two situtations: 1) in-process
with AutoCAD, loading a "managed ARX", or 2) (uncommon) out-of-process in
conjunction with RealDWG (aka ObjectDBX).

Dan

"CB" wrote in message
news:5208748@discussion.autodesk.com...
Can you access the com object model through .net? Ultimately I am trying to
figure out if it is possible to program an interface in .net that mimics
Eagle point software. I want to be able to open the app outside of AutoCAD
and manipulate the currently opened drawing. I understand that you will
need realDWG if autocad is not going to be loaded.... but if autocad is on
the client machine will .net have the ability to silently open or use the
currently open dwg and perform some drawing manipulation. I have done this
with dbx and VB6 but I have decided to switch to c# and I am finding it
difficult to get an answer to this question. I am still very new to .net
and was wondering if it is possible without spending time hacking away at
the object model for myself.
Thanks
--
CB




wrote in message news:5208394@discussion.autodesk.com...
You can only use the managed wrappers from 'inside' autocad (the same as
arx) ie. a dll loaded into acad at runtime. If you want to do this without
AutoCAD you will have to use the COM/dbx interface.
Cheers,
Mick.
*Mark Johnston
Message 10 of 12 (608 Views)

Re: DatabaseServices ReadDwgFile

06-16-2006 08:49 AM in reply to: *Mark Johnston
So could I create an app that uses the managed wrappers to:
1. Start the AutoCAD application (hopefully without displaying it)
2. Use DatabaseServices to quickly read a drawing without displaying it
3. Close AutoCAD

Our AutoCAD users only use the program for about 50% of the workday but they
want access to the data in the drawings at any given time. Starting the
AutoCAD editor just to read a piece of data out of a drawing seems like a
tremendous waste of time and resources.

ObjectDBX did this for us in the past but the ability to do that has been
removed with more current versions. I don't understand that. I understand
promoting RealDWG for those that want to work with drawing files WITHOUT
having AutoCAD. That is a great idea. Why though, should I have to pay for
RealDWG when I have already paid for full-blown AutoCAD?

(sorry for the rant, they took away one of my favorite toys)

"J. Daniel Smith" wrote in message
news:5208851@discussion.autodesk.com...
Yes, .NET interacts very well with COM. Depending on the particulars of the
COM API (Office, for example), VB.NET may be a little easier than C#.

The AutoCAD COM automatation API is completely different from the managed
wrappers, even though you can use either one from the same .NET language.
The .NET wrappers can only be used in one of two situtations: 1) in-process
with AutoCAD, loading a "managed ARX", or 2) (uncommon) out-of-process in
conjunction with RealDWG (aka ObjectDBX).

Dan

"CB" wrote in message
news:5208748@discussion.autodesk.com...
Can you access the com object model through .net? Ultimately I am trying to
figure out if it is possible to program an interface in .net that mimics
Eagle point software. I want to be able to open the app outside of AutoCAD
and manipulate the currently opened drawing. I understand that you will
need realDWG if autocad is not going to be loaded.... but if autocad is on
the client machine will .net have the ability to silently open or use the
currently open dwg and perform some drawing manipulation. I have done this
with dbx and VB6 but I have decided to switch to c# and I am finding it
difficult to get an answer to this question. I am still very new to .net
and was wondering if it is possible without spending time hacking away at
the object model for myself.
Thanks
--
CB




wrote in message news:5208394@discussion.autodesk.com...
You can only use the managed wrappers from 'inside' autocad (the same as
arx) ie. a dll loaded into acad at runtime. If you want to do this without
AutoCAD you will have to use the COM/dbx interface.
Cheers,
Mick.
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!