scad-utils
scad-utils copied to clipboard
WARNING: len() parameter could not be converted, in file scad-utils/trajectory.scad, line 7
Hi, the latest OpenSCAD version produces the warning above, for example when running the list-comprehension-demos/toothed-belt.scad
I thought that to be be trivially fixable, but I have found the following behavior hard to grasp:
vec_is_undef([1,2,3,undef], index_=3) == true
vec_is_undef([1,2,3,undef,4], index_=3) == false
What is the rationale behind that? Do we actually need it?
I have a similar issue (but in my own scad file). Using the old SCAD does not croak. Too bad since the "compiler warnings" are not really present in the old version compared to the new one.
@thomaskilian Please note that this is not the OpenSCAD repository, but the one of library scad-utils. If you have issues in your own scad file, than the right place to ask is the OpenSCAD forum showing your own code.
Oops. I got here by Google and it just looked as being the right place. Anyhow, seems to be a general issue with the new OpenSCAD.
@thomaskilian Plenty of times it can easily be resolved. In this specific case of scad-utils it is not so obvious (at least to me) how to adjust the code.
Well, it might give me the kick to go on with my "Python-SCAD-Pre-Compiler" where I can overcome the many limits of OpenSCAD. From a compiler construction view this language is sub-optimal. Well, it's free so no one to blame :-)
Did anyone find a workaround for this yet? This makes some projects out there unable to render :(
its because len() function can be used on string variables only now, before it returned length of other types too, quickfix is to convert any variable into string before using len on it as such len(str(x)), here are lines in question that are wrong in trajectory module: Line 4 and Line 7
Looking at the examples from https://en.wikibooks.org/w/index.php?title=OpenSCAD_User_Manual/Mathematical_Functions&stable=0#len the len(str(x)) workaround isn't good:
a=6; len_a=len(a);
echo(a,len_a);
x=6; len_x=len(str(x));
echo(x,len_x);
y=66; len_y=len(str(y));
echo(y,len_y);
WARNING: len() parameter could not be converted in file , line 1
ECHO: 6, undef
ECHO: 6, 1
ECHO: 66, 2