# I have element ids in python - I would now like to SetParameterByName

**URL:** https://forum.dynamobim.com/t/i-have-element-ids-in-python-i-would-now-like-to-setparameterbyname/18471
**Category:** Developers
**Created:** [January 24, 2018, 5:26pm UTC](https://forum.dynamobim.com/t/i-have-element-ids-in-python-i-would-now-like-to-setparameterbyname/18471 "2018-01-24T17:26:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jup](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@jup](https://forum.dynamobim.com/u/jup)
#### Post date: [January 24, 2018, 5:26pm UTC](https://forum.dynamobim.com/t/i-have-element-ids-in-python-i-would-now-like-to-setparameterbyname/18471/1 "2018-01-24T17:26:01Z")

</div>

Hi all,

I am working on a script to change detail numbers of views on sheets. I’m sick of rejigging them and feels like I’m wasting my time doing a repetitive task… So perfect for a little script. I’ve been trying to learn a bit of python so would like to try do it using Pythonically (purely for practice / learning purposes)

So i’ve got to picking the objects (I intend to add a filter for views later … )  
enumerate (starting at 1)

I’m now a little stuck as I have the element ids. However when I try to SetParameterByName I’m getting an exception, “Element Id has no attribute SetParameterByName” - this makes sense i have an id not an object.

I’m sure its a super easy step, but how to i get the object from the id to then change the parameter?

Also before getting the ids i was getting an Autodesk.Revit.DB.Reference , i thought getting the ids would be a good idea, should i have got something else?

Many thanks

J-P

(also i realise i’ve imported way too much - i just wrote them all down one day and copy them in to begin with - not ideal, but convenient)

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

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.DB import * 

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager
from Autodesk.Revit.UI.Selection import ObjectType

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

picked = uidoc.Selection.PickObjects(ObjectType.Element)
objects = [el.ElementId for el in picked]

objects = list(enumerate(objects,1))

for object in objects: 
        object[1].SetParameterByName("Detail Number", object[0])

OUT = objects
```

---

<div class="post-metadata">

### Author: ![Einar\_Raknes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/einar_raknes/32/8566_2.png) [@Einar\_Raknes](https://forum.dynamobim.com/u/Einar_Raknes)
#### Post date: [January 24, 2018, 5:42pm UTC](https://forum.dynamobim.com/t/i-have-element-ids-in-python-i-would-now-like-to-setparameterbyname/18471/2 "2018-01-24T17:42:38Z")

</div>

I think you can get the Element directly from the reference by `doc.GetElement(el )`

---

<div class="post-metadata">

### Author: ![jup](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@jup](https://forum.dynamobim.com/u/jup)
#### Post date: [January 26, 2018, 6:23pm UTC](https://forum.dynamobim.com/t/i-have-element-ids-in-python-i-would-now-like-to-setparameterbyname/18471/3 "2018-01-26T18:23:51Z")

</div>

Thank you Einar
