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

Speed Up my command / function

2 REPLIES 2
Reply
Message 1 of 3
GrzesiekGP
366 Views, 2 Replies

Speed Up my command / function

Hello!

My function is very complicated. After enter command user must select objects. He select the whole drawing space. After that I'm do my job - storing specified blocks and curves into my collection, doing calculations and updating blocks.

 

Number of all elements that I'm modifying could raise to few thousands.

 

I've made some tests and (even that I'm removing objects from my collection while loop) function is faster at begin and slower at the end.

 

I thought I can do something like this:

 

if (counter = 100)

 transaction.Commit();

 

but I'm getting fatal error 😛

 

Maybe someone know a way to increase speed up, so I can clean memory while calculating selected objects in my function.

 

Thanks.

2 REPLIES 2
Message 2 of 3
StephenPreston
in reply to: GrzesiekGP

Its very hard to make suggestions on optimizing performance without seeing any code. If you're opening objects in a transaction to check their type is one you're interested in, then using ObjectId.ObjectClass to make the comparison could speed up processing a large drawing, and make sure you open an object for read to query it and ugradeopen when you decide to edit it, rather than opening everything fro write. You could also read through Fenton's ongoing series of blogs about API performance, starting here - http://adndevblog.typepad.com/autocad/2012/07/the-right-tools-for-the-job-autocad-part-1.html.

 

 

Cheers,

Stephen Preston
Autodesk Developer Network
Message 3 of 3

You weren't very descriptive, but I believe your fatal error is because you are trying to commit the transaction and then keep using it and commit it over and over again.  You can't do that.  Once a transaction has been committed, the only thing you can do with it is dispose it.

 

 

Dave O.                                                                  Sig-Logos32.png

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