When I try and run this I get error: user defined type not defined. Code
breaks at:
Dim odTables as odtables. What does it mean to dim something as itself?
thanks,
russell
"Scott Friedrich" wrote in message
news:F835F9B81DC605FA2067A978093EA6D4@in.WebX.maYIadrTaRb...
> Maybe this will help - the following sub prompts for an entity, then loops
> through all the ODTables in the dwg and gathers all the ODrecords for the
> entity.
>
> Good Luck,
>
> Private Sub cmdSelect_Click()
> Dim ent As Object
> Dim sset As AcadSelectionSet
> Dim odTables As odTables
> Dim odTable As odTable
> Dim RecordIterator As odRecords
> Dim odRecord As odRecord
> Dim odValue As ODFieldValue
> Dim msg As String
> Dim count As Integer
>
>
> '' create a new selection set
> Set sset = ThisDrawing.SelectionSets.Add("OD_SSET")
>
> '' clear entity
> Set ent = Nothing
>
> '' hide our form and activate acad window
> Me.Hide
> AppActivate ThisDrawing.Application.Caption
>
> '' let user select an entity
> sset.SelectOnScreen
> If sset.count > 0 Then
> Set ent = sset.Item(0)
> End If
>
> '' remove selection set
> sset.Delete
>
> '' if we got an entity
> If Not ent Is Nothing Then
>
> '' clear message
> msg = ""
>
> '' get the selected object data table and iterator
> Set odTables = amap.Projects(ThisDrawing).odTables
> For Each odTable In odTables
> Set RecordIterator = odTable.GetODRecords
>
> '' initilize iterator on entity
> If RecordIterator.Init(ent, False, False) = True Then
>
> '' oops, that entity has no od attached to specified table
> If RecordIterator.IsDone Then
> msg = msg & "Entity has no data from Object Data
Table:
> " & odTable.Name
> End If
>
> '' loop through all attached records from specified table
> Do Until RecordIterator.IsDone
>
> '' get record data
> Set odRecord = RecordIterator.Record
>
> '' initialize field counter
> count = 0
>
> '' loop through each od field
> For Each odValue In odRecord
>
> '' get field name from defs
> msg = msg &
odTable.ODFieldDefs.Item(count).Name
>
> '' and show field value
> Select Case odValue.Type
> Case 0, 1, 2, 3
> msg = msg & " = " & CStr(odValue.Value) &
> Chr(10)
> Case 4
> msg = msg & " = " & CStr(odValue.Value.X)
&
> "," & CStr(odValue.Value.Y) & "," & CStr(odValue.Value.X) & Chr(10)
> End Select
>
> '' increment field counter
> count = count + 1
> Next
>
> '' there may be more records attached
> RecordIterator.Next
> Loop
>
>
> '' error getting iterator
>
> Else
>
> '' report the bad news
> msg = "Error iterating Object Data Table: " & odTable.Name
> End If
> Next
> '' update text box
> txtOD.Text = msg
>
> End If
>
> '' restore our form after acad selection
> Me.Show
>
> End Sub
>
>
> "Marcelo" wrote in message
> news:62A3307B3213D62538CFAB31B5F88AD5@in.WebX.maYIadrTaRb...
> > I'm using VBA with AutoCad Map 4 and I need to get the
> > attribute values of records of a specific Object Data
> > Table. The follow code is returning the runtime
> > error "Method 'Record' of objetc 'ODRecords' failed". My
> > drawing contain any lines attached to three ODTables.
> > Can you helpme ??
> >
> > Sincerely,
> >
> > Marcelo
> > BRAZIL
> >
> >
> > Public Sub ViewItem()
> > Dim Objeto As acadObject
> > Dim Mapas As AcadMap
> > Set Mapas =
> > ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")
> > For Each Objeto In ThisDrawing.ModelSpace
> > If
> Mapas.Projects(ThisDrawing).ODTables(2).GetODRecords.Init(Objeto,
> > True, False) Then
> > Debug.Print
> >
Mapas.Projects(ThisDrawing).ODTables(2).GetODRecords.Record.Item(1).Value
> > End If
> > Next
> > End Sub
> >
> >
> >
>
>