How do we set the FDO feature attribute value to NULL using Map 3D API ?

By Partha Sarkar

In AutoCAD Map 3D UI, when we open the "Data Table" corresponding to a FDO feature layer and delete an attribute value for a FDO feature, it is set to <Null> as shown in the screenshot below.

 

FDO_Set_Null_01

 

 

Using the Map 3D Platform API  SetNull(bIsNull As Boolean) we can  achieve the same.

Here is a relevant code snippet :

 

' Create a new Property colleaction Object
Dim propColl As MgPropertyCollection = New MgPropertyCollection()
 
' Here the Length Prop is specific to a Data Set
Dim lengthProp As MgDoubleProperty = New MgDoubleProperty("Length", Nothing)
 
' To set the attribute value to  we need to use the following method
lengthProp.SetNull(True)
 
'Add the length property to property collection
propColl.Add(lengthProp)
 
' Define a filter to get the object whose property we want to update
'' Feature ID = 10 is specific a FDO data set
Dim filterText As String = "ID=10"
 
'Create the UpdateFeatures object for the update
Dim updateFeatures As MgUpdateFeatures = New MgUpdateFeatures(layer.FeatureClassName, propColl, filterText)
 
' Create a command collection for the update
Dim commands As MgFeatureCommandCollection = New MgFeatureCommandCollection()
commands.Add(updateFeatures)
 
' Commit the Update
fs.UpdateFeatures(resId, commands, True)
layer.ForceRefresh()

 

FDO_Set_Null_02

 

Hope this is useful to you!

 


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading