AutoCAD operations in background .NET

AutoCAD operations in background .NET

BestFriendCZ
Advocate Advocate
2,520 Views
7 Replies
Message 1 of 8

AutoCAD operations in background .NET

BestFriendCZ
Advocate
Advocate

Hi,

I'm here new and try to learn AutoCAD API.. In the past i programed lots of addons and macros for SolidWorks but in AutoCAD I'm totally beginner. ATM i have big .NET application which makes many operation in AutoCAD like scan blocks, update layouts, insert blocks, export to pdf etc.. and I would like to ask … Is there any opportunity how to make this operation in AutoCAD background? I mean without run directly AutoCAD or set AcadApp visible false:). Is there any library which can makes these functions? For example in SW was solidworks document manager library which modify SW data without open in SW.

thank you for your opinion

...
0 Likes
Accepted solutions (1)
2,521 Views
7 Replies
Replies (7)
Message 2 of 8

JamesMaeding
Advisor
Advisor

@BestFriendCZ

That need is common, and you have two choices.

You can open drawings, using an acad session, as "side databases", or called dbx documents...other names too.

It all means the same, you read the dwg into a .net database object, and you can scan and do many things that do not require selection or activities involving on screen picking as there is no screen for them. Its really fast and you can control if xrefs are "resolved" or not, meaning fully loaded.

It is what I use to catalog drawing properties, clean app ids, rename layer, so many things.

That needs a "mother" session to run with, but it does not open the drawings on screen, its all done in memory.

 

You can also buy "realdwg" license that runs without an acad session. Its not cheap, and you still have to have acad installed.

It just runs without even opening a session, and is also fast like side database.

There are many examples on this forum, search by "readdwgfile" as that is the method called.

 

Do not waste your time on "coreconcole" or script methods, they resolve xrefs so are way slower and not what you want.


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

0 Likes
Message 3 of 8

ActivistInvestor
Mentor
Mentor

In an AutoCAD session, all database-related operations must be done in the foreground, and cannot be run on background worker threads.

 

That has nothing to do with loading a DWG into a 'side database', because regardless of how its accessed, the operations must still be run in the foreground.

 

However, you can run another or several other instances of AutoCAD or the AutoCAD core console, each of which can perform 'unattended' operations in the foreground. 

 

 


@BestFriendCZ wrote:

Hi,

I'm here new and try to learn AutoCAD API.. In the past i programed lots of addons and macros for SolidWorks but in AutoCAD I'm totally beginner. ATM i have big .NET application which makes many operation in AutoCAD like scan blocks, update layouts, insert blocks, export to pdf etc.. and I would like to ask … Is there any opportunity how to make this operation in AutoCAD background? I mean without run directly AutoCAD or set AcadApp visible false:). Is there any library which can makes these functions? For example in SW was solidworks document manager library which modify SW data without open in SW.

thank you for your opinion


 

0 Likes
Message 4 of 8

JamesMaeding
Advisor
Advisor

Yes, but I think what I described fits what the OP is looking for.

It will indeed suck up a session, and it opens one drawing at a time.

I've thought about trying to use threads to open multiple drawings with one session, but never tried it.

In the end, I have found side database method perfectly suited to scanning drawings.

 

Recently an Autodesk person mentioned the idea of running multiple coreconsole tasks to speed up things like batching through drawings to explode AEC objects and other things.

@ActivistInvestor knows the speed you get with that, and its the same time as it takes to open the dwg in editor the classic way. That means between 5 and 10x slower.

I was disappointed the adesk person would even suggest using coreconsole for batching through hundreds of drawings.

The only reason he did was the style problem he wanted to fix would only heal by opening the drawing in civil3d, a terrible horribly slow solution.

So don't get sucked into that rabbit hole unless you must open the drawing in editor for your task to work.


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

0 Likes
Message 5 of 8

JamesMaeding
Advisor
Advisor

BTW, I did a free tool that uses the method I talked about, its at:

https://forums.autodesk.com/t5/autocad-civil-3d-forum/h-amp-a-file-cleaning-tool-free-and-attached/t...

 

You don't have to modify any files, it reads their properties and shows in the grid before you decide to purge or do anything.

Look at the dialog pic shot to see the dialog.

You can try it to get a feel for the speed as I have found most of the speed is limited by how fast the dwg reads in and saves (if saving).

The time to do something once the dwg is open has been negligible.

In other words, its so fast you can practically gather any info without slowing things down. I gather complete xref tree structures and layer states.

thx


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

0 Likes
Message 6 of 8

BestFriendCZ
Advocate
Advocate

Hi,

i really appreciate your opinion and thank you for sharing your experience with me. I am afraid of what is written here that i will have to work with the AutoCAD in the foreground. Because our application makes lost of operations like: scans current blocks, inserts new blocks to model, inserts new layouts, creates new drawing views, adds dimensions to drawing view, inserts various notes and etc...From these operations could run in the background only functions like scan blocks... if I understand it correctly.

I've been thinking about working with multiple instances of the AutoCAD for these purposes... but I'm worried about stability and i try to find the best / fastest solution 🙂 Today I also looked at AutoCAD core console...

...
0 Likes
Message 7 of 8

JamesMaeding
Advisor
Advisor
Accepted solution

@BestFriendCZ

You misunderstood.

You can and should do what you want using side database method.

 

@ActivistInvestor is just being specific about the fact that it does tie up a session, and its one at a time.

Your post kind of mixed two ideas so got responses on both, but don't be confused.

 

All experiences third party programmers try to use side-database style operations if possible, and go to great lengths to make it possible too.

We consider that part almost trivial. The whole reason we go to .net is its power and speed (both composing and at runtime) and to batch using old style open would be pointless unless forced to.

Your concern should be how to draw things using .net. By the time you know that, this question will seem obvious.


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

Message 8 of 8

BestFriendCZ
Advocate
Advocate

Hi,

ok thank you for explain... i will try it 😊

...
0 Likes