How to get layer data from a .dwg file without opening CAD by API of ObjectArx?

How to get layer data from a .dwg file without opening CAD by API of ObjectArx?

27925916
Advocate Advocate
6,117 Views
11 Replies
Message 1 of 12

How to get layer data from a .dwg file without opening CAD by API of ObjectArx?

27925916
Advocate
Advocate

Is it possible to get data of entities in layer from dwg without openning cad by API of ObejcetArx?

if not ,is there  any way to realize it except for RealDWG,

0 Likes
6,118 Views
11 Replies
Replies (11)
Message 2 of 12

27925916
Advocate
Advocate

I mean by .NET API..

0 Likes
Message 3 of 12

norman.yuan
Mentor
Mentor

"without opening CAD" is a pretty vague term about your real requirement. Does it mean not starting/running AutoCAD, or running AutoCAD, but not opening drawing file in AutoCAD EDITOR?

 

Well, since you said "I mean by .NET API", I assume you mean AutoCAD .NET API, thus, you MUST run AutoCAD (be it regular AutoCAD or AutoCAD's core console. Thus your question becomes: does the drawing has to be opened in AutoCAD? Technically, yes, If you run code with AutoCAD .NET API to access data in a drawing file, the drawing file MUST be open by AutoCAD, either fully opened in AutoCAD editor visibly, or opened as side database without showing the graphics in Editor. With your brief description, you could do:

 

1. Run AutoCAD;

2. Load your AutoCAD .NET API code

3. Execute your code, which read drawing file as side database and access layer information

 

Since AutoCAD does not have to process the drawing data for showing the graphics in AutoCAD Editor, reading data from side drawing database is a lot faster than doing the same work with drawing being opened visibly.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 12

JamesMaeding
Advisor
Advisor

You have to have a cad session open, and .net api is always run from within that session.

The C++ people can use "realdwg" to do this outside of a session, but you said .net, so....

 

You will be doing something like this to get the database object of a dwg:

try {

using (AcDb.Database db = new AcDb.Database(false, true)) {

db.ReadDwgFile(origDwg, FileOpenMode.OpenForReadAndAllShare, true, null); //FileOpenMode.OpenForReadAndAllShare

....

 

then things like this to dig through that db for info, in my case app id count:

 

try {

Transaction tr = db.TransactionManager.StartTransaction();

using (tr) {

//get app id count

RegAppTable regapptbl = (RegAppTable)tr.GetObject(db.RegAppTableId, OpenMode.ForRead);

int count = 0;

foreach (ObjectId id in regapptbl) { ++count; }

ParentInfo.ParAppIDCount = count;

 

you need to look up how to access layer info, as it will involve a different object than a regapptable, but the idea is the same.

Hopefully this gets you started, but the code you want is already on this forum, just look a bit more.

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 5 of 12

dgorsman
Consultant
Consultant

Last I heard, the RealDWG API can be used with C# as well as C++.  I don't have it so this is purely second-hand info...

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 6 of 12

ActivistInvestor
Mentor
Mentor
AcDbMgd.dll is the managed layer of RealDWG, and is used both within AutoCAD, and with other RealDWG host applications.
0 Likes
Message 7 of 12

JamesMaeding
Advisor
Advisor

so can you use realdwg in a c# app not run from an acad session?

 

I know that the access to the db is the same once the db is read in, but you cannot read it in outside of acad, right?

 

I care about this because I catalog dwg info and might buy the realdwg seat if it could run outside acad from c#.

thx


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 9 of 12

JamesMaeding
Advisor
Advisor

indeed, it does run from non acad c# app.

The price is too high considering we already have enough cad seats for our users.

It makes little sense that its not included with an acad purchase, as that costs more than the realdwg seats.

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 10 of 12

27925916
Advocate
Advocate

thanks a lot ,but I mean reading dwg without open cad, if it is impossible to use .NET API without openning cad, then whether there is any way to read infomation of dwg without opening cad except for realdwg

0 Likes
Message 11 of 12

27925916
Advocate
Advocate

someone suguest me to use DwgDirect,I don't know if it is ok and free

0 Likes
Message 12 of 12

dgorsman
Consultant
Consultant

@Anonymous wrote:

indeed, it does run from non acad c# app.

The price is too high considering we already have enough cad seats for our users.

It makes little sense that its not included with an acad purchase, as that costs more than the realdwg seats.

 


It does make sense, after a fashion.  With some modest programming you could purchase a single AutoCAD license and then deploy your application to all the users, rather than requiring a license for every AutoCAD user.  The intent of the RealDWG license is for third-party developers who require access to DWG content but aren't necessarily already in a "native" AutoCAD environment and therefore don't have AutoCAD licenses to work with.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes