Zum Hauptinhalt gehen

Remove an item from the selection with "RemoveFeatureFromSelection"

Kommentare

2 Kommentare

  • Permanently deleted user

    That command is not really intended for use in Workflow. Fortunately there is another way to do this.

    1. First, add a reference to System.Linq to your Workflow. Click on 'Imports' at the bottom of the screen and start typing 'System.Linq'. When it pops up, hit enter, and you have added a reference to this assembly. This provides some SQL-like methods for use in Visual Basic that will make our lives easier here.

    2. You'll want to hang on to the OBJECTID of the original parcel. This is how you will tell the computer which one you want it to remove later. Put the OBJECTID in a string variable using an assign statement. Here I have called that variable 'objectid', and I have assumed that the objectid field is actually called 'OBJECTID':

    objectid = parcel.Attributes("OBJECTID").ToString();

    3.Then after buffering and performing a query task you will presumably have a FeatureSet that you'd like to remove the original parcel from. Add a RemoveFromCollection task to your workflow, and assuming your featureset variable is called 'selectedFeatures', fill out the parameters (look on the right hand side of the screen) as follows:

    Collection: selectedFeatures.Features

    Item: (From f In selectedFeatures.Features Where f.Attributes("OBJECTID").ToString() = objectid).FirstOrDefault()

    TypeArguement: ESRI.ArcGIS.Client.Graphic

    4. The code in the 'Item' box is where the magic happens. This uses the SQL-type syntax called Linq to look through your featureset for any features which match the OBJECTID you saved earlier. Since we know there is only one, and this task only operates on a single item at a time, you must then call .FirstOrDefault() to transform the resulting collection into a single item.

    Hope this helps.

    0
  • Permanently deleted user

    Thanks Jonathan, worked like a charm and just in time to keep the boss happy!

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.