List.count for list level 2

dynamo

#1

Hi everyone
I am trying to create a mark beam list like image
Someone can help me


#2

I’m not sure what you want to count here. The beams based on the Mark-parameter? :slight_smile:


#3

Hi @CVest
I I have filtered beams of the same length and type and I want to Mark - parameter type it with the same name
Please see result like image


#4

I think Count might be the wrong thing but what he wants is for Element.SetParameterByName to have all of the elements in each nested list to be set to the same value in the DS# list according to the index of the nested list. As in, all of the elements in the first nested list to be DS1, all of the elements in the second nested list to be DS2, etc.

As I don’t have access to your revit project, I can’t test this but you can try this script in a python node:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
elements = IN[0]
paramName = IN[1]
values = IN[2]

for i in range(len(elements)):
	for j in elements:
		j.SetParameterByName(paramName,values[i])
#Assign your output to the OUT variable.
OUT = elements

Use this python script to replace the Element.SetParameterByName node, make sure you increase the inputs on the python node to 3 (up to IN[2]), and connect in the same order. Let me know if it works or if any errors pop up.


#5

Thanks @kennyb6 i will try now!


#6

Sorry, I mistyped one line. Replace for j in elements: to

    for j in elements[i]:

#7

@kennyb6
i try your python but error line 14


#8

What is the error? And is it possible to post your Revit and Dynamo files?


#9

@kennyb6
Please help me
This is .dyn .rvt
Sorry I do not know much about python


V3.dyn (11.2 KB)


#11

I am assuming you are using Revit 2018? I cannot open the file in my 2017, so I cannot fix the python node for you. Can you copy and paste what the error message is in the python node? More than just “on line 14”


#12

I tried this on the sample structural plan that comes with Revit so no promises but I got this to work.
V4.dyn (12.5 KB)


#13

Hello there Bach.

Try doing these changes to your graph:

You can also solve it by using the RIE.IndexDuplicateStrings node:

If you don’t need to keep the list structure, you dont really need the chop node.


Iterating through list
#14

The results are perfect thanks so much @kennyb6


#15

No problem, glad it worked!


#16

Thanks @andre.abotnes for help
I will try adding your way without using python