Feature class definitions are composed of properties that define how classified objects will appear. Each feature class definition can only be used with certain types of drawing objects.
To create a feature class definition, start with a drawing object to use as a template. Get the properties of the drawing object using ClassificationManager.GetProperties(). The current values of the drawing object become the default property values.
Determine the list of object types that the feature class definition can be used with. This list can be expressed as a string collection or a collection of AutoCAD RXClass objects. Create the empty feature class definition using ClassificationManager.CreateFeatureClassDefinition(). Set a drawing object type to use for creating new instances of the class using FeatureClassDefinition.SetCreateMethod().
Dim classMgr As Classification.ClassificationManager
Dim newDef As Classification.FeatureClassDefinition
classMgr = activeProj.ClassificationManager
Dim trans As Transaction = Nothing
Dim obj As DBObject = Nothing
Dim cls As RXClass = Nothing
Try
trans = _
MdiActiveDocument.TransactionManager.StartTransaction()
obj = trans.GetObject(objId, OpenMode.ForRead)
cls = obj.GetRXClass()
trans.Commit()
Finally
trans.Dispose()
End Try
Dim entType As System.String = System.String.Copy(cls.Name)
Dim entTypesCol As StringCollection = New StringCollection()
entTypesCol.Add(entType)
newDef = classMgr.CreateFeatureClassDefinition( _
defName, Nothing, entTypesCol, Nothing, False)
newDef.SetCreateMethod(entType, "")
Use the FeatureClassPropertyCollection as an initial set of properties for the feature class definition. Modify it as needed by setting range and default values for the properties in the collection. Create a new FeatureClassPropertyCollection with the updated properties. Save the feature definition file.
Dim classProp As Classification.FeatureClassProperty
Dim propCollection As _
Classification.FeatureClassPropertyCollection
propCollection = _
New Classification.FeatureClassPropertyCollection
classMgr.GetProperties(classPropCollection, Nothing, objId)
For Each classProp In classPropCollection
' Modify the property if necessary
newDef.AddProperty(classProp)
Next
classMgr.SaveCurrentFeatureDefinitionFile()