# Renumbering with filters

**URL:** <https://forum.dynamobim.com/t/renumbering-with-filters/1011>\
**Category:** Packages\
**Created:** [February 3, 2015, 6:37am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011 "2015-02-03T06:37:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Turner](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@James\_Turner](https://forum.dynamobim.com/u/James_Turner)\
**Post date:** [February 3, 2015, 6:37am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/1 "2015-02-03T06:37:40Z")

</div>

Hi

I’ve been tasked with setting out approximately 10k foundation piles. I have the coordindates sorted, however, the subscription tools only allow renumbering from survey origin. I have been asked to number the piles from where the contractor is starting to drive from.

I have also been asked to separate a portion of the building which is sequenced first.

This is the first time that I’ve done any programming, and looking through the clockworks package, I can see that something similar has been achieved. I have recreated the script, with the inclusion of some parameter filters (shared parameter for zone, shared parameter for foundation type).

The script selects the correct piles, however the listing function at the end is throwing up errors - any help on this would be greatly appreciated. At the moment, I’m using the unique element ID to number the piles, but the sequence isn’t logical for the schedules.

![Office_Pile_Foundation](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/9/99daceffd2a2e67dfe372523115a9c81f28e53a2.png)

&nbsp;

&nbsp;

&nbsp;

&nbsp;

Thanks in advance

&nbsp;

James

---

<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:** [February 4, 2015, 4:24am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/2 "2015-02-04T04:24:35Z")

</div>

Someone might be able to help if you share what the error is 🙂

---

<div class="post-metadata">

**Author:** ![James\_Turner](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@James\_Turner](https://forum.dynamobim.com/u/James_Turner)\
**Post date:** [February 4, 2015, 4:53am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/3 "2015-02-04T04:53:27Z")

</div>

Apologies

The error is in the sort list of lists function. The list created prior to this works fine. Due to the first “sort list of lists” failing (sorting the X value of the points), the second “sort list of lists” (sorting Y value of the points) cannot function.

&nbsp;

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [February 4, 2015, 5:07am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/4 "2015-02-04T05:07:21Z")

</div>

The problem is not with the List.SortListOfLists node. The nested list you are passing into it does not have the expected format, because the **first** sublist only contains a **single item** (the result of your **List.Count** operation). It looks like the result you want to get is a list of sorted indices, so you would have to pass a **list of indices** into the first sublist. Have a look here how to do that: [http://dynamobim.com/forums/topic/list-data-converting/](http://dynamobim.com/forums/topic/list-data-converting/)

---

<div class="post-metadata">

**Author:** ![James\_Turner](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@James\_Turner](https://forum.dynamobim.com/u/James_Turner)\
**Post date:** [February 4, 2015, 7:25am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/5 "2015-02-04T07:25:32Z")

</div>

Thanks

We’ve added the code block, this fixes the “List.SortListOfLists” for both the X & the Y sort, and correctly feeds the “list.FirstItem”.

However, the “Element.SetParameterByName” node inst reading the sorted list as an acceptable input to the element.

Does the list function maintain a relationship with the item in the list and the element’s identification?

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [February 4, 2015, 7:52am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/6 "2015-02-04T07:52:25Z")

</div>

My first guess:

Mark is usually a text parameter. The indices are numbers. Try converting them into strings.

---

<div class="post-metadata">

**Author:** ![jostein\_olsen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jostein_olsen/32/8570_2.png) [@jostein\_olsen](https://forum.dynamobim.com/u/jostein_olsen)\
**Post date:** [February 4, 2015, 3:47pm UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/7 "2015-02-04T15:47:35Z")

</div>

I fiddled with this and managed to get some form of definition going. I couldn’t quite understand your List.SortListofLists node, Andreas, but I couldn’t see that you used the “itemgetter” from the “operator” module? I think you can skip the double List.SortListofLists node if you use that.  
The way my definition works now it is sorted one way or the diagonal opposite. I hope some other Python gurus can do better so one can sort it anyway possible! 🙂 Element.SortByXYZ in Clockwork maybe?

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

---

<div class="post-metadata">

**Author:** ![James\_Turner](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@James\_Turner](https://forum.dynamobim.com/u/James_Turner)\
**Post date:** [February 5, 2015, 7:15am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/8 "2015-02-05T07:15:33Z")

</div>

Thanks!!

This has fixed the problem pretty much completely. It would be nice to be able to sort from different directions, but this will be great for now.

---

<div class="post-metadata">

**Author:** ![Timon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/timon/32/12035_2.png) [@Timon](https://forum.dynamobim.com/u/Timon)\
**Post date:** [April 10, 2015, 10:58am UTC](https://forum.dynamobim.com/t/renumbering-with-filters/1011/9 "2015-04-10T10:58:16Z")

</div>

It’s great to see similar code… thanks for the “sorted” python snippet.

Before your suggestion (did not sort X and Y)

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

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

After your suggestion implemented:

![StructuralColumnAssignMarkXYsorted](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/1/1539b2c9e58ec9eed07889e700da1599a174330e.png)

&nbsp;

&nbsp;

&nbsp;

Thanks for the snippets and conversation!
