Why is my python script making multiple layouts?

Ok so just a heads up, I am very new to scripting so I may ask a lot of questions.

So I want to write a script that makes layouts in gh. So I made this script in the Py Gh component.

“”" Inputs
z = Print to layout Bool
x = Title of new layout Text
y = Rectangles to creat details from Crv
u = List of views for each perspective Text
v = Width of page
w = Height of page
Outputs
a = New layout in Rhino. ?
“”"
if z is None:
z = false

if x is None:
x = (“New Layout”)

if z is True:
Layout = (rs.AddLayout( (x) , (v,w)))


The problem is that whenever I click the button, not even hold it down it makes 16 new layouts instead of 1. Not sure why that is. Does anyone know what could fix this?

u is a list of 4 items, y is 4 lists of 1 item, 4x4 = 16

Thanks! is there a way that I can fix that? They are not referenced in the script yet right? :confused:

This will create your layouts…


addLayoutspy.gh (5.2 KB)

@Japhy
Sweet thank you!
How would you recommend adding details to each layout from rectangles?

There are many examples on the forum

https://discourse.mcneel.com/search?q=%23grasshopper%20add%20detail%20to%20layout

Your amazing! Thanks!