ObjectID from Excel to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created some code to extract the information from an AutoCAD block and put it into a Excel Sheet. I am now working on the code to put the updated information back into the drawing.
One of the items I extracted out was the ObjectID using the code:
myXLWS.Cells(CurRow, 23) = myObjID.ToString
And it is stored in the excel sheet in this format:
(1943116255376) |
However, when I try to use this value and try to find this block, I get this error:
Here is the code for the reverse process.
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDB As DatabaseServices.Database
Dim myXLApp As Microsoft.Office.Interop.Excel.Application
Dim myXLWS As Microsoft.Office.Interop.Excel.Worksheet
myXLApp = GetObject(, "Excel.Application")
myXLWS = myXLApp.ActiveSheet
myDB = ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
myTransMan = myDB.TransactionManager
myTrans = myTransMan.StartTransaction
Dim CurRow As Long = 9
Dim LastRow As Long = myXLWS.UsedRange.Rows(myXLWS.UsedRange.Rows.Count).Row
If CurRow <> LastRow + 1 Then
Dim myObjID As DatabaseServices.ObjectId = myXLWS.Cells(CurRow, 23)
Dim myBlockRef As DatabaseServices.BlockReference = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)
Class1_Obj.Setattributes(myObjID, "Length", myXLWS.Cells(CurRow, 2))
CurRow = CurRow + 1
End If
' End Transactions
myTrans.Dispose()
myTransMan.Dispose()