AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Valued Contributor
bill.salling
Posts: 66
Registered: ‎10-07-2008
Message 1 of 16 (714 Views)

Does it have Object Data? vb.net

714 Views, 15 Replies
10-12-2011 12:46 PM

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?

 

Dim

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.StartTransaction()

 

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

MsgBox(myFieldDef.Item(i).Name)

i = i + 1

EndWhileNextEndUsingEndIf

Valued Contributor
bill.salling
Posts: 66
Registered: ‎10-07-2008
Message 2 of 16 (712 Views)

Re: Does it have Object Data? vb.net

10-12-2011 12:48 PM in reply to: bill.salling

forgot to say 2012.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,607
Registered: ‎06-29-2007
Message 3 of 16 (711 Views)

Betreff: Does it have Object Data? vb.net

10-12-2011 01:01 PM in reply to: bill.salling

Hi,

 

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
bill.salling
Posts: 66
Registered: ‎10-07-2008
Message 4 of 16 (700 Views)

Re: Does it have Object Data? vb.net

10-13-2011 05:44 AM in reply to: bill.salling

Thank you that was it.

 

Mentor
mfernandes
Posts: 208
Registered: ‎08-21-2007
Message 5 of 16 (535 Views)

Re: Does it have Object Data? vb.net

04-23-2012 11:18 PM in reply to: bill.salling

 

please help

I have gone through

http://wikihelp.autodesk.com/AutoCAD_Map_3D/enu/2012/Help/0000-Map_3D_O0/0009-Object_D9/0010-Introdu...

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")

 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,607
Registered: ‎06-29-2007
Message 6 of 16 (532 Views)

Re: Does it have Object Data? vb.net

04-23-2012 11:26 PM in reply to: mfernandes

Hi,

 

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
mfernandes
Posts: 208
Registered: ‎08-21-2007
Message 7 of 16 (529 Views)

Re: Does it have Object Data? vb.net

04-24-2012 12:25 AM in reply to: Alfred.NESWADBA

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.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,607
Registered: ‎06-29-2007
Message 8 of 16 (527 Views)

Re: Does it have Object Data? vb.net

04-24-2012 01:02 AM in reply to: mfernandes

Hi,

 

>> is ambiguous, imported from the namespaces or types

>>     'Autodesk.Gis.Map.ObjectData,

>>     ADOX,

>>     Autodesk.AutoCAD.DatabaseServices'

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 -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
mfernandes
Posts: 208
Registered: ‎08-21-2007
Message 9 of 16 (520 Views)

Re: Does it have Object Data? vb.net

04-24-2012 10:08 AM in reply to: Alfred.NESWADBA

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.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,607
Registered: ‎06-29-2007
Message 10 of 16 (518 Views)

Re: Does it have Object Data? vb.net

04-24-2012 11:09 AM in reply to: mfernandes

Hi,

 

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 :smileywink:

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.