reading Object data in VB

reading Object data in VB

Anonymous
Not applicable
343 Views
5 Replies
Message 1 of 6

reading Object data in VB

Anonymous
Not applicable
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
0 Likes
344 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
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

The object type being returned from odTables.Item ... does not match the
data type declared for the variable you are assigning it to. In this case
odTable1 does not match the data type of the return value.

joe ...


wrote in message news:5650771@discussion.autodesk.com...
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
0 Likes
Message 3 of 6

Anonymous
Not applicable
thnx........
then in this case how we can assign odtables to odtable1
can any body guide me
0 Likes
Message 4 of 6

Anonymous
Not applicable
one way would be to change the variable data type to object until you figure
out the exact object data type.

joe ...


wrote in message news:5651978@discussion.autodesk.com...
thnx........
then in this case how we can assign odtables to odtable1
can any body guide me
0 Likes
Message 5 of 6

Anonymous
Not applicable
thnx joe........

i have changed the datatype to Object.....it is working fine...i will get back to u if i found as such any

Jagadish
0 Likes
Message 6 of 6

Anonymous
Not applicable
using the generic data type Object will always work when assigning an
object. what it does not do is give you the intellisense associated with the
specific object that it is. just makes things a bit more complicated. i
would still suggest you attempt to get it to a more specific object data
type.

joe ...

wrote in message news:5652109@discussion.autodesk.com...
thnx joe........

i have changed the datatype to Object.....it is working fine...i will get
back to u if i found as such any

Jagadish
0 Likes