### Author Topic: Expression quastion  (Read 1403 times)

#### Mishanin

• Newbie
• Posts: 12
##### Expression quastion
« on: December 03, 2019, 08:20:29 AM »
Why this expression doesn't work in evenly distance or evenly count?
return if (XSplineMatID==1,3,8); - (evenly count)
return if (XSplineMatID==1,150,450); - (evenly distance)

How i can get distance between two corner?
« Last Edit: December 14, 2019, 12:58:55 PM by Mishanin »

#### Rokas

• Hero Member
• Posts: 3324
##### Re: MatID expression
« Reply #1 on: December 03, 2019, 10:27:01 AM »
Evenly is special distance. It is calculated once and applied throughout the spline at regular intervals.

Hopefully this technique can be a workaround in Your case.

Hope this helps.
Rokas

#### Mishanin

• Newbie
• Posts: 12
##### Re: MatID expression
« Reply #2 on: December 06, 2019, 09:23:19 AM »
I decided not to create a new theme

Can you explain why it works like this?
I compare the length of the segment with the length of the next segment, but in one segment it does not work correctly.
I suspect that it has something to do with the first vertex spline, but how to solve it i don't know

#### Rokas

• Hero Member
• Posts: 3324
##### Re: MatID expression
« Reply #3 on: December 06, 2019, 01:30:00 PM »
Rokas

#### Mishanin

• Newbie
• Posts: 12
##### Re: MatID expression
« Reply #4 on: December 06, 2019, 01:37:18 PM »
attached below

#### Rokas

• Hero Member
• Posts: 3324
##### Re: MatID expression
« Reply #5 on: December 06, 2019, 01:44:46 PM »

There is no next segment after 4 to compare and determine what to place teapot or a box. So RC ends with comparison= false = Box.

Rokas

#### Mishanin

• Newbie
• Posts: 12
##### Re: MatID expression
« Reply #6 on: December 06, 2019, 01:52:01 PM »
For a closed spline, wouldn't the next segment after 4 be 1?
Why does it work correctly if it is done on a rectangle spline?
Example attached
« Last Edit: December 06, 2019, 01:53:57 PM by Mishanin »

#### Rokas

• Hero Member
• Posts: 3324
##### Re: MatID expression
« Reply #7 on: December 06, 2019, 01:57:25 PM »
add edit spline modifier and check which spline is first:

I attach You the image:

RC checks:
is 1st segment shorter than 2? YES = Teapot
is 2nd segment shorter than 3? NO = BOX
is 3rd segment shorter than 4? YES = Teapot
is 4th segment shorter than 5(?) NO= BOX

P.S. Idea to get 1st segment value added for consideration for next RC versions. I agree it would be useful in similar cases.
« Last Edit: December 06, 2019, 02:09:12 PM by Rokas »
Rokas

#### Mishanin

• Newbie
• Posts: 12
##### Re: MatID expression
« Reply #8 on: December 06, 2019, 02:08:22 PM »
Too bad it doesn't loop the counter. Thanks

#### Mishanin

• Newbie
• Posts: 12
##### Re: MatID expression
« Reply #9 on: December 13, 2019, 09:14:07 PM »
Is it possible to set one random, so that it would be the same for all arrays, but different for splines?
or in another way how to set a different random on subspline?
« Last Edit: December 13, 2019, 10:52:57 PM by Mishanin »

#### Dragan

• Hero Member
• Posts: 1356
##### Re: Expression quastion
« Reply #10 on: December 14, 2019, 03:02:18 PM »
Easy wat to do it is using Selector (but it will not place the same segments on the same mat ID subspline).
For index just use random parameter set to Generate on Xspline section.

#### Mishanin

• Newbie
• Posts: 12
##### Re: Expression quastion
« Reply #11 on: December 16, 2019, 10:25:43 AM »
Not exactly what I wanted.
below is a scene for example

#### Dragan

• Hero Member
• Posts: 1356
##### Re: Expression quastion
« Reply #12 on: December 16, 2019, 03:26:36 PM »
Ah, You are targeting the height of the RC object, right?
If so... then...

#### Mishanin

• Newbie
• Posts: 12
##### Re: Expression quastion
« Reply #13 on: December 16, 2019, 03:41:21 PM »
It should be exactly two arrays

#### Dragan

• Hero Member
• Posts: 1356
##### Re: Expression quastion
« Reply #14 on: December 16, 2019, 04:15:39 PM »