Just noticed you're using the document transaction to work inside a side database. Use the side database's transaction
Also since in this case you aren't modifying the side database the call to close input is adding extra time.
Just noticed you're using the document transaction to work inside a side database. Use the side database's transaction
I don't know how to do that.
I tried creating the new side database before the transaction and use it for the transaction,
but when I try to use that side database in the loop, it throws an "eRepeatedDwgRead" exception and subsequent fatal error.
Is there a way to reset the new side database so I could use it more than once inside the loop?
The only other way I can think of, is to create the transaction within the loop after creating a new side database each time through the loop,
but then I'm back to creating a new transaction each time through the loop.
Or, could I use : Database db = HostApplicationServices.WorkingDatabase; for the transaction and make a new side database for the ReadDwgFile?
TIA
Just noticed you're using the document transaction to work inside a side database. Use the side database's transaction
I don't know how to do that.
I tried creating the new side database before the transaction and use it for the transaction,
but when I try to use that side database in the loop, it throws an "eRepeatedDwgRead" exception and subsequent fatal error.
Is there a way to reset the new side database so I could use it more than once inside the loop?
The only other way I can think of, is to create the transaction within the loop after creating a new side database each time through the loop,
but then I'm back to creating a new transaction each time through the loop.
Or, could I use : Database db = HostApplicationServices.WorkingDatabase; for the transaction and make a new side database for the ReadDwgFile?
TIA
A document can have a database a number of side databases associated with it.
If your just reading information from a file; then in the Database constructor the second parameter is if you want to associate a document with it, and I guess only reason is for undo mechanism. So passing true as second argument in Constructor new Database(false, true). You do not need to lock the document and might solve error.
Then use the database you ReadDwgFile into to start a transaction then do whatever looping required.
If your just reading information from a file; then in the Database constructor the second parameter is if you want to associate a document with it, and I guess only reason is for undo mechanism. So passing true as second argument in Constructor new Database(false, true). You do not need to lock the document and might solve error.
My two cents.
Why Lock the Document? You aren't doing anything with it.Code - C#: [Select]
using (document.LockDocument())
Why ToString()? Elements of array are already strings?Code - C#: [Select]
string str = filelist[i].ToString();
Why ToString()? Elements of array are already strings?Code - C#: [Select]
string str = filelist[i].ToString();
Ah, good catch. This was copied from the other block of search code, where I was reading the listBox.Items, which needed that cast.
I get pulled in a lot of different directions around here so it can take me a while to go over the code and catch all that stuff.
Thanks!
I know it costs alot of money ($250) but this is the kind of thing that ReSharper (http://www.jetbrains.com/resharper/?gclid=CjwKEAjw14mhBRC0vdSNkI2l7CASJAC8OFS0NLE1x7ArYZtcspyH8SvPQFeLfE4v3bO9O5qmcoNHVBoCnaPw_wcB) is really good at informing you of. Some of the best money i ever spent.
I have no problems using Database(false, true) constructor and the only time I have to lock the document when updating a side database is using
Database(false, false) from Application context.
So if Database(false, false) used from a modeless dialog or a command with CommandFlags.Session then I have to lock document.
From there I run the code for searching and replaceing text in drawings using a button click.And the short comment (again, I have not read whole tread) is that the multithreading is not working in autocad and will not be supported any time soon (as per Stephen Preston), so EVERYTHING you do in autocad must be in the same thread, and the only thing you can do the multithreaded way, is to extract data from dbobjects you need in the main tread, and move only that data in different thread, continue with main UI, and when finished, move results back. Now, this is easy in .NET 4.5, with Await, Asyinc .NET commands, but that is 4.5 is acad2015 only for now.
The search thread is supposed to run on another thread from a control so it doesn't lock up the UI.
The only reason I tried to run something on another thread,
was to keep the UI from "appearing to lock up" while a file search was going on.
Don't know if I accomplished running on a different thread
but by using the methods I found HERE: