Hello to everybody.
I have tried to write a code that can update attribute data in block of autocad file.
I found alot of example in this forum, but i dont know why my programe can not work.
My PC is winXP, VS2008, autocad2009.
1. This code is work ofcouse:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("hello")
End Sub
2. But this one does not work:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("hello")
Dim myBT As DatabaseServices.BlockTable
End Sub
As long as i insert in the code which relative to reference .dll; i got error: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
It means that problem is my PC sysem, sofware... not about the code.
Please help me to fix it, i spent two but still not found the reason.
Here the code i used:
Function PopulateOIDCs(ByVal BlockName As String) _
As DatabaseServices.ObjectIdCollection
Dim myBT As DatabaseServices.BlockTable
Dim myBTR As DatabaseServices.BlockTableRecord
Dim myBTRE As DatabaseServices.SymbolTableEnumerator
Dim myDB As DatabaseServices.Database
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myOIDs As New DatabaseServices.ObjectIdCollection
Dim myOIDs2 As DatabaseServices.ObjectIdCollection
Dim I As Long
Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDB = acDoc.Database
myTransMan = myDB.TransactionManager
myTrans = myTransMan.StartTransaction
myBT = myDB.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
myBTR = myBT(BlockName).GetObject(DatabaseServices.OpenMode.ForRead)
myOIDs2 = myBTR.GetBlockReferenceIds(True, False)
For I = 1 To myOIDs2.Count
myOIDs.Add(myOIDs2.Item(I - 1))
Next
myBTRE = myBT.GetEnumerator
While myBTRE.MoveNext
myBTR = myBTRE.Current.GetObject(DatabaseServices.OpenMode.ForRead)
If myBTR.IsLayout = False Then
Select Case myBTR.IsAnonymous
Case True
myOIDs2 = myBTR.GetBlockReferenceIds(True, False)
If myOIDs2.Count > 0 Then
Dim myBRef As DatabaseServices.BlockReference
myBRef = myOIDs2(0).GetObject(DatabaseServices.OpenMode.ForRead)
Dim myBTR2 As DatabaseServices.BlockTableRecord
myBTR2 = myBRef.DynamicBlockTableRecord.GetObject( _
DatabaseServices.OpenMode.ForRead)
If myBTR2.Name.CompareTo(BlockName) = 0 Then
For I = 1 To myOIDs2.Count
myOIDs.Add(myOIDs2.Item(I - 1))
Next
End If
End If
End Select
End If
End While
myTrans.Dispose()
myTransMan.Dispose()
Return myOIDs
End Function
Hello,
Is that a compile error ?
Have you set the right .Net framework version in your project settings ?
For .Net applications, you can use VS 2008 but need to set the target framework to 3.0