Outputting List of Lists in a Popup Window

I am attempting to output the information from all the conduit runs in a project to a popup window. I have the pop up window working and can input information to it. I just can’t figure out how to get two list of lists to print out.

Currently I have to code completed to make a list of lists for each Conduit Run (list outrun) and a list of lists for each section in the Conduit Run (list combined).

The output of outrun + combined is in a screenshot below.

I am wanting to print out the Conduit Run then underneath it the sections in that run then the next run with sections, etc.

I’m having a hard time finding information on how to access lists inside of a list.

I think I want to do a for loop to go through each list and print out the information. I’m just not sure how to do that in a way that it outputs to the popup window. I attempted to put a for loop inside ‘TaskDialog.Show’ but that isn’t allowed.

I appreciate any help on pointing me in the right direction.


Here is the code. I forgot to seperate it when I posted.

import clr
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import TaskDialog

TotalCount = IN[0]
TotalLength = IN[1]
ids = IN[2]
TotalBends = IN[3]
RunSegLengths = IN[4]
RunSegments = IN[5]
i = 0 #Total Run Count
j = 0 #Total Segments
count = IN[6] - 1
out = []
outrun = []
tempsegment = []
combined = [] #all segments combined
test = []

for run in ids:
	id = str(ids[i])
	length = str(TotalLength[i])
	bend = str(TotalBends[i])
	segments = str(RunSegments [i])
	out.insert(i, 'RUN ' + id + ': IS ' + length + ' LONG, WITH ' + bend + ' DEGREES OF BENDS' '\n')
	segs = RunSegments[j]
	outrun.append(out)
	out = []
	x = 0
	while x < segs:
		len = str(RunSegLengths[j][x])
		n = str(x)
		tempsegment.append('SEGMENT: ' + n + ': IS ' + len + ' LONG' '\n')
		x += 1
	combined.append(tempsegment)	
	tempsegment =[]
	j += 1
	i =+ 1

#outs = ''.join(out)
#outseg = ''.join(tempsegment)

TaskDialog.Show('Conduit Segment Length', 
'Total of '+ TotalCount + ' Conduit Runs:' 
'\n' )
#+ outs + outseg

OUT = outrun + combined

I figured out a work around, but had to output lists from a Python Scripting node and use some Dynamo nodes and use another Python Script node to display popup window.

For the popup I have two different options using Windows.Forms or using the Revit.UI TaskDialog. Since this is a test project with only two runs I am leaning more towards Windows.Forms because I don’t know how the Revit.Ui TaskDialog will work when there starts being more information being
output.

The code for the Python Script from the ‘Creates lists of the Runs and Segments for output in next step.’

import clr
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import TaskDialog

TotalCount = IN[0]
TotalLength = IN[1]
ids = IN[2]
TotalBends = IN[3]
RunSegLengths = IN[4]
RunSegments = IN[5]
i = 0 #Total Run Count
j = 0 #Total Segments
count = IN[6] - 1
out = []
outrun = []
tempsegment = []
combined = [] #all segments combined
test = []

for run in ids:
	id = str(ids[i])
	length = str(TotalLength[i])
	bend = str(TotalBends[i])
	segments = str(RunSegments [i])
	out.insert(i, '  RUN ' + id + ': IS ' + length + ' LONG, WITH ' + bend + ' DEGREES OF BENDS' '\n')
	segs = RunSegments[j]
	outrun.append(out)
	out = []
	x = 0
	while x < segs:
		len = str(RunSegLengths[j][x])
		n = str(x)
		tempsegment.append('    -SEGMENT: ' + n + ': IS ' + len + ' LONG' '\n')
		x += 1
	combined.append(tempsegment)	
	tempsegment =[]
	j += 1
	i =+ 1

#outs = ''.join(out)
#outseg = ''.join(tempsegment)

#TaskDialog.Show('Conduit Segment Length', 
#'Total of '+ TotalCount + ' Conduit Runs:' 
#'\n' )
#+ outs + outseg

OUT = [outrun,combined]

Python Script - Out 2 : Code (Revit.UI TaskDialog

import clr
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import TaskDialog

runoutput = IN[0]
TotalCount = IN[1]
out = ''.join(runoutput)

TaskDialog.Show('Conduit Segment Length', 'Total of '+ TotalCount + ' Conduit Runs:' '\n' + out)

Python Script - Out 1: Code (Windows.Forms)

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form,Label,FormStartPosition

runoutput = IN[0]
TotalCount = IN[1]
out = ''.join(runoutput)

def popup(text):
	form = Form()
	form.StartPosition = FormStartPosition.CenterScreen
	form.Width = 700
	form.Height = 700
	form.Text = 'Conduit Lengths'	
	label = Label()
	label.Text = text
	label.Width = 650
	label.Height = 650
	label.Parent = form	
	form.ShowDialog()
	
Text = 'Total of '+ TotalCount + ' Conduit Runs:' + '\n' + out

popup(Text)

If any one has any idea how to do this more efficiently I would appreciate the help. Or any advice at all on what I did.

1 Like

Is there a way to have a scroll-able window(popup)?

Either with Revit(Task.Dialog) or Windows Forms.

For my tests I have only had a handful of conduit runs, but on an actually project I will have alot more and will need a way to scroll through them.

I found out that the scroll bar automatically appears when you have enough content to fill the screen with the Revit Task.Dialog. So that is good.

But is there a way to set the size of the task dialog? Like there is with the Windows Forms.

Right now it stretches from the top of the screen to the bottom.

Hi djforeman, I was hoping to use a similar method what you have done here, except I can´t make it to work.
In the end of my graph I get a simple list of doors that I want to show up on a dialog message, but I fail to understand how you define the output in your first Python script for the second Python script?

Sorry I didn’t reply, but in my example I was using two different popup boxes. The first was the Revit TaskDialog and the second was a Windows form.

Which one were you wanting help with?

I’m not expert, but can try to explain what I know.