### dist function - how to use it (strange errors)

Posted:

**Thu Feb 07, 2019 3:11 pm**Hi!

Expressions are great and thanks for this forum section but I seem to have problems using them

Very basic expressions work but I wanted to try the functions and got into problems.

I made simple test to make a box x coordinate match distance between two other boxes.

The expression code for box_dist.translate.x is:

Can you please tell me what I am doing wrong?

The errors I get are (comment out the sqrt and uncomment the dist line):

Expression bound on project://box_dist.translate[0] failed to compile:

Line 4 Col -47 - Too few args for function dist

Line 4 Col -49 - Assignment operation has bad type: lifetime_error Error

Too few args???? The manual says two vectors and those are two vectors

Lifetime_error?????

Thank you!

Antti

Expressions are great and thanks for this forum section but I seem to have problems using them

Very basic expressions work but I wanted to try the functions and got into problems.

I made simple test to make a box x coordinate match distance between two other boxes.

The expression code for box_dist.translate.x is:

- Code: Select all
`p1=get_vec3("box_p1.translate");`

p2=get_vec3("box_p2.translate");

d=sqrt((p1[0]-p2[0])^2+(p1[1]-p2[1])^2+(p1[2]-p2[2])^2); # works fine

#d=dist(p1,p2); # does not work, strange errors :o

d

Can you please tell me what I am doing wrong?

The errors I get are (comment out the sqrt and uncomment the dist line):

Expression bound on project://box_dist.translate[0] failed to compile:

Line 4 Col -47 - Too few args for function dist

Line 4 Col -49 - Assignment operation has bad type: lifetime_error Error

Too few args???? The manual says two vectors and those are two vectors

Lifetime_error?????

Thank you!

Antti