Notifications
Clear all

[Closed] Inverting a spinner value

Is there a quick way to invert a spinner value? Like if the spinner is changed to -0.35, can the variable become 0.35?

I’m using three spinners to establish the distance to offset vert/face data before i export it.


  in coordsys local move tmesh [cg_x,cg_y,cg_z] 
  

I need the cg_z spinner value to be inverted. Doesn’t matter to me if it is updated in the UI…just when the actual move happens.

5 Replies

Times by -1?

Or if you always need a positive value you can use abs() to get the absolute value.

I had tried multipying by negative one first but -.35 becomes -1.35. I’ll give the abs() a whirl and see if that will work though having it be the opposite sign is the most ideal…not necessarily just the positive.

Is there a way to maybe use an if statement to check if its negative and then flip the sign…and vice versa for positive?

Or maybe converting it to a string and removing/inserting the negative sign as the case may be?

Thanks for the help by the way.

As an If statement, you can simply test if your given value is < 0 – if so, you know it’s a negative value.

But multiplying by -1 will give you the correct result – it sounds like perhaps the syntax went a bit awry and instead of multiplying by -1, you just flat out “minused” 1 from the value?

-0.35 * -1

That, in the listening, gives a value of 0.35 for me.

Dan is right. You should be able to just multiply it by -1 and get what you need.