discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

"unable to convert parameter to a vec3 or vec2" warning meaning?

TP
Torsten Paul
Sun, Sep 29, 2019 3:52 AM

On 29.09.19 05:55, onion wrote:

Unable to convert translate([[9.78], [0.455208], 0])

The extra [ ] are the hint. The rands() function always returns
a vector, even if it's just a single value.

To get just the actual number, you could do something like:

spongeX = rands(0,10,1)[0];

ciao,
Torsten.

On 29.09.19 05:55, onion wrote: > Unable to convert translate([[9.78], [0.455208], 0]) The extra [ ] are the hint. The rands() function always returns a vector, even if it's just a single value. To get just the actual number, you could do something like: spongeX = rands(0,10,1)[0]; ciao, Torsten.
O
onion
Sun, Sep 29, 2019 3:55 AM

hey,

this is probably super basic stuff, but can anyone explain to me what the
warning "Unable to convert translate([[9.78], [0.455208], 0]) parameter to a
vec3 or vec2 of numbers, in file" means? i'm currently trying to generate
shapes at random x/y values to form a texture and i'm using the rand
function. i started with this to see if it would work, and the code threw
back the above warning:

spongeX=rands(0,10,1);
spongeY=rands(0,5,1);

translate([spongeX,spongeY,0]){
cube([10,10,10]);
}

i figure i'm misunderstanding variable types somehow, but i can't find a
more detailed how-to on using rands. i searched around but all i can find is
that error popping up when it shouldn't, not an explanation of what it
means. any advice is super appreciated and sorry if this question has been
answered elsewhere

--
Sent from: http://forum.openscad.org/

hey, this is probably super basic stuff, but can anyone explain to me what the warning "Unable to convert translate([[9.78], [0.455208], 0]) parameter to a vec3 or vec2 of numbers, in file" means? i'm currently trying to generate shapes at random x/y values to form a texture and i'm using the rand function. i started with this to see if it would work, and the code threw back the above warning: spongeX=rands(0,10,1); spongeY=rands(0,5,1); translate([spongeX,spongeY,0]){ cube([10,10,10]); } i figure i'm misunderstanding variable types somehow, but i can't find a more detailed how-to on using rands. i searched around but all i can find is that error popping up when it shouldn't, not an explanation of what it means. any advice is super appreciated and sorry if this question has been answered elsewhere -- Sent from: http://forum.openscad.org/
O
onion
Sun, Sep 29, 2019 4:00 AM

ah, i just solved my own problem. i was omitting this part at the end:
(example code from openscad manual)
// get a single number
single_rand = rands(0,10,1)[0];
echo(single_rand);

second probably dumb question, what purpose does the "[0]" serve?

--
Sent from: http://forum.openscad.org/

ah, i just solved my own problem. i was omitting this part at the end: (example code from openscad manual) // get a single number single_rand = rands(0,10,1)*[0];* echo(single_rand); second probably dumb question, what purpose does the "[0]" serve? -- Sent from: http://forum.openscad.org/
O
onion
Sun, Sep 29, 2019 4:02 AM

thanks!

--
Sent from: http://forum.openscad.org/

thanks! -- Sent from: http://forum.openscad.org/