IF statement

hi;
I have created a code block for the if statement, but when I put a list for the value of x, I don’t get any result.

x;
p = [Imperative]
{
if(x==90)
{return = x+90;
}
else
{
return = x;
}
};

Can someone point out my error?

@outmanechamekh ,

at least it is a workaround :wink:

2 Likes

Thanks for help,
But why the first code does not work.
One more thing I have the same problem with Python script

1 Like

@outmanechamekh ,

nums = IN[0]

OUT = []

for i in nums:
	if i == 90:
		OUT.append(i+90)
	else:
		OUT.append(i)

in a programm language you have to explan each step! at least Python is not asking “why…”

2 Likes

Hello

Code Block:

x;
Nb_item=DSCore.List.Count(x);
z=[];
p=[Imperative]
{
for (i in 0..(Nb_item-1))
	{
		if (x[i]==90)
			{
			z[i]=x[i]+90;
			}
		else
			{
			z[i] =x[i];
			}
	}
	return z;
};

Cordially
Christian.stan

1 Like

@christian.stan ,

where did you get this knowlage, for me its hard to learn, based the recources here… :wink:, is there more to designscript as the guide?

1 Like

Based the recources here and youtube.
I don’t have any other sources or guide. :sweat_smile:

Hello,
I like the work of Mr. Sol Amour (Will stop, he will think that I am a stalker)
+designscript guide
+I try to visualize and understand the scripts of Mr. Vikram Subbaiah
and so many other people (I absorb)

Here is a knowledge slider :wink: (

code block:

[Line.ByStartPointEndPoint(
Point.ByCoordinates(0,0),
Point.ByCoordinates(10,0)),
Line.ByStartPointEndPoint(
Point.ByCoordinates(0,-0.2),
Point.ByCoordinates(0,0.2)),
Line.ByStartPointEndPoint(
Point.ByCoordinates(10,-0.2),
Point.ByCoordinates(10,0.2))];
GeometryColor.ByGeometryColor(
Cylinder.ByPointsRadius(Point.ByCoordinates(0,0),
Point.ByCoordinates(Knowledge*10,0),0.2),
Color.ByARGB(255,0,255,0));

good evening
Cordially
christian.stan

2 Likes

For your python issue your if statement is asking “is this list equal to 90? and is 180?” Because you have a list you will need to iterate over it.

1 Like