
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I want to make a selection of multiple elements(viewports), and this selection, I want it to be by "PickObjects" and not "PickByRectangle". So, when trying to implement the following lines of code in order to make the desired selection, I come up with a conversion error. This error states the following:
Error CS0039: Cannot convert type 'Autodesk.Revit.DB.Reference' to 'Autodesk.Revit.DB.Viewport' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion
Build failed.
The code is:
ISelectionFilter viewportfilter = new ViewPortPickFilter();
Selection choices = uidoc.Selection;
IList<Reference> refa = choices.PickObjects(ObjectType.Element,viewportfilter, "Pick multiple elements one by one");
foreach(Reference vp in refa)
{
var e = vp as Viewport;
}
I have tried changing IList<Reference> for <Viewport> and the pertinent modifications, however, then the issue is on choices, stating that it cannot convert type reference to viewport once again...
Thus, If someone could give me a generic way of PickObjects. It would be really appreciated.
Thanks in advance!
Solved! Go to Solution.