Hi,
I recently converted a vb.net program that extracts attribute data to work with ACAD2013. The program runs but is very slow It takes a full 10 minutes to read 120 small dwg files. The same program running in ACAD2010 takes about 3 seconds. Has anyone else run into this?
Thanks in Advance
G.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by GeeHaa. Go to Solution.
can you send us some sample code please? I'd like to test it for you to see where the problem is.
For x As Integer = 0 To UBound(listOfFiles) Dim layoutStrings() As String = Nothing Dim acCurDB As New Database(False, True) acCurDB.ReadDwgFile(listOfFiles(x), FileOpenMode.OpenForReadAndReadShare, True, "") Using acTrans As Transaction = acCurDB.TransactionManager.StartTransaction Dim acLayoutMgr As LayoutManager acLayoutMgr = LayoutManager.Current Dim layoutdict As DBDictionary = acTrans.GetObject(acCurDB.LayoutDictionaryId, OpenMode.ForRead) ReDim layoutStrings(layoutdict.Count - 2) For Each Ent As DBDictionaryEntry In layoutdict Dim desc_Txt As String = "" Dim lay As Layout = acTrans.GetObject(Ent.Value, OpenMode.ForRead) Dim layBTRId As ObjectId = lay.BlockTableRecordId Dim btr As BlockTableRecord = TryCast(layBTRId.GetObject(OpenMode.ForRead), BlockTableRecord) If (Not lay.LayoutName = "Model") Then myWS.Cells(curRow, "D") = File.GetLastWriteTime(listOfFiles(x)) For Each entId3 As ObjectId In btr Dim ent3 As Entity = entId3.GetObject(OpenMode.ForRead) Dim nextRow As Boolean = False If TypeOf ent3 Is DatabaseServices.BlockReference Then Dim bref As BlockReference = ent3 Dim atts As AttributeCollection = bref.AttributeCollection For Each attId As ObjectId In atts Dim AttRef As AttributeReference = attId.GetObject(OpenMode.ForRead) Select Case AttRef.Tag Case getTags(0) If Trim(AttRef.TextString) <> "" Then myWS.Cells(curRow, "A") = AttRef.TextString myWS.Cells(curRow, "J") = fixDwgName(AttRef.TextString) myWS.Cells(curRow, "G") = ListOfNames(x) End If Case getTags(1) If Trim(AttRef.TextString) <> "" Then myWS.Cells(curRow, "C") = Trim(AttRef.TextString) End If Case getTags(2) If Trim(AttRef.TextString) <> "" Then myWS.Cells(curRow, "E") = Trim(AttRef.TextString) End If Case getTags(3) If Trim(AttRef.TextString) <> "" Then myWS.Cells(curRow, "F") = Trim(AttRef.TextString) End If End Select Next attId Dim tempstr As String = "" For x2 As Integer = 4 To getTags.Count - 1 For Each attId As ObjectId In atts Dim AttRef As AttributeReference = attId.GetObject(OpenMode.ForRead) If AttRef.Tag = getTags(x2) Then tempstr = tempstr + AttRef.TextString + " " End If Next attId Next If (Not Trim(tempstr) = "") Then myWS.Cells(curRow, "B") = Trim(tempstr) End If If nextRow = True Then curRow += 1 End If End If 'End If 'invp Next entId3 curRow += 1 End If 'MsgBox("layoutname = " + lay.LayoutName) Next acTrans.Dispose() End Using acCurDB.CloseInput(True) Next
Here it is Some of it. I hope it's all you need.
Thanks Very Much
remove closeInput and also try changing the open mode to just read (no sharing)
Try commiting your transaction instead of disposing it which will call Abort
http://www.theswamp.org/index.php?topic=44037.msg493005#msg493005
Removing CloseInput helped. Still Not as fast as 2010 and it crashes at about 1600 drawings always on a different drawing though. Is anything else wrong that you can see? I also committed the Transaction instead of disposing it
Thanks Again
make sure you set the workingDatabase. Also, if you are not writing anything I recommend you use StartOpenCloseTransaction instead of StartTransaction
I added your recommendations but it still crashes with the following error at around 1600 drawings out of 2100.
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Acdbmgd
StackTrace:
at Autodesk.AutoCAD.Runtime.RXObject.DeleteUnmanagedObject()
at Autodesk.AutoCAD.Runtime.DisposableWrapper.!DisposableWrapper()
at Autodesk.AutoCAD.Runtime.DisposableWrapper.Dispose(Boolean )
InnerException:
Thanks
Hi,
You do not need to explicitly dispose your transaction as you're using a 'Using' block.
You might dispose the side Database too.
Using acCurDB As New Database(False, True) acCurDB.ReadDwgFile(listOfFiles(x), FileOpenMode.OpenForReadAndReadShare, True, "") Using acTrans As Transaction = acCurDB.TransactionManager.StartTransaction ' ... End Using End Using
Disposing of the side database worked. AS far as speed goes I was running the program in Debug Mode. The release version is as fast as 2010 if not faster.
Thanks Again
Can't find what you're looking for? Ask the community or share your knowledge.