-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add random function for gcode macros. #5219
Conversation
Update fork to master.
Update to upstream master.
Update to upstream master.
… number in the range specified by the parameters. The type of parameters defines the type of the output, if the inputs are doubles then result will be a double and if the inputs are int the output will be in. Uses C++11 random functionality, compiler compatibility on Linux should be checked. Fixes prusa3d#4001.
The thread local storage variables for the random number generator were replaced by an external context variable. Thread local storage is a scarce resource.
Merged, reworked with 7353d8c |
I might be wrong but to me it looks like the Like put this in the Start G-code: Where X should be random and not always 1.27095 |
What platform are you running on? It may well depend on the implementation being used on your device by |
I'm on linux and a friend of mine is on windows. We both get the same number. |
Looks like that might be part of the change @bubnikv made to remove my thread local storage. |
Seems so. I see that in your initial code you've seeded the generator, but that code got removed. :) |
Initializing random generator in PlacholderParser from system clock.
It should be fixed for the G-code generator with 6820921 |
Nice, thank you very much! |
Initializing random generator in PlacholderParser from system clock.
I wanted to use this new feature in the file name, so when exporting the same model twice while testing settings I would not have to always overwrite the old gcode file in the same folder. However I get the error that the random number generator is not available in the filename processing context. I see no practical reason why that limitation should exist, so, can this be changed? |
Adds a
random(min,max)
function for gcode macros. Fixes #4001