Parallel read from .NET

Parallel read from .NET

Anonymous
Not applicable
2,480 Views
10 Replies
Message 1 of 11

Parallel read from .NET

Anonymous
Not applicable
How do I read all objects in modelspace using parallel.foreach() in .NET? I use Visual Basic .NET, but a C# answer is ok. I tried some methods, but the code hangs, and it may be that Autocad needs some specific way to read the objects in parallel, so that's why I ask. I do not need to make any modifications to modelspace objects. Just read their properties (like cordinates and layer names objects names). I have an autocad 2013 file with hundred of thousands of objects in modelspace, and I need to find all polylines from a specific layer, to get their coordinates. A single threaded code works, but is unbearably slow, and I have many processors idling, so I want to use parallel code.
0 Likes
Accepted solutions (1)
2,481 Views
10 Replies
Replies (10)
Message 2 of 11

dgorsman
Consultant
Consultant

There is no parallel processing in AutoCAD.  For better performance I would first suggest better data management ie. more drawings with fewer objects per drawing - that's better for both automation and users.  Maybe there is some loop optimization that can be done as well, but without knowing how you are looping over the model space objects its hard to tell.

----------------------------------
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.


Message 3 of 11

jabowabo
Mentor
Mentor
Accepted solution
As dgorsman states, it's hard to diagnose without seeing your code. From the example you give (finding polylines on a specific layer), it would be much faster to use selection filters rather than looping every object.
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-NET/files/GUI...
Message 4 of 11

Anonymous
Not applicable

That's so depressing. Multicore desktop processors are more than a decade old.

 

Autodesk released more than 10 versions of Autocad in between. Is time to get up to the times, Autodesk!

0 Likes
Message 5 of 11

Anonymous
Not applicable

Thanks Jabowabo. I will try this way.

0 Likes
Message 6 of 11

dgorsman
Consultant
Consultant

That would require changing the entire drawing database structure, as well as everything that interfaces with it.  Effectively that's a ground-up redesign of the entire program (short of the UI layer, anyways).  That's a huge investment for not much return, as most either don't have to deal with that much data and the few who do structure it in a more efficient manner.

 

That would also render all existing DWG files unreadable from the updated version and vice-versa.  That goes against one the strongest points of AutoCAD - the forward, (and to a certain extend, backwards) compatibility of DWG file content.

----------------------------------
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 7 of 11

kerry_w_brown
Advisor
Advisor

 

 
You may find that investing a little time in LINQ to access and mine into the database will be worth your while ...
 
particularly for something a simple as this  
 
[quote] ... 
I need to find all polylines from a specific layer ... [/quote]
 
 
Regards,
 
 
 
 
added:
 
 
 
 
 
 
or preferably, look for any of the AutoDesk AU lectures by Scott McFarlane.
 
 
 
 
 
 
 

// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 8 of 11

Anonymous
Not applicable

Tanks KerryBrown

0 Likes
Message 9 of 11

kerry_w_brown
Advisor
Advisor

 

You're welcome, and I appreciate the comment.

 

Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 10 of 11

Anonymous
Not applicable

@dgorsman

 

As a programmer, I understand. I had been there before.

 

Yet, it will need to be done soon or later. The code shouldn't depend on a specific implementation of a database.

 

Last processor I bought for my home (not work) was an i7-920. Is already an antique. I didn't updated because the faster desktop processor sold today is barely 30% faster per thread (i7-6950X). But it has 10 cores instead of 4.

 

The number of cores rises slowly, but much faster than single threaded performance.If Autocad does not embrace multicore, his performance will freeze in time.

0 Likes
Message 11 of 11

MGO-Norsyn
Advocate
Advocate

Hello from the future! Guess what? Autocad is still as it was back then! That is singlethreaded. And I guess it will stay that way untill it comes up against a much better competitor. Which isn't happening in foreseeable future.

The sad reality is that outdated, underperforming, loaded with technical debt, architecture is weighting down the WHOLE world, is using more electricity and hampering progress overall.

And Autodesk is not interested in changing this situation!

0 Likes