Hi all,
I guess this is an easy one, but I don’t know it anymore
I need a loop/while that’s start over after 3 values.
In this case I want 8 values:
PV op L1
PV op L2
PV op L3
PV op L1
PV op L2
PV op L3
PV op L1
x = 1
nummers = []
while x < 100:
nummers.append("PV op L"+ str(x))
x += 1
OUT = nummers
here an example with itertools.cycle()
Edit : code fixed
import sys
import itertools
out = []
if IN[0] is not None:
cycle_x=itertools.cycle([1,2,3])
for idx, x in enumerate(cycle_x):
out.append("Toto L{}".format(x))
# 'make break and avoid infinite loop
if idx + 1 == IN[0] or idx > 9999:
break
OUT = out
3 Likes
Hello, I tried like this,
# 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.
b=IN[0]
result=[]
a=[]
# Placer votre code au-dessous de cette ligne
num=(b[0]/3)*range(1,4)
num.append(1)
for i in num:
result.append("Pv op L"+str(i))
# Affectez la sortie à la variable OUT.
OUT = result
I still have work to do
thank you
Cordially
christian.stan
1 Like
hello again, when I copy / paste your code then save revit freeze, it comes from the python version which does not support itertools (I am under revit 2020)
Cordially
christian.stan
Well seen, I guess the IN[0] was null
I fixed my code in previous post
1 Like
@c.poupin @christian.stan thank you both!
It was harder than I thought haha
2 Likes
I had not yet connected in fact, a beautiful nozzle I am thank you
cordially
christian.stan
1 Like
Good evening, a designscript version (there is surely more efficient)
code block:
n;
txt="PV op L";
arr=n%3>0?Math.Floor(n/3):n/3;
Sequence=DSCore.List.Cycle(1..3,arr);
Sup=n-arr*3;
ajout=Sup<=0?null:1..Sup;
serie=DSCore.List.AddItemToEnd(ajout,Sequence);
numb=DSCore.List.Clean(DSCore.List.Flatten(serie));
n<=0?"No List":txt+numb;
Cordially
christian.stan
2 Likes