Author Topic: object data table and field definitions sync  (Read 2921 times)

0 Members and 1 Guest are viewing this topic.

jcoon

  • Newt
  • Posts: 157
object data table and field definitions sync
« on: March 11, 2014, 05:54:24 PM »
Need help syncing object data tables and field definitions

I'm able to loop thru the active map project and get the object data tables and their names and I was able to loop thru the field definitions and return the field names.
what I'm looking to find out is how to sync the object tables and the field definitions for each index so that I only get the field definitions for that current index.

My final goal is to sent the object data names to combobox1, which I've accomplished. Next I need the field definitions names synced so that when I select a new table name in combobox1 let say that the field definitions names for that object data table name are populated in a combo box or list box.

Any links or info you can provide are welcome.

Thank you,
John

'sample
' Loop through all object data tables in active project
                    For i = 0 To myTables.TablesCount - 1
                        ' Get Objects Data Table names
                        Dim mytable As ObjectData.Table = myTables.Item(myTables.GetTableNames(i))
                        strtablename = mytable.Name
                        Me.ComboBox2.Items.Add(strtablename.ToString)

                        ' Loop through all Field Definitions in active project
                        Dim fieldDefs As ObjectData.FieldDefinitions = mytable.FieldDefinitions
                        For j = 0 To fieldDefs.Count - 1
                            ' Get Field Definitions names
                            Dim fieldDef As ObjectData.FieldDefinition = fieldDefs.Item(j)
                            Me.ComboBox3.Items.Add(fieldDef.Name)

                        Next
                    Next

jcoon

  • Newt
  • Posts: 157
Re: object data table and field definitions sync
« Reply #1 on: March 16, 2014, 10:25:38 AM »
all,

For those how are interested, I found that I was looping thru the entire table and its FieldDefinitions. all I needed to do was limit it to a names table and I was able to get the field names for that current table. Still working on the best way to index all the defined object data tables with the map values & field names so I can edit them, which is the goal here.

Dim myTable = myTables.Item("obstacle")
Dim fieldDefs As ObjectData.FieldDefinitions = myTable.FieldDefinitions
  For j = 0 To fieldDefs.Count - 1
  Dim fieldDef As ObjectData.FieldDefinition = fieldDefs.Item(j)
  Me.ComboBox2.Items.Add(fieldDef.Name)
  'ed.WriteMessage(vbCrLf + vbLf & "Field name" & fieldDef.Name + ": ")
   Next

huiz

  • Swamp Rat
  • Posts: 919
  • Certified Prof C3D
Re: object data table and field definitions sync
« Reply #2 on: March 17, 2014, 09:04:12 AM »
A year ago I wrote an application for classifying objects and used Object Data for that. There is not much information about Map 3D programming, just a few simple examples. It is easier to use Extended Data so it is also available in standard AutoCAD. Unless you need database chains and Map 3D stuff.

I was even as far to be able to read/write geometry in an Oracle database without FDO. But then the company I worked for went bankrupt. In my new job we focus more on Civil3D.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

jcoon

  • Newt
  • Posts: 157
Re: object data table and field definitions sync
« Reply #3 on: March 18, 2014, 07:56:18 AM »
Huiz,

Your correct about not having many samples on the subject, I've found very little, and what I have found is mainly in C which I have  difficulty converting so that I can test it. This is the first attempt at using map.  I'm looking into it because we have a need to add or attach and edit attribute information for a design specification. we also have a need to add classified objects. I've created an xml definition file much like the industry standard files supplied with map, it seems to work well enough but its difficult to create and edit. It works great for attaching the object data tables but it has no editing for field value attachment unless the value is default to the object data table from which the classification file was created from. It world be great to be able to draw the geometry and attach at the same time. if I can't figure this out I guess I'll have to look seek out someone who can. The best that I've been able to do in the last week or so is to test that the dwg has object data tables, if it does I loop thru the tables name and add them to a comboBox, next it loops thru the field definition names of a named object table and adds those items to a comboBox, next with a selection in the field definition names it prints a list of the values for that single field, that's about it. I know I need to figure out how to better index all the items, that's where I'm going to focus because project will have about 25 object data table names and each one of those has been 6 and 25 field definitions name that require a value. The only AutoCAD Map process that comes the closest is editing shape file dbf thru the data table. maybe it that direction could be an option if the object data tables are already assigned to the objects.

Thanks for the encouragement
John
 

n.yuan

  • Bull Frog
  • Posts: 348
Re: object data table and field definitions sync
« Reply #4 on: March 18, 2014, 09:38:47 AM »
Quote
...I'm looking into it because we have a need to add or attach and edit attribute information for a design specification. we also have a need to add classified objects. I've created an xml definition file much like the industry standard files supplied with map, it seems to work well enough but its difficult to create and edit. It works great for attaching the object data tables but it has no editing for field value attachment unless the value is default to the object data table from which the classification file was created from. It world be great to be able to draw the geometry and attach at the same time...

I am not sure I understand what the above quoted statements mean. You do know Object Classification and ObjectData are two different approach to attach data attribute to AutoCAD entities, don't you? Yes, with either approach, the data attribute (Object class data, or ObjectData record) can be attached to geometry entities when they are created (well, theoretically, the entity must be created first before data can be attached, but your code can make it look like to users that they are created at the same time), and make the attribute data field have any valid value other than default value. Keep up exploring the Map API, I am sure you'd find your way.

Since this is a AutoCAD MAP API topic and fairly old technologies (ObjectData/ObjectClassification) to which Autodesk has not improved/enhanced in past 7 to 10 year, I suspect there aren't many programmers doing anything with or being much interested in, in terms of custom application development.

jcoon

  • Newt
  • Posts: 157
Re: object data table and field definitions sync
« Reply #5 on: March 19, 2014, 07:49:51 AM »
n.yuan,

yes I know they are different, I use the classification file to map existing points, line and polylines objects to classified object and add the blank object data table and I use the object data table data to add and edit the values for the specification I have to follow. With the editing of the object data I need to some how display the enumerated code values for the user to select from a list supplied from the spec. It's pretty much like the attribute domain values you can create in ESRI. that's the process I'm trying match in AutoCAD. 

If these methods are outdated, what direction would you use to match the classification of object and adding and editing object data?
one of the goals of this project outside just the process of attaching the data to the objects is that the data will be used in a GIS data set, exported shape files.

thanks
John

Miroslav

  • Mosquito
  • Posts: 3
Re: object data table and field definitions sync
« Reply #6 on: November 04, 2015, 04:34:42 AM »
jcoon i would recommend try put all data in Excel for clarity so you can see all tables and their values good. I had the same problem as you and tryed alot to put it in different forms with DataGrid tables. But why? If you aint gonna do a program for commercial use, use Excel. It is very easy also to rewerite back data from excel to the OD tables you can have your own database structure this way. I did it for attributes in Blocks and it worked perfectly.

Best would be a simple text file for speed, Excel can get slow sometimes if you read and write back data from 1000 of rows. But text file dont got all the free functions you get if you want to edit values ;)

jcoon

  • Newt
  • Posts: 157
Re: object data table and field definitions sync
« Reply #7 on: December 10, 2015, 04:17:09 PM »
Miroslav,

Thank you. I'll give this another try

John Coon