# SetParameterByName to wall object in Python

**URL:** <https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497>\
**Category:** Uncategorized\
**Created:** [January 25, 2018, 12:10pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497 "2018-01-25T12:10:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 25, 2018, 12:10pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/1 "2018-01-25T12:10:08Z")

</div>

Hi All,

I have a little question. I have this short Python that does 2 tasks:

- Corrects the level name according to my criteria.
- Assign a determined RebarCoverType to the wall elements collected.

The last task I can’t to get it done, I have this message:.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/2/12fd453f663e2655840410932b4ad2992c96344a.png)

The Code:

```
import clr

clr.AddReference('RevitNodes')
import Revit

#importa el ToProtoType y ToRevitType
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry
from Autodesk.DesignScript.Geometry import *

#Importar el Docuement Manager y Transacciones
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('System')
from System import *

#Importar la API de Revit
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('DSCoreNodes')
from DSCore import *

# Datos de entrada
EntradaTonta = IN[0] #Solo se deja para que funcione el Passthrough.

# Hacer referencia al documento activo.
doc = DocumentManager.Instance.CurrentDBDocument

# Crear un colector de los elementos para ciertas categorias (http://www.revitapidocs.com/2017.1/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm)
collectorLevels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels)
collectorWalls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)
collectorRebarCover = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CoverType)

# Inicia la transaccion
TransactionManager.Instance.EnsureInTransaction(doc)

# Genera una lista con todos los
PisosRevit = []
for i in collectorLevels:
    if not ('LevelType' in str(i)):
        if 'FUNDACION' in i.Name:
            i.Name = 'PLANTA DE FUNDACIONES'
        elif ' ' in i.Name:
            i.Name = (i.Name).Replace(' ', '')

# Finaliza la transaccion
TransactionManager.Instance.TransactionTaskDone()

Muros = []
for i in collectorWalls:
    if not ('WallType' in str(i)):
        Muros.append(i)

RebarCover = []
for i in collectorRebarCover:
    RebarCover.append(i)

# Aplica recubrimientos en todos los elementos muro.
for wall in Muros:
    muro = wall
    muro.SetParameterByName("Rebar Cover - Exterior Face", RebarCover[8])
    muro.SetParameterByName("Rebar Cover - Interior Face", RebarCover[8])
    muro.SetParameterByName("Rebar Cover - Other Faces", RebarCover[8])

OUT = []

```

I know that I’m missing something here, Cold you help me with this please?

Thanks in advance for your time.

Cheers!

---

<div class="post-metadata">

**Author:** ![Tomasz\_Puchala](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Tomasz\_Puchala](https://forum.dynamobim.com/u/Tomasz_Puchala)\
**Post date:** [January 25, 2018, 12:38pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/2 "2018-01-25T12:38:01Z")

</div>

> [@Jorge\_Villarroel](#):
>
> muro.SetParameterByName(“Rebar Cover - Exterior Face”, RebarCover[8])

try:  
muro.LookupParameter(“Rebar Cover - Exterior Face”).Set(RebarCover[8])

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 25, 2018, 1:55pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/3 "2018-01-25T13:55:24Z")

</div>

Thanks @Tomasz_Puchala. Tried what you recommended but this didn’t solve my problem.

Here is the same script, but using the collections trough Dynamo.

[Seteo Inicial.dyn](https://forum.dynamobim.com/uploads/short-url/rQWEjLau9IBBwoh1GpjQbNdJa8J.dyn) (17.9 KB)

This works just fine.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 25, 2018, 5:25pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/7 "2018-01-25T17:25:35Z")

</div>

Thanks, @erfajo! It works like you said. But, I doing the collector to avoid putting the nodes “Categories” and “All Elements of Category”. I want to do this process in Python.  
More similar to what I did in the first post.

Is it possible?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 11:45am UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/10 "2018-01-26T11:45:20Z")

</div>

WOW! Great! Thanks a lot @erfajo . I didn’t know about the “WhereElementIsNotElementType()” method. Also, I think the “ToElements()” was the stumbling rock here. I’ll adjust my script using your recommendations.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 12:19pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/11 "2018-01-26T12:19:36Z")

</div>

Hi @erfajo:

I managed to adjust my code using you directions:

```
import clr

clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitNodes')

#Importar el Docuement Manager y Transacciones
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Revit and Dynamo modules
from Autodesk.Revit.DB import BuiltInCategory, FilteredElementCollector
from RevitServices.Persistence import DocumentManager
import Revit
clr.ImportExtensions(Revit.Elements)

# Datos de entrada
EntradaTonta = IN[0] #Solo se deja para que funcione el Passthrough.

# Hacer referencia al documento activo.
doc = DocumentManager.Instance.CurrentDBDocument

# Crear un colector de los elementos para ciertas categorias (http://www.revitapidocs.com/2017.1/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm)
Niveles = (FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements())
Muros = (FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements())
RebarCover = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CoverType).ToElements()

# Inicia la transaccion
TransactionManager.Instance.EnsureInTransaction(doc)

# Corrige el nombre de los niveles de acuerdo al criterio indicado en el manual.
for i in Niveles:
    if 'FUNDACION' in i.Name:
        i.Name = 'PLANTA DE FUNDACIONES'
    elif ' ' in i.Name:
        i.Name = (i.Name).Replace(' ', '')

# Finaliza la transaccion
TransactionManager.Instance.TransactionTaskDone()

# Aplica recubrimientos en todos los elementos muro.

for wall in Muros:
    muro = wall.ToDSType(True)
    muro.SetParameterByName('Rebar Cover - Exterior Face', RebarCover[8])
    muro.SetParameterByName('Rebar Cover - Interior Face', RebarCover[8])
    muro.SetParameterByName('Rebar Cover - Other Faces', RebarCover[8])

OUT = 'Nombres de pisos corregidos y parametros asignados correctamente.'

```

