- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
There is a change from Revit 2023 that you are not longer allowed to tag a whole rebar set with a Independent Tag. You need to tag one of the individual rebars which are Subelements of the rebar set. See this forum post for more: https://forums.autodesk.com/t5/revit-api-forum/revit-2023-version-getting-an-error-at-independenttag...
Is there any way to avoid this exception without a try/catch block? I have tried the following:
1) Use a ObjectType.Subelement filter in PickObject. This works to some degree, but if you mouse over the first or the last rebar in a rebar higlights the whole set.
pickedRebarRef = uidoc.Selection.PickObject(ObjectType.Subelement, "Pick a single Rebar");
2) Try to create a filter using the ISelectionFilter interface, but it requires an Element and not Subelement.
3) Check if the selected reference can be converted to a Subelement. The problem is that even if the whole rebar set is selected it still converts to a valid Subelement.
pickedRebarRef = uidoc.Selection.PickObject(ObjectType.Subelement, "Pick a Rebar");
if(doc.GetSubelement(pickedRebarRef) == null) {
//please select only one bar
}
4) Similar to 3) this returns true even when the whole set is selected:
Subelement.IsValidSubelementReference(doc, pickedRebarRef);
Solved! Go to Solution.
Developer Advocacy and Support +