# Help with python code

**URL:** <https://forum.dynamobim.com/t/help-with-python-code/3655>\
**Category:** Packages\
**Created:** [April 6, 2016, 9:33am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655 "2016-04-06T09:33:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirsty\_Hogg](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kirsty_hogg/32/60864_2.png) [@Kirsty\_Hogg](https://forum.dynamobim.com/u/Kirsty_Hogg)\
**Post date:** [April 6, 2016, 9:33am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/1 "2016-04-06T09:33:34Z")

</div>

Can anyone help that understands Python? We have the below code for moving objects from one list of their current coordinates to a new coordinate location based on another list already generated. We have no knowledge of Python programming and are having a lot of trouble working out where the errors are in the code. Dynamo comes up with an error for line 24.

&nbsp;

Any help would be much appreciated.

&nbsp;

![Capture](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/4/484f9b9a2ab68b9e787948c763295db3114ea4a5.png)

---

<div class="post-metadata">

**Author:** ![Gui\_Talarico](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gui_talarico/32/10887_2.png) [@Gui\_Talarico](https://forum.dynamobim.com/u/Gui_Talarico)\
**Post date:** [April 6, 2016, 10:05am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/2 "2016-04-06T10:05:57Z")

</div>

Can you post the code as text (or the definition) as well as the exception message? (shows when you hover over the python component.

---

<div class="post-metadata">

**Author:** ![Paolo\_Emilio\_Serra1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paolo_emilio_serra1/32/12902_2.png) [@Paolo\_Emilio\_Serra1](https://forum.dynamobim.com/u/Paolo_Emilio_Serra1)\
**Post date:** [April 6, 2016, 10:44am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/3 "2016-04-06T10:44:20Z")

</div>

newloc is a list of values, you need a loop to process its items

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [April 6, 2016, 2:08pm UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/4 "2016-04-06T14:08:48Z")

</div>

what did the error say?

---

<div class="post-metadata">

**Author:** ![Chris\_Kay](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@Chris\_Kay](https://forum.dynamobim.com/u/Chris_Kay)\
**Post date:** [April 13, 2016, 8:16am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/5 "2016-04-13T08:16:57Z")

</div>

I have the same problem. The code works with single elements but when its lists I get the following error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. Traceback (most recent call last): File “”, line 20, in AttributeError: ‘list’ object has no attribute ‘ToRevitType’

Any help would be great!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [April 13, 2016, 8:29am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/6 "2016-04-13T08:29:07Z")

</div>

if your input is a list of elements then you have to iterate over it to apply ToDSType() method as it only works on a single element and not on a list. just write a for loop and call ToDSType() on each element.

output = []

for i in someList:

output.append(i.ToDSType())

you could also use map or a lambda but loop is just fine here.

---

<div class="post-metadata">

**Author:** ![Chris\_Kay](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@Chris\_Kay](https://forum.dynamobim.com/u/Chris_Kay)\
**Post date:** [April 20, 2016, 6:18am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/7 "2016-04-20T06:18:10Z")

</div>

Hi Konrad, thank you for your advice.  
I have attempted to create some basic loops to output the data.

I have been unable to apply ToDSType() and ToRevitType() to elements from the within the loop. What variable type should the element be before I can apply one of these methods to the element?

The following code gives me data output, but not exactly what I need as it does not apply itself to the revit model ?

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

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [April 20, 2016, 5:22pm UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/8 "2016-04-20T17:22:02Z")

</div>

Chris,

Please clarify what you mean by “does not apply itself to Revit model”. I am not exactly sure what you wanted to do. Can you just type up a brief description and maybe a few screenshots of what you expected to happen in revit after this code was executed.

---

<div class="post-metadata">

**Author:** ![Chris\_Kay](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@Chris\_Kay](https://forum.dynamobim.com/u/Chris_Kay)\
**Post date:** [April 21, 2016, 3:33am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/9 "2016-04-21T03:33:50Z")

</div>

Konrad,

Once I execute the code nothing happens in the revit model. I was hoping to move families onto walls. Using the code at the top of this discussion I was able to move one family at a time, but not the list of families with the list of vector coordinates I was hoping for. Appreciate your help with this!

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [April 21, 2016, 4:41am UTC](https://forum.dynamobim.com/t/help-with-python-code/3655/10 "2016-04-21T04:41:29Z")

</div>

Hi Chris,

Don’t get this the wrong way, but have you tried using the search bar at the top of the forum?

[http://dynamobim.org/forums/search/python+for+loop/](http://dynamobim.org/forums/search/python+for+loop/)

The results are not always relevant because the built-in search kind of sucks… Still, your question has been asked and answered multiple times already. In fact, I answered a similar question just last week. Even better, consider using a filtered google search. That will yield many relevant existing forum topics:

[http://lmgtfy.com/?q=site%3A+http%3A%2F%2Fdynamobim.org%2Fforums%2Ftopic%2F+for+loop+python](http://lmgtfy.com/?q=site%3A+http%3A%2F%2Fdynamobim.org%2Fforums%2Ftopic%2F+for+loop+python)
