- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Forum,
I have created SelectionSets of the ModelItems on the basis of Revit family type and provided display name as same Revit family type. for example if Revit family type is "Walls" then I am making one selection set of all the walls in model and naming this selection set as Walls.
For an exercise I wanted Revit ID's of all the walls, So I used the property of SelectionSet called "ExplicitModelItems"
code-
1.ModelItemCollection mic = set.ExplicitModelItems;
2.foreach(ModelItem item in mic){
3. getRevitID(item);
4. }
But at line 1 it throws an exception "InvalidOperationException".
I searched API doc's and it says this property throws an exception when when property name '!HasExplicitModelItems' is false.
Forum is there any specific reason for this exception to occur ?
On the other hand my selection set is not empty and fortunately in API doc's I found one method "SelectionSet.GetSelectedItems(ActiveDoc)" which returns ModelItemCollection of ModelItem in SelectionSet.
So I was able to carry out my exercise completely.
But Why this property is null ?
Becuase I have Observed same thing for ModelItem.Model property, When I try to access the model from modelItem. it returns null.
Solved! Go to Solution.