Create Stand Alone Feature Class

403
2
03-01-2013 03:55 PM
BrianBaldwin1
New Contributor III
Hi All, I have a real beginner question here.

I am using this code from the Arc sample's, it is the CreateStandaloneFeatureClass.

Basically, what do I place in the OnClick Sub to call this function?  I have been doing a lot of reading and just ordered some books....but could use some help with this very basic concept. 

Thus far, I had my Sub with this code: CreateStandaloneFeatureClass(, "Test", , "Test")

Public Function CreateStandaloneFeatureClass(ByVal workspace As IWorkspace, ByVal featureClassName As String, ByVal fieldsCollection As IFields, ByVal shapeFieldName As String) As IFeatureClass
        Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace)
        Dim fcDesc As IFeatureClassDescription = New FeatureClassDescriptionClass()
        Dim ocDesc As IObjectClassDescription = CType(fcDesc, IObjectClassDescription)

        ' Use IFieldChecker to create a validated fields collection.
        Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
        Dim enumFieldError As IEnumFieldError = Nothing
        Dim validatedFields As IFields = Nothing
        fieldChecker.ValidateWorkspace = workspace
        fieldChecker.Validate(fieldsCollection, enumFieldError, validatedFields)

        ' The enumFieldError enumerator can be inspected at this point to determine
        ' which fields were modified during validation.
        Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID, esriFeatureType.esriFTSimple, shapeFieldName, "")
        Return featureClass
    End Function  
0 Kudos
2 Replies
BrianBaldwin1
New Contributor III
Just adding some clarification.  I have the function all built (from the sample code provided by ESRI), I just don't know how to call it with the OnClick Sub. 

Thus far I have CreateStandaloneFeatureClass(, "Test", , "Test"), in the OnClick Sub, but I still need to provide the workspace and the fieldsCollection values, what would these be?
0 Kudos
LeoDonahue
Occasional Contributor III
IWorkspace and IFields are two object references that you need to write code for, before you can pass them to that Sub.

I don't know, but it sounds like you are maybe creating a console application, in which nothing really exists until you create it?

These might help.

Creating Geodatabases

Create FeatureClass Snippet
0 Kudos