AutoCAD Map 3D Forum
Welcome to Autodesk’s AutoCAD Map 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA: objectdata creation

1 REPLY 1
Reply
Message 1 of 2
Anonymous
714 Views, 1 Reply

VBA: objectdata creation

I have used the example of Map Object-data. I try to change the Object-
data definition from a character to integer to do other querys.

How Do I have to Change the Column defenition of the object-data?
Where I have to add the definition "as integer" or "as long"?




Thanks
Gvanaco




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("Index", "Index", "", 0)
Set ODfdf = ODfdfs.Add("pipedia", "pipedia", "", 1)
Set ODfdf = ODfdfs.Add("pipemater", "pipemater", "", 2)





Sub tableproc()

Dim amap As AcadMap
Dim ODfdfs As ODFieldDefs
Dim ODfdf As ODFieldDef
Dim ODtb As ODTable
Dim ODrc As ODRecord

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", "Entity name", "", 0)
Set ODfdf = ODfdfs.Add("Color", "Object color", acRed, 1)
Set ODfdf = ODfdfs.Add("Layer", "Object layer", "0", 2)



'Ensure Table Does Not Exist
If amap.Projects(ThisDrawing) _

.ODTables.Item("SampleOD") Is Nothing Then


'Register OD Table in the drawing

Set ODtb = amap.Projects(ThisDrawing) _

.ODTables.Add("SampleOD", "Sample Xdata", ODfdfs, True)



'Create OD Record with Defaults

Set ODrc = ODtb.CreateRecord



'Loop Through Entities in Model Space

For Each acadObj In ThisDrawing.ModelSpace



'Fill Records with Entity Data

ODrc.Item(0).Value = acadObj.EntityName
ODrc.Item(1).Value = acadObj.Color
ODrc.Item(2).Value = acadObj.Layer



'Attach Record to Entity

ODrc.AttachTo(acadObj.ObjectID)

Next

Else
'Table Already Exists

MsgBox "Unable to create " & "SampleOD", ,"Object Data Table Error"

End If
End Sub
1 REPLY 1
Message 2 of 2
abhishekkalamkar1010
in reply to: Anonymous

Hello,

  Thanks for sharing the code.If I want to run the code for several times then i need to change the name from "SAMPLEOD"  to other Name.Is there any way that without changing any thing in code I could run the code for so many times

 

kindly advice me

 

 

Thanks in Advance !!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost