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

Autodesk.Gis.Map.ObjectData.FieldDefinition.SetDefaultValue

1 REPLY 1
SOLVED
Reply
Message 1 of 2
JohnDutz
1291 Views, 1 Reply

Autodesk.Gis.Map.ObjectData.FieldDefinition.SetDefaultValue

The following VB code, taken almost verbatim from the Map 3D Object ARX .Net Developer's Guide, doesn't compile for Map 3D 2014 (didn't test it for other versions).

 

Here's the compiler error:

Error 10 'SetDefaultValue' is not a member of 'Autodesk.Gis.Map.ObjectData.FieldDefinition'. C:\Users\jdutz\Documents\Visual Studio Projects\C3D_2014\MH_ParcelTools\ClassLibrary2\Class1.vb 17 9 ClassLibrary2

 

The error appears to be because the SetDefaultValue method isn't defined.  Is there a workaround?

 

 

Imports Autodesk.Gis.Map

Imports Autodesk.Gis.Map.Project

Imports Autodesk.Gis.Map.ObjectData

 

Public Class Class1

 

    Private Sub Sub1()

        Dim mapApp As MapApplication

        mapApp = HostMapApplicationServices.Application

 

        Dim fieldDefs As ObjectData.FieldDefinitions

        fieldDefs = _

          mapApp.ActiveProject.MapUtility.NewODFieldDefinitions()

        Dim def1 As ObjectData.FieldDefinition

        def1 = fieldDefs.Add("FIRST_FIELD", "Owner name", _

          Autodesk.Gis.Map.Constants.DataType.Character, 0)

        def1.SetDefaultValue("A")

 

        Dim def2 As ObjectData.FieldDefinition

        def2 = fieldDefs.Add("SECOND_FIELD", "Assessment year", _

          Autodesk.Gis.Map.Constants.DataType.Integer, 1)

        def2.SetDefaultValue(0)

 

    End Sub

 

End Class

 

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: JohnDutz

I think the sample code from AutoCAD Map ObjectARX SDK's document/dev. guide is out-dated. The documentation on AutoCAD Map development has been particularly known for its not being updated.

 

The oldest AutoCAD Map version I currently has access is AutoCAD Map 2012, and indeed the ObjectData.FieldDefinition class does not have the method SetDefaultValue(). This method must have been there when first AutoCAD Map .NET API avialble in Map 2006 and was removed in later version.

 

Anyway, to create a FieldDefinition with default value, you can use FieldDefinition's static method Create() and then add the FieldDefinition into the FieldDefinitions collection:

 

Dim field As FieldDefinition= _

    FieldDefinition.Create("MyField1","This is the field for...", "This is default text value") ''The last parameter could be String, Integer, Doule...

 

MyOdTable.FieldDefinitions.AddColumn(field,0)

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost