# Python Help - Untagged rebar

**URL:** <https://forum.dynamobim.com/t/python-help-untagged-rebar/87560>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [March 20, 2023, 3:27pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560 "2023-03-20T15:27:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [March 20, 2023, 3:27pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/1 "2023-03-20T15:27:24Z")

</div>

I have been using a script since 2018 that notifies me of any untagged rebars but when I have gone to use it in Revit 2022 I get an error message:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.

Traceback (most recent call last):

File “”, line 26, in

TypeError: expected object, got NoneType

**This is the code:**

```auto
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))

```

Is the reporting error to do with “Autodesk.Revit.DB.Dimension” since this script was created in 2018.

I have no knowledge of Python and any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [March 20, 2023, 4:01pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/2 "2023-03-20T16:01:41Z")

</div>

@kieran.atherton ,

i did test your code just cleaned up and set the right template…

```auto
import clr
import sys
import System

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

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
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

tag = UnwrapElement(IN[0])

output = []

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:
		output.append(doc.GetElement(ui).ToDSType(True))

	else:
		output.append(element.ToDSType(True))
		
OUT = output

```

---

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [March 20, 2023, 4:25pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/3 "2023-03-20T16:25:09Z")

</div>

Thanks for your help Draxl, however, it still doesn’t seem to be reporting the missing rebar tags, this is the error:  
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
Traceback (most recent call last):  
File “”, line 38, in   
NameError: name ‘uId’ is not defined

this is line 38: for ui in uId:

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [March 20, 2023, 4:27pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/4 "2023-03-20T16:27:48Z")

</div>

@kieran.atherton ,

i think there are still some syntext errors

check out this topic

> [@AttributeError: 'List\[object\]' object has no attribute 'id' trying to filter elements](https://forum.dynamobim.com/t/attributeerror-list-object-object-has-no-attribute-id-trying-to-filter-elements/73660/13):
>
> whats your imput? values or elements? Object has no Id. Sounds like the imput is not correct! import System import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import \* from Autodesk.Revit.DB.Structure import \* clr.AddReference('RevitAPIUI') from Autodesk.Revit.UI import \* clr.AddReference('System') from System.Collections.Generic import List clr.AddReference('RevitNodes') import Revit clr.ImportExtensions(Revit.GeometryConversion) clr.ImportExtensions(Revit.Elements) clr.AddRe…

---

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [March 20, 2023, 4:32pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/5 "2023-03-20T16:32:42Z")

</div>

the inputs are elements I think. This is the script I am using  
[RebarCheckUntaggedBars-MultiplePartition.dyn.dyn](https://forum.dynamobim.com/uploads/short-url/lBLVWSLdI5vltym2DNVOr72iG95.dyn) (23.5 KB)

---

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [March 20, 2023, 5:47pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/6 "2023-03-20T17:47:33Z")

</div>

Ive no experience with python so Im not sure what the correct inputs should be

---

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [March 27, 2023, 2:59pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/7 "2023-03-27T14:59:00Z")

</div>

The error in this script is occurring at line 34, and is stating that a `NoneType` object was encountered where an object was expected.

Without additional context, it is difficult to pinpoint the exact cause of the error. However, one possibility is that the `UnwrapElement` function used to retrieve the `tag` parameter may be returning a `NoneType` object, which is causing an error when attempting to access the `TaggedLocalElementId` property on the next line.

To troubleshoot this issue, you may want to try printing out the `tag` object before the loop to ensure that it is a valid object, and checking to make sure that the `UnwrapElement` function is returning the expected type of object. You may also want to double-check that the input passed into the script is of the correct type and format.

Additionally, it may be helpful to check if any other variables or functions used within the loop are returning `NoneType` objects, which could be causing the error on line 34.

This is what Chat gpt gives me, Do I have to edit 1 of the lines so that it only reads none object?

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [March 27, 2023, 3:13pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/8 "2023-03-27T15:13:09Z")

</div>

Very quick glance I’d suggest this bit needs an extra indent

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/f/ef418f815a5f94a97e1797ec572111cbb547cd9c.png)

---

<div class="post-metadata">

**Author:** ![kieran.atherton](https://avatars.discourse-cdn.com/v4/letter/k/5f8ce5/32.png) [@kieran.atherton](https://forum.dynamobim.com/u/kieran.atherton)\
**Post date:** [April 24, 2023, 12:27pm UTC](https://forum.dynamobim.com/t/python-help-untagged-rebar/87560/9 "2023-04-24T12:27:26Z")

</div>

I think ive got it to work:

[RebarCheckUntaggedBars-MultiplePartition2022.dyn](https://forum.dynamobim.com/uploads/short-url/vwaf03RDw0cQlcz0itfi5mzgm45.dyn) (23.6 KB)
