i am trying to read the Object data records. i can see the object data table and definitions and field names, but cannot seem to get to the value of each field. What am i missing?
ed AsEditor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim pe AsNewPromptEntityOptions("Select Object..")
Dim pr AsPromptEntityResult= ed.GetEntity(pe)
If pr.Status = PromptStatus.OK ThenUsing trans AsTransaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransacti
Dim ent AsEntity = trans.GetObject(pr.objectid, OpenMode.ForRead)
Dim myTables As Autodesk.Gis.Map.ObjectData.Tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables
Dim myRec As Autodesk.Gis.Map.ObjectData.Records = myTables.GetObjectRecords(0, ent.ObjectId, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead, True)
Dim myFieldDef As Autodesk.Gis.Map.ObjectData.FieldDefinitions' Dim FieldDef As Autodesk.Gis.Map.ObjectData.FieldDefinitionForEach rec As Autodesk.Gis.Map.ObjectData.RecordInmyRec
Dim table As Autodesk.Gis.Map.ObjectData.Table= myTables(rec.TableName.ToString)
myFieldDef = table.FieldDefinitions
Dim i AsIntegerWhilei < myFieldDef.Count
i = i + 1
Dim i As Integer = 0 While i < myFieldDef.Count 'you first have to check the datatype of the column 'then you can do one of these statements (or more like boolean ...) debug.print rec(i).Int32Value.ToString debug.print rec(i).DoubleValue.ToString debug.print rec(i).StrValue MsgBox(myFieldDef.Item(i).Name) i = i + 1 EndWhile
HTH, - alfred -
I have gone through
for help on extracting ObjData from an object and it is over my head.
I have created referance to ManagedMapApi.dll
I have Imports Autodesk.Gis.Map.ObjectData.
now what do I need to do to extract OD from my objects.
Dim activeProject AsProject.ProjectModel = mapApp.ActiveProject Dim table As ObjectData.Table = tableList("table1")
why not continueing >>>here<<<?
The thread-title says "Does it have Object Data" ==> is that also your problem? Or do you have another one?
- alfred -
Hey Alfread...looks like you are burning the midnight oil as well.
anyway when I use
Dim fieldDefs AsAutodesk.Gis.Map.ObjectData.FieldDefinition = table.FieldDefinitions
Dim recs As ObjectData.Records
recs = table.GetObjectTableRecords(0, objId, Constants.OpenMode.OpenForRead,True)
from the sample,
I get a bunch of errors.
Error 1 'table' is ambiguous, imported from the namespaces or types 'Autodesk.Gis.Map.ObjectData, ADOX, Autodesk.AutoCAD.DatabaseServices'.
Error 2 Type 'ObjectData.Records' is not defined.
Error 3 'table' is ambiguous, imported from the namespaces or types 'Autodesk.Gis.Map.ObjectData, ADOX, Autodesk.AutoCAD.DatabaseServices'.
Error 4 'OpenMode' is not a member of 'Microsoft.VisualBasic.Constants'.
besides all I have is a selection set and just one table.
All I want to do is get the object data of an object, and not all the objects in the selection may have object data.
>> is ambiguous, imported from the namespaces or types
that message means you have 3 namespaces having an item "table", so the compiler does not know how to do with them.
Either you be more careful on top of your code-file with the number of "import"-statements or you write the full namespace-part to these lines.
And every time you get something like "not a member of" you also can try to use the full namespace for that object (or this enumeration).
- alfred -
Thank for your patients, I am still getting my feet wet with vb.net
Bottom line, specifically what do I need to do to get this sample code to work.
After that, I can step through the debugger to see exactly how it works.
is it just a sample solution you are currently working (so you can upload your sources/projects/solution-files) or can't you upload it?
If first ... would be much easier to describe what to change
- alfred -
Access a broad range of knowledge to help get the most out of your products and services.