Dear all,
I want to check whether I can determine the geometry type of the new created feature, is it a point, polyline or polygon?
I am using vb.net and arcmap 10.2.1, thanks.
Solved! Go to Solution.
Hi,
so you're looking for a way to run code each time a new feature is created in an edit-session ? This can be done by using Editor-events (see "ArcGIS Desktop editing for developers" in the online help): the editor object that handles editing tasks in ArcMap owns an event "OnCreateFeature" where you can react on new features inserted by the user.
I hope this helps you and meets your needs. Otherwise please give some more informations about the workflow you want to support.
Frank
Hi,
you could check the GeometryType of the Shape-property of IFeature:
IFeature feature = CreateFeatureOfUnknownType();
//do some null-checks here
//then
switch(feature.Shape.GeometryType)
{
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
//blah
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
//blahblah
break;
//etc
}
Thank you Frank for the quick reply.
I convert the code you provided to vb.net and insert into my vb.net project.
But I get an error:
'CreateFeatureOfUnknownType' is not declared. Is there any library need to import?
Sorry - "CreateFeatureOfUnknownType" is no existing function, it's a placeholder in this example for the function you are using to create your feature.
Hi Frank,
I am creating feature in arcmap, not arcobjects.
Hi,
so you're looking for a way to run code each time a new feature is created in an edit-session ? This can be done by using Editor-events (see "ArcGIS Desktop editing for developers" in the online help): the editor object that handles editing tasks in ArcMap owns an event "OnCreateFeature" where you can react on new features inserted by the user.
I hope this helps you and meets your needs. Otherwise please give some more informations about the workflow you want to support.
Frank
Hi Frank,
Thanks for the update. Yes I am looking for a way to run code each time a new feature is created in an edit-session. Will follow the instruction you give me.
Hi Frank,
Sorry to trouble you. I have followed the sample code from : http://resources.esri.com/help/9.3/arcgisengine/arcobjects/esriEditor/IEditEvents_OnCreateFeature.ht...
I can determine when the new feature is created, but I don't know how to get the geometry type, any hints? So sorry I know little about arcobjects.
Hi Li,
no problem. In the event-handler OnCreateFeature you receive the parameter "obj" of type IObject. IFeature inherites from IObject - in this case the parameter obj is an IFeature so that you can cast obj to IFeature and use the code above to check the GeometryType.
I'm no vb-crack but I guess it should look like this (at least similar):
Private Sub OnCreateFeature(ByVal obj As ESRI.ArcGIS.Geodatabase.IObject) Dim feature as IFeature feature = DirectCast(obj, IFeature) if feature.Shape.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon then 'do something with a polygonfeature else etc. ... End Sub
regards
Frank
Thanks Frank, it works.