How to make a local variable not point at attribute?

   907   1   0
User Avatar
Member
2 posts
Joined: April 2019
Offline
Hello! I am experiencing very strange behavior from the “iteration” metadata in a basic for loop block.

I am running pointwrangle over 100 points (see example images for the super simple setup). I use “iteration” metadata as an incremental value. Super simple, right?

But when I set a local variable equal to “iteration” detail attribute, and then I divide that local variable by a number to scale the iteration value, I start to lose points in the output entirely!!

In example image 1, My scaling value is set to 1. And I get all 100 points as a result.

In example image 2, My scaling value is set to 10, and I only get every 10th point back!

The only reason I can think that this would happen is if, when setting the local variable to the value of the detail attribute, I am actually pointing at the detail attribute itself. And so when I scale, I am dividing the actual detail attribute.

How do I make it stop doing this, and return 100 points every time?

Attachments:
example_1.jpg (233.6 KB)
example_2.jpg (266.5 KB)

User Avatar
Member
2038 posts
Joined: Sept. 2015
Online
Well, not looking at your code entirely…did you want your ‘time’ float variable to actually have ‘fractional’ values?

Because Your dividing an integer by an integer before assigning, so your getting rounded off values, and as a consequence some points will be sharing the same position - So your really not ‘losing’ them.

Either change one of the numerator or denominator values to a float by typcasting, or any other way. e.g.

float time = float(counter)/scalar;
Edited by BabaJ - Aug. 27, 2020 21:38:46
  • Quick Links