Hi, Dynamo experts!
I’m trying to create a closed line with points and controlled by strings using if else function, but at first I needed to change the numbers in the list,so I created a def function so I can make thing easier(I have lots of them to change), then I want to create another function for the lines, and use the former function I created to trigger the numbers inside.
well it worked if I don’t use def function, why is that? what is wrong with the second node?
Thanks in advance, need help!!
this is my code
center point : (0,0,0)
Gong_Type: string
CD: Number
function a:
def C_F(CD,list1:var)
{
Cai_Deng = [Imperative]
{
if (CD == 1)
{
return = 0.6;
}
elseif (CD == 2)
{
return = 0.55;
}
elseif (CD == 3)
{
return = 0.5;
}
elseif (CD == 4)
{
return = 0.48;
}
elseif (CD == 5)
{
return = 0.44;
}
elseif (CD == 6)
{
return = 0.4;
}
elseif (CD == 7)
{
return = 0.35;
}
elseif (CD == 8)
{
return = 0.3;
}
else
{
return = null;
}
};
result = list1 * Cai_Deng * 3.12;
return = result;
};
function b:
centerfunction(Center_Point,GongType,CD);
def centerfunction(Center_Point:var,GongType:string,CD)
{
LC_P_X = C_F(CD,[-10,-10,-5,-5,5,5,10,10]);
LC_P_Y = C_F(CD,[0,4,4,5,5,4,4,0]);
HC_P_X = C_F(CD,[-4,-4,4,4]);
HC_P_Y = C_F(CD,[5,15,15,5]);
[Imperative]
{
if (GongType == "H_G")
{
return = PolyCurve.ByPoints(
Geometry.Translate(Center_Point,LC_P_X,0,LC_P_Y),true);
}
elseif (GongType == "N_G"||"G_G"||"M_G"||"L_G")
{
return = PolyCurve.ByPoints(
Geometry.Translate(Center_Point,HC_P_X,0,HC_P_Y),true);
}
else
{
return = null;
};
};
};