Message 1 of 6
reading Object data in VB

Not applicable
07-09-2007
02:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys:
i am facing a problem when reading an object data of each feature in autocad 2000, i am writting the code in VB
the code is here,
Public objAcadMap As Object
Public objAcad As autocad.AcadApplication
Public objMapPrjs As Object
Public AcadDoc As autocad.AcadDocument
Dim odTable As odTable
Dim odTables As odTables
Dim AcadDoc As AcadDocument
Dim dwgName As String
Dim odtbl As Object
Dim tab_name As String
Dim lst As ListItem
Dim odTable1 As autocadmap.odTable
Set objAcad = CreateObject("AutoCAD.Application")
If Not (objAcad Is Nothing) Then
Set objAcadMap = objAcad.GetInterfaceObject("AutoCADMap.Application")
dwgName = Text1.Text
Set AcadDoc = objAcad.Documents.Open(dwgName)
AcadDoc.Activate
Set objMapPrjs = objAcadMap.Projects
If (objMapPrjs(AcadDoc).odTables.count > 0) Then
For Each odtbl In objMapPrjs(AcadDoc).odTables
Debug.Print (odtbl.Name)
tab_name = odtbl.Name
MsgBox tab_name
Set lst = Me.ListView1.ListItems.Add(, , tab_name)
Next odtbl
Set odTable1 = objMapPrjs(AcadDoc).odTables.Item("ATTACHMENT")
Else
MsgBox "There is no Object Data available.", vbInformation
End If
End If
End Sub
i am getting an error at set odTable1 = objMapPrjs(AcadDoc).odTables.Item("ATTACHMENT") saying an error as "TYPE MISMATCH" and ATTACHMENT is an layer in map
by removing an items it will pass through but the odtable1 will be nothing
Please guide me for the above case.
Regards
Jagadish
i am facing a problem when reading an object data of each feature in autocad 2000, i am writting the code in VB
the code is here,
Public objAcadMap As Object
Public objAcad As autocad.AcadApplication
Public objMapPrjs As Object
Public AcadDoc As autocad.AcadDocument
Dim odTable As odTable
Dim odTables As odTables
Dim AcadDoc As AcadDocument
Dim dwgName As String
Dim odtbl As Object
Dim tab_name As String
Dim lst As ListItem
Dim odTable1 As autocadmap.odTable
Set objAcad = CreateObject("AutoCAD.Application")
If Not (objAcad Is Nothing) Then
Set objAcadMap = objAcad.GetInterfaceObject("AutoCADMap.Application")
dwgName = Text1.Text
Set AcadDoc = objAcad.Documents.Open(dwgName)
AcadDoc.Activate
Set objMapPrjs = objAcadMap.Projects
If (objMapPrjs(AcadDoc).odTables.count > 0) Then
For Each odtbl In objMapPrjs(AcadDoc).odTables
Debug.Print (odtbl.Name)
tab_name = odtbl.Name
MsgBox tab_name
Set lst = Me.ListView1.ListItems.Add(, , tab_name)
Next odtbl
Set odTable1 = objMapPrjs(AcadDoc).odTables.Item("ATTACHMENT")
Else
MsgBox "There is no Object Data available.", vbInformation
End If
End If
End Sub
i am getting an error at set odTable1 = objMapPrjs(AcadDoc).odTables.Item("ATTACHMENT") saying an error as "TYPE MISMATCH" and ATTACHMENT is an layer in map
by removing an items it will pass through but the odtable1 will be nothing
Please guide me for the above case.
Regards
Jagadish