Active Contributor
Posts: 31
Registered: ‎02-19-2011
Message 1 of 2 (146 Views)

Problem with VS2008 & autocad

146 Views, 1 Replies
11-26-2012 08:09 AM

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
    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
        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))
        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( _

                            If myBTR2.Name.CompareTo(BlockName) = 0 Then
                                For I = 1 To myOIDs2.Count
                                    myOIDs.Add(myOIDs2.Item(I - 1))
                            End If
                        End If
                End Select
            End If
        End While
        Return myOIDs
    End Function

ADN Support Specialist
Posts: 660
Registered: ‎03-21-2011
Message 2 of 2 (94 Views)

Re: Problem with VS2008 & autocad

12-03-2012 08:20 AM in reply to: cokhitp



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





Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community