But now, if I want to assign a RebarCover Type to the corresponding parameter, the error says: “No parameter found by that name”.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/3/03419830d948e3a4a8b3498d4029bf9a5f605a43.png)

This is weird, because If I look for Element.Parameters, I get the desired Parameter.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/2/a2f1abca40f08a1944ef99aee8332049ea091257.png)

Any thoughts?

Thanks in advance for your time.

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 3:47pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/13 "2018-01-26T15:47:15Z")

</div>

Hi,

I don’t think it is a SubCategory issue.

Here I made a simple example. I couldn’t replicate the exact error that I’m witnessing:

[https://drive.google.com/open?id=1orXqYYt8SvyzkWArdRys\_4h5k80NEOHb](https://drive.google.com/open?id=1orXqYYt8SvyzkWArdRys_4h5k80NEOHb)

Now, I’m getting this error:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/4/14d635dd78dedfb2ba5fdfb7f95b86eb6bb430ca.png)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 4:59pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/15 "2018-01-26T16:59:48Z")

</div>

@erfajo I found the missing piece for the “No parameter found by that name” error. The model had some architectural walls which I couldn’t see in my Structural view. This walls didn’t have the “Structural” option enabled, therefore, they didn’t have Rebar Cover parameters.

The solution you recommended was accurate. So, the problem now is the one explained in my previous post. Is the one from the example provided.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/d/ed264f838e89a2814db991465f2feefc092cff43.jpg)

Thanks in advance for your time!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 5:12pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/17 "2018-01-26T17:12:12Z")

</div>

Thanks @erfajo! I really appreciate your help. For me was very illustrative this thread!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 5:14pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/19 "2018-01-26T17:14:11Z")

</div>

My final code is like this:

```
import clr

clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitNodes')
clr.AddReference('RevitAPIUI')

from Autodesk.Revit.UI import TaskDialog

#Importar el Docuement Manager y Transacciones
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Revit and Dynamo modules
from Autodesk.Revit.DB import BuiltInCategory, FilteredElementCollector
from RevitServices.Persistence import DocumentManager
import Revit
clr.ImportExtensions(Revit.Elements)

# Hacer referencia al documento activo.
doc = DocumentManager.Instance.CurrentDBDocument

# Crear un colector de los elementos para ciertas categorias (http://www.revitapidocs.com/2017.1/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm)
Niveles = (FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements())
Muros = (FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements())
RebarCover = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_CoverType).ToElements()

# Inicia la transaccion
TransactionManager.Instance.EnsureInTransaction(doc)

# Corrige el nombre de los niveles de acuerdo al criterio indicado en el manual.
for i in Niveles:
    if 'FUNDACION' in i.Name:
        i.Name = 'PLANTA DE FUNDACIONES'
    elif ' ' in i.Name:
        i.Name = (i.Name).Replace(' ', '')

# Finaliza la transaccion
TransactionManager.Instance.TransactionTaskDone()

# Aplica recubrimientos en todos los elementos muro.

# transformar a elementos de Dynamo
coverTypes = []
for cover in RebarCover:
    coverTypes.append(cover.ToDSType(True))

indice = []
for i in range(len(Muros)):
    muro = Muros[i].ToDSType(True)
    if muro.GetParameterValueByName('Structural') == 1:
        muro.SetParameterByName('Rebar Cover - Exterior Face', coverTypes[8])
        muro.SetParameterByName('Rebar Cover - Interior Face', coverTypes[8])
        muro.SetParameterByName('Rebar Cover - Other Faces', coverTypes[8])
    else:
        indice.append(i)

if indice:
    contador = str(len(indice))
else:
    contador = str(0)

OUT = 'Nombres de pisos corregidos y parametros asignados correctamente. Hay ' + contador + ' muros arquitectonicos! Revisar!'
# OUT = indice

```

Hope it will be useful!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 26, 2018, 5:38pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/21 "2018-01-26T17:38:51Z")

</div>

Thanks for the advice! I’ll keep it in mind.

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [February 15, 2018, 3:39pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/22 "2018-02-15T15:39:41Z")

</div>

Hi @erfajo,

As you suggested this solution (which works just fine!) I’m trying to replicate this procedure directly as a revit plug-inn (C#). I made almost the same, but in this case, it shows me an error saying “the parameter is read-only”.

Do you know why through dynamo I can do it withoput a problem, but through the API I can’t?

This is the thread: [https://forums.autodesk.com/t5/revit-api-forum/rebar-cover-types-collector/m-p/7780511/highlight/false#M28680](https://forums.autodesk.com/t5/revit-api-forum/rebar-cover-types-collector/m-p/7780511/highlight/false#M28680)

Thanks in advance for your time!

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [February 15, 2018, 5:07pm UTC](https://forum.dynamobim.com/t/setparameterbyname-to-wall-object-in-python/18497/24 "2018-02-15T17:07:20Z")

</div>

😄 I understand (I’m also a novice in C# and I think zero-touch nodes is a pretty good start!). I think that maybe is when you transform the object into a Dynamo object when the “read-only” option is disabled. I’m just guessing here…

Hope if someone comes with a proper explanation of this phenomena.

Cheers!
