This article provides an example of how to Find items in a limited context, i.e., not in the entire database. In this example, the result is to return all items of a specific item type based on the item type specified in the search criteria.
Example
private static void GetAllItemsWithSid(IswItem topItem, string wantedSid) { var visitedItemHandels = new HashSet<long>(); IswItems foundItems = topItem.Broker.Lists.NewItemList(); GetItemsWithSidRecursive(topItem, wantedSid, foundItems, visitedItemHandels); } private static void GetItemsWithSidRecursive(IswItem topItem,string wantedSid, IswItems foundItems, HashSet<long> visitedItemHandels) { //Read all parts that is connected to topItem foreach(IswPart part in topItem.GetAllParts()) { //Get the parts DefObj as IswItem IswItem item = part.DefObj as IswItem; //If part.DefObj isn't an IswItem go to next. if (item != null) { //Since SystemWeaver allows cirkular references the program must control that the item isn't already visited if (visitedItemHandels.Add(item.Handle)) { //If the item is of the wanted SID save it in the foundItem list if (item.IsSID(wantedSid)) foundItems.AddUnique(item); //Do the same operation on this item as its owner GetItemsWithSidRecursive(item, wantedSid, foundItems, visitedItemHandels); } } // Do the same control on RefObj item = part.RefObj as IswItem; if (item != null) { if (visitedItemHandels.Add(item.Handle)) { if (item.IsSID(wantedSid)) foundItems.AddUnique(item); GetItemsWithSidRecursive(item, wantedSid, foundItems, visitedItemHandels); } } } }