Putting data into Object Data ...?

Putting data into Object Data ...?

Anonymous
Not applicable
377 Views
1 Reply
Message 1 of 2

Putting data into Object Data ...?

Anonymous
Not applicable
Hi,

Can anyone tell me how to add object data to a dwg file using VBA in AutoCAD
Map 5? I have a file with data held in extended entity data that I need to
move into object data for use in a shape file. I can get the extended data
fine, but cannot figure out how to automatically shove that data into object
data, as reached via Map>Object Data>Edit Object Data ... from the menu bar.

Grateful for any assistance!

Cheers,

Russell GAnt.
0 Likes
378 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Russell,
There are a few example of this in the help files you might want to look at
if you haven't yet.
Here's what I have use as you wish
Murph

Public Function JM_CreateOdTable()
Dim amap As AcadMap
Dim ODfdfs As ODFieldDefs
Dim ODfdf As ODFieldDef
Set amap = ThisDrawing.Application. _
GetInterfaceObject("AutoCADMap.Application")
'Create OD Table Definition
Set ODfdfs = amap.Projects(ThisDrawing).MapUtil.NewODFieldDefs
' Add Column Headings and Defaults
Set ODfdf = ODfdfs.Add("Entity", "PoleNo", "", 0)
Set ODfdf = ODfdfs.Add("Size", "Size of Pole", "45-2", 1)
Set ODfdf = ODfdfs.Add("X_Location", "X Coordinates", "", 2)
Set ODfdf = ODfdfs.Add("Y_Location", " Y Coordinates", "", 3)
Set ODfdf = ODfdfs.Add("Type", "Primary or Secondary Pole", "", 4)
Set ODfdf = ODfdfs.Add("Device", "Devices on the pole", "", 5)
Set ODfdf = ODfdfs.Add("ROW", "Date ROW cut", "", 6)
Set ODfdf = ODfdfs.Add("PoleCheck", "Date of Last PoleCheck", "", 7)
'Ensure Table Does Not Exist

If amap.Projects(ThisDrawing) _
.ODTables.Item("Pole_No_OD") Is Nothing Then

'Register OD Table in the drawing
Set ODtb = amap.Projects(ThisDrawing).ODTables.Add("Pole_No_OD", "Sample
Xdata", ODfdfs, True)

Else
'Table Already Exists
Set ODtb = amap.Projects(ThisDrawing).ODTables.Item("Pole_No_OD")
End If

End Function
-----------------------------------------------------------------------
Public Function JM_AttachStuff()
Dim strType As String
'Create OD Record with defaults
Set ODrc = ODtb.CreateRecord
'Loop Through Entities in Model Space
Select Case strlay
Case "POLE"
strType = "Primary"
Case "SEC"
strType = "Secondary"
Case Else
strType = ""
End Select
'Fill Records with Data <<<<<<<<<<<<<<
ODrc.Item(0).Value = mapref
ODrc.Item(1).Value = "45-2"
ODrc.Item(2).Value = ip_x
ODrc.Item(3).Value = ip_y
ODrc.Item(4).Value = strType
ODrc.Item(5).Value = "00"

'Attach Record to Entity
ODrc.AttachTo (objent.ObjectID)
End Function
0 Likes