Check if rebar is tagged

Hi,

with revit 2023 api, TaggedLocalElementId Property was removed. I used it to check whether rebar in current view had tag assigned. What would be suplement for it? I couldnt find any other way to check it with new API. What would be new way to check whether the rebar is tagged?

Previous forum post that discussed this:
https://forum.dynamobim.com/t/rebar-tag-check/5200

Heres the code used in version 2022 which worked.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
tag = UnwrapElement(IN[0])
OUT = []
for t in tag:
	id = t.TaggedLocalElementId
	element = doc.GetElement(id)

	if element.GetType().ToString() == "Autodesk.Revit.DB.Dimension":
		uId = set([r.ElementId for r in element.References])
		for ui in uId:
			OUT.append(doc.GetElement(ui).ToDSType(True))
	else:
			OUT.append(element.ToDSType(True))

Checking the nodes on the property indicates that this was noted for deprecation in 2022, and the recommended alternative is: GetTaggedLocalElements Method

1 Like

Hello, thanks for the response.

I managed to find that property was changed to method. I managed to change the code to get it working but its clunky and I have problem with the list of IDs of tags. I need it flattened but it has 2nd level structure and I couldnt come up how to achieve this.

This is what I get
image

This is what I need
image

Heres the code to get tag IDs but in gets me the wrong structure so I worked it around by using flatten function of dynamo before pluging it to the rest of python script.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
tag = UnwrapElement(IN[0])

idz = []
for t in tag:
	id = t.GetTaggedLocalElementIds()
	idz.append(id)
	 
OUT = idz

How do I get flattened list from that python script?

Heres the preview of dynamo file.

Heres what it does (marks red rebar that is not tagged in view):

Reference files:
Project1.rvt (6.7 MB)
2023_rebarTagCheckInCurrentView.dyn (65.5 KB)

Hi,
replace
idz.append(id)
by
idz.extend(id)

1 Like

Hi Daniel, Do you have the updated script for this please? I still cant get 2022 to work

Also, do you know what packages these 2 nodes are?