.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DatabaseServices ReadDwgFile

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
2258 Views, 11 Replies

DatabaseServices ReadDwgFile

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?
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

I didn't know you could
Message 3 of 12
Anonymous
in reply to: Anonymous

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
Message 4 of 12
Anonymous
in reply to: Anonymous

"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
----
Message 5 of 12
Anonymous
in reply to: Anonymous

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
Message 6 of 12
Mick Duprez
in reply to: Anonymous

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.
Message 7 of 12
Anonymous
in reply to: Anonymous

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.
Message 8 of 12
Anonymous
in reply to: Anonymous

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.
Message 9 of 12
Anonymous
in reply to: Anonymous

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.
Message 10 of 12
Anonymous
in reply to: Anonymous

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.
Message 11 of 12
Anonymous
in reply to: Anonymous

From my understanding now.... is that you can still do what you have done
before through the com object (i guess that is what I was trying to get
clarified before I continue learning with .net). I would guess that I will
not be able to take advantage of some of the exposed functions in arx/.net
by using the dbx/com object but it will work for my purposes. Someone
please tell me if I am wrong before I continue further with .net and
autocad. I will stick it out with VB6 if I have to.

I fell the RealDWG license is unnessesary also. I think the dwg format
should have full *free* api (from autodesk) for manipulating the files and
reading the format. Too many people rely on the format for archiving and
storage. If there where no opensource sdks for jpeg and png writting then I
would bet money that most people would not store there photos with it. It
is an extra bit of security to have the ability to utilize a format without
contracts or licensing. I know the gif made allot of web designers nervous
before the patent term expired (to this day most open source software will
not write to it without adding the ability yourself).

I do not think that you have to pay for a RealDWG license.... last I checked
in 2005 (you may have to be part of the adn, which comes with a subscription
fee). Autodesk does want you to fill out paperwork and submit a business
plan/model for why and your plans with the technology. I personally would
not share my business plan with anyone other than to seek venture capitol
and prospective clients. Add to that the fact that my programming skills
with arx/.net is still in learning / personal utilities, and not production.
I figure there are allot of people in my same boat who would love to explore
the technology of RealDwg but will find it not worth the hassle. Plus to be
perfectly honest I would probably use the RealDWG technology create a better
drawing port to blender or gimp. Something that would probably not please
autodesk..... and I would doubt getting a license.

The only alternative is the opened libraries but you have to pay for them.
You have to pay allot. I have always wondered if it was possible to use the
opened libraries by installing the software that uses it like intellicad. I
have never tried.

Good luck
--
CB




"Mark Johnston" wrote in message
news:5209079@discussion.autodesk.com...
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.
Message 12 of 12
Anonymous
in reply to: Anonymous

To correct the last post - opened should be openDWG.


"The only alternative is the opened libraries but you have to pay for them."

--
CB




"Mark Johnston" wrote in message
news:5209079@discussion.autodesk.com...
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost