Sorting and renumbering doors

Hello,
I need renumbering doors by multiple parameters. I try create dynamo function for sorting and renumbering doors by parameters. I use node SortByFunction but finally I don´t know grupping elements and renumbering it. Can you help me solve this problem, please.
Thank youDoor_sorting_and_renumbering.dyn (12.5 KB)

Hello everybody :slight_smile: ,
I try renumbering doors, but I still have a problem with group similar family parameters. Do you have some ideas about my problem? Thank you dvere okna cad.dyn (12.0 KB)

Hi

do you need to sort the doors by the parameters or filter the doors by the parameters?

Hi,
I need sort and group doors by parameter for correct numbering. Doors with similar parameters has the same number.

Project1.rvt (1.6 MB)

Hi Michal,

I’m using the type name of the doors to establish the door number. In other words if any of the door names form the list doorName in the Imperative Block = the name of the first item from the List.UniqueItems node, then set the Mark parameter value to letter A. The same method is applied for all the remaining items in the List.UniqueItems node.

you can rearrange the numbering system to suit your needs.

RenumberDoors
DesignScript -RenumberDoors .dyn (6.0 KB)

Hope this helps!

@Michal_Nagy try this
image

import clr
from operator import itemgetter

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

lst=IN[0]

w=[UnwrapElement(i).LookupParameter("Ширина").AsDouble()*304.8 for i in lst]
h=[UnwrapElement(i).LookupParameter("Высота").AsDouble()*304.8 for i in lst]
k=[UnwrapElement(i).LookupParameter("Комментарии").AsString() for i in lst]

lst_zip=[i for i in zip(lst,w,h,k)]

lst_sort=sorted(lst_zip , key=itemgetter(1,2,3))

lst_doors=[ [str(i[1])+"x"+str(i[2])+"/"+i[3], i[0]] for  i in lst_sort ]

dict = dict()
for x in lst_doors:
    d = x[0]
    if d in dict:
        dict [d].append(x[1])
    else:
        dict [d] = [x[1]]
check_list = sorted([[k,v] for k,v in dict.items()], key = lambda x: x[0])
for x in check_list:
    for y in x[1]:
        x.append(y)
    x.remove(x[1])

els_list =[i[1:] for i in check_list]

TransactionManager.Instance.EnsureInTransaction(doc)
els_list=[[UnwrapElement(x).LookupParameter("Марка").Set(str(els_list.index(i)+1)) ] for i in els_list for x in i]
TransactionManager.Instance.TransactionTaskDone()

OUT=check_list, els_list

just change some language strings to english:

“Ширина” - “Width”

“Высота” - “Height”

“Комментарии” - “Comments” ?

“Марка” - “Mark” ?

@Renzoj14 @til.shviger guys thank you so much, you are awesome :grinning: It is exactly what I need. But for perfection I have to combine yours scripts together :smile: At first I must sorting by type parameters and than by Revit instance parameters. I am not good in pyton but I´ve try add new sorting string but something is wrong… :thinking: and it is possible add next string in sorting by instance parameter?

import clr
from operator import itemgetter

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

lst=IN[0]

t=[UnwrapElement(i).LookupParameter("Type").AsString() for i in lst]
w=[UnwrapElement(i).LookupParameter("Width").AsDouble()*304.8 for i in lst]
h=[UnwrapElement(i).LookupParameter("Height").AsDouble()*304.8 for i in lst]
k=[UnwrapElement(i).LookupParameter("Comments").AsString() for i in lst]

lst_zip=[i for i in zip(lst,t,w,h,k)]

lst_sort=sorted(lst_zip , key=itemgetter(1,2,3,4))

lst_doors=[ [str(i[1])+"x"+str(i[2])+str(i[3])+"x"+"/"+i[4], i[0]] for  i in lst_sort ]

dict = dict()
for x in lst_doors:
    d = x[0]
    if d in dict:
        dict [d].append(x[1])
    else:
        dict [d] = [x[1]]
check_list = sorted([[k,v] for k,v in dict.items()], key = lambda x: x[0])
for x in check_list:
    for y in x[1]:
        x.append(y)
    x.remove(x[1])

els_list =[i[1:] for i in check_list]

TransactionManager.Instance.EnsureInTransaction(doc)
els_list=[[UnwrapElement(x).LookupParameter("Mark").Set(str(els_list.index(i)+1)) ] for i in els_list for x in i]
TransactionManager.Instance.TransactionTaskDone()

OUT=check_list, els_list

whats name of next parameter ? Type parameter must be first ?

It ist family Type of Door.
Obrazok dvere param

its need a sort like this:

image

yes

import clr
from operator import itemgetter

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

lst=IN[0]

type=[UnwrapElement(i).LookupParameter("Тип").AsValueString() for i in lst]
w=[UnwrapElement(i).LookupParameter("Ширина").AsDouble()*304.8 for i in lst]
h=[UnwrapElement(i).LookupParameter("Высота").AsDouble()*304.8 for i in lst]
k=[UnwrapElement(i).LookupParameter("Комментарии").AsString() for i in lst]

lst_zip=[i for i in zip(lst,type,w,h,k)]

lst_sort=sorted(lst_zip , key=itemgetter(1,2,3,4))

lst_doors=[ ["type:"+str(i[1])+" size:"+str(i[2])+"x"+str(i[3])+"/"+i[4], i[0]] for  i in lst_sort ]

dict = dict()
for x in lst_doors:
    d = x[0]
    if d in dict:
        dict [d].append(x[1])
    else:
        dict [d] = [x[1]]
check_list = sorted([[k,v] for k,v in dict.items()], key = lambda x: x[0])
for x in check_list:
    for y in x[1]:
        x.append(y)
    x.remove(x[1])

els_list =[i[1:] for i in check_list]

TransactionManager.Instance.EnsureInTransaction(doc)
set_list=[[UnwrapElement(x).LookupParameter("Марка").Set(str(els_list.index(i)+1)) ] for i in els_list for x in i]
TransactionManager.Instance.TransactionTaskDone()

OUT=check_list, els_list
2 Likes

Thank you so much, i have wrong string. I go try it. :slightly_smiling_face: