I am starting with Python so I have to still learn a lot:)
I have my input:
a list with areas of rectangles
sliders with width and length.
I would like to create many rectangles with different dimensions that have the same areas as the areas in the list.
As output, I would like to get width and length which meets the condition W*L=rooms area
Have you thought approaching this from the other way around?
Let’s say you want to create a rectangle with an area of 20 m2 but with random lengths.
You could simply create a shuffled list of x amount of items for the amount of rectangle you want.
Then from there simply do 20/x for each item to determine its width (assuming x is the height).
# Charger les bibliothèques DesignScript et Standard Python
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
Area_Room=IN[0]
Width=IN[1]
Lenght=IN[2]
Result=[]
# Placer votre code au-dessous de cette ligne
for i in Area_Room:
if i == Width*Lenght:
Result.append({"Surface good":i})
else :
Result.append("Change Width or Lenght")
# Affectez la sortie à la variable OUT.
OUT = Result
Script 2 with ratio:
# Charger les bibliothèques DesignScript et Standard Python
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
Area=IN[0]
Ratio=IN[1]
Width=[]
Lenght=[]
# Placer votre code au-dessous de cette ligne
for i in Area:
L=round((i/Ratio)**0.5,3)
W=round(L*Ratio,3)
Lenght.append(L)
Width.append(W)
# Affectez la sortie à la variable OUT.
OUT = {"Lenght":Lenght,"Width":Width}