Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARNING: len() parameter could not be converted, in file scad-utils/trajectory.scad, line 7 #10

Open
dpellegr opened this issue Jun 23, 2019 · 8 comments

Comments

@dpellegr
Copy link

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?

@thomaskilian
Copy link

thomaskilian commented Mar 20, 2020

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.

@dpellegr
Copy link
Author

@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.

@thomaskilian
Copy link

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.

@dpellegr
Copy link
Author

@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.

@thomaskilian
Copy link

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 :-)

@uqs
Copy link

uqs commented Mar 6, 2022

Did anyone find a workaround for this yet? This makes some projects out there unable to render :(

@szero
Copy link

szero commented Mar 9, 2022

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

@drf5n
Copy link

drf5n commented Sep 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants