Visit Methods
 
Methods Introduced:
In a Creo Object TOOLKIT C++ application, you may often want to perform an operation on all the objects that belong to another object, such as all the features in a part, or all the surfaces in a feature. For such cases, Creo Object TOOLKIT C++ provides an appropriate visit method. The visit method is an alternative to passing back an array of data.
The method wfcWAssembly::VisitComponents visits all the components in an assembly. The input argument visitingClient specifies an object of type wfcVisitingClient that contains the visit action and filter methods for visiting items.
The method wfcVisitingClient::ApplyAction is the method that you want to be called for each item and pass its pointer to the Creo Object TOOLKIT C++ visit method. This method is referred to as the visit action method. The Creo Object TOOLKIT C++ visit method calls the visit action method once for every visited item.
The method wfcVisitingClient::ApplyFilter is referred to as the filter method. The filter method is called for each visited item before the action method. The return value of the filter method controls whether the action method must be called for that item. You can use the filter method as a way of visiting only a particular subset of the items in the list.
The filter method must return one of the following values defined in enumerated data type wfcStatus:
wfcTK_CONTINUE—Specifies that the visit action method must not visit this object, but continue to visit the subsequent objects.
Any other value—Specifies that the visit action method must be called for this object. The return value must be passed as the input argument to the visit action method.
The visit action method must return one of the following values defined in enumerated data type wfcStatus:
wfcTK_NO_ERROR—Specifies that the visit action method must continue visiting the other objects in the list.
wfcTK_E_NOT_FOUND—Specifies that no items of the specified type were found and therefore no objects could be visited.
Any other value including wfcTK_CONTINUE—Terminates the visit. Typically this status is returned from the visit action method on termination, so that the calling method knows the reason for the abnormal termination of the visit.
For the method wfcWSolid::VisitItems, the actual type of item passed to the methods wfcVisitingClient::ApplyAction and wfcVisitingClient::ApplyFilter is of type wfcWModelItem. To make the methods of wfcWModelItem available in pfcModelItem, cast pfcModelItem to wfcWModelItem.
Similarly, for the method wfcWAssembly::VisitComponents, to make the methods of wfcWComponentFeat available in pfcObject, cast pfcObject to wfcWComponentFeat.
If you are using Creo Object TOOLKIT C++ together with Creo TOOLKIT, use the utility method wfcStatusFromPro to convert the ProError to equivalent Creo Object TOOLKIT C++ wfcStatus. Use the utility method wfcStatusToPro to convert a Creo Object TOOLKIT C++ wfcStatus to an equivalent ProError.
The method wfcWFeatureGroup::VisitDimensions traverses the members of the feature group.
The method wfcWModel::VisitItems visits the pfcModelItemType objects in the model for the specified type of item only if the model has a single body, else returns the error wfcTK_MULTIBODY_UNSUPPORTED.
The method wfcWFeature::VisitItems visits the annotation elements in the specified feature.
The method wfcWModel::VisitDetailItems visits the pfcDetailType objects in the model for the specified drawing and sheet of a detail item.
Was this helpful?