Revit API provides a variety of ways to pick objects including whole elements and some visible geometry components such as edges and faces/surfaces. They are wrapped in the class Autodesk.Revit.UI.Selection and the most useful and typical ones are PickObject, PickObjects and PickElementsByRectangle.
Object Picker of RevitAddinWizard can help take care of all these methods and any combinations of their arguments. It can be found from both the menu and the toolbar of the Revit Addin Coder:
If the Object Picker is launched and filled out like,
the following code will be created automatically as a helper method of the chosen class in the current project after the OK button is pressed:
public static Reference PickAWallFace(Selection selection)
{
Reference picked = selection.PickObject(ObjectType.Face, new RevitAddinCSProject.SelectionFilter(), "Pick a wall face");
return picked;
}
As can be seen, the code is the same as we introduced before. Here are some more examples.
public static Reference PickAWallEdge(Selection selection)
{
Reference picked = selection.PickObject(ObjectType.Edge, new RevitAddinCSProject.SelectionFilter(), "Pick a wall edge");
return picked;
}
public static Reference PickAWallPoint(Selection selection)
{
Reference picked = selection.PickObject(ObjectType.PointOnElement, new RevitAddinCSProject.SelectionFilter(), "Pick a wall point");
return picked;
}
public static Reference PickAWallElement(Selection selection)
{
Reference picked = selection.PickObject(ObjectType.Element, new RevitAddinCSProject.SelectionFilter(), "Pick a wall");
return picked;
}
public static IList<Reference> SelectWallsThroughPickingFaces(Selection selection)
{
IList<Reference> picked = selection.PickObjects(ObjectType.Face, new RevitAddinCSProject.SelectionFilter(), "Pick wall faces to select walls");
return picked;
}
public static IList<Reference> SelectWallsThroughPickingEdges(Selection selection)
{
IList<Reference> picked = selection.PickObjects(ObjectType.Edge, new RevitAddinCSProject.SelectionFilter(), "Pick wall edges to select walls");
return picked;
}
public static IList<Reference> SelectWallsThroughPickingPoints(Selection selection)
{
IList<Reference> picked = selection.PickObjects(ObjectType.PointOnElement, new RevitAddinCSProject.SelectionFilter(), "Pick wall points to select walls");
return picked;
}
public static IList<Reference> SelectWallsThroughPickingWholeElements(Selection selection)
{
IList<Reference> picked = selection.PickObjects(ObjectType.Element, new RevitAddinCSProject.SelectionFilter(), "Pick whole elements to select walls");
return picked;
}
public static IList<Element> SelectWallsThroughWindow(Selection selection)
{
IList<Element> picked = selection.PickElementsByRectangle(new RevitAddinCSProject.SelectionFilter(), "Select walls through dragging a window");
return picked;
}
The SelectionFilter referenced in the code can be the same as we demonstrated before or can be a totally different class in case it implements the ISelectionFilter interface properly.
Object Picker of RevitAddinWizard along with Selection Filter wizard can take into account countless object picking situations and create code accordingly in a moment.
Our Software http://netspiderstudio.com/Software.html
Support: mailto:[email protected]
Query: mailto:[email protected]
Blog: http://spiderinnet.typepad.com
More: http://netspiderstudio.com
Links to some related articles:
Object Picking of Revit API - PickObject And ObjectType
Object Picking of Revit API - PickObjects And ObjectType
Recent Comments