Hello,
Is it possible to create a function in DesignScript with an Imperative block
the variables must be given before the Imperative block (must be declared in the function variables)
I am trying to create the function to avoid copying the code block 1
I get stuck
Thank you in advance for the help
edit:
script
07 aout forum anglais.dyn (29.6 KB)
Cordially
christian.stan
1 Like
Hello @christian.stan
Is that what you’re looking for?
def solide(curves:var[]..[], pt_haut:var[]..[])
{
return [Imperative] {
Coll_Surf = [];
k = DSCore.List.Count(curves);
b = Autodesk.DesignScript.Geometry.Curve.PointAtParameter(curves,0);
Pt_utiles = DSCore.List.AddItemToEnd(b[0],b);
for (i in 0..(k-1)) {
Coll_Surf[i]=Surface.ByPatch(PolyCurve.ByPoints([Pt_utiles[i],
Pt_utiles[i+1], pt_haut],true));
}
Coll_Surf = DSCore.List.AddItemToEnd(Surface.ByPatch(
PolyCurve.ByJoinedCurves(curves)), Coll_Surf);
Solide = Solid.ByJoinedSurfaces(Coll_Surf);
return = Solide;
}
};
07 aout forum anglais.dyn (21.9 KB)
3 Likes
I now understood the trick of positioning the return before the [Imperative] block
Thank you very much, perfect.
and happy birthday by the way
Cordially
christian.stan
2 Likes
Thanks mate
Have fun with DesignScript!
2 Likes