Notifications
Clear all

[Closed] Trouble with Comparixon Expressions

Hello all, I am having trouble with a very simple code, I am trying to compare the following:

if $.modifiers[1].gizmo.scale > [1.3,1.3,1.3] do $.modifiers[1].gizmo.scale = [1.3,1.3,1.3]

but I get the following error:
No “”>”” function for [1.20644,1.20644,1.20644]

Strangely enough if I use an == operator and no error is reported, I even tryed the following just as a test

$.scale == [1,1,1]
result:
true

$.scale > [1,1,1]
result:
– No “”>”” function for [1,1,1]

Anybody can help me with this issue?

Thanks in advanced.

5 Replies

Don’t have max open to test, but I think u need to check x, y, and z individually.

if $.modifiers[1].gizmo.scale.x > 1.3 and $.modifiers[1].gizmo.scale.y > 1.3 and $.modifiers[1].gizmo.scale.z > 1.3 do $.modifiers[1].gizmo.scale = [1.3,1.3,1.3]

Hi David,
the error says you cannot use the comparison operator “greater than” and “lesser than” with Point3 values. What does it means?

Scale value is represented by three numbers gathered in a vector of three elements which are scale factor along object axis X, Y, and Z. if you want to make a comparison, you need to perform it at component level like:

local fCapValue = 1.3
local p3GizmoScale = $.modifiers[1].gizmo.scale

if ( (p3GizmoScale.x > fCapValue) or (p3GizmoScale.y > fCapValue) or (p3GizmoScale.z > fCapValue) ) do
    $.modifiers[1].gizmo.scale = [fCapValue, fCapValue, fCapValue]

Or a bit neater version:

local fCapValue = 1.3
local p3GizmoScale = $.modifiers[1].gizmo.scale
local p3TestScale = p3GizmoScale / fCapValue

if ( (p3TestScale.x > 1) or (p3TestScale.y > 1) or (p3TestScale.z > 1) ) do
    $.modifiers[1].gizmo.scale = [1,1,1] * fCapValue

Using “or” or “and” in the if…do statement is up to you. If you want to set the scale value if a single scale factor is bigger than your cap value, use “or”. If you want to set the scale value if all three scale factors are bigger than your cap value, use “and”.

As a final thought, if you are absolutely sure the object is always scaled uniformly, you can limit the test to a single axis, like X, because the other two would be the same.

  • Enrico

p.s.
Solitude beaten me

Yes! it did work, thanks a lot for your help.

Ja yes, Solitude it did work with your advice, Enrico, he did beat you but I apreciate the options you explained will work with them.

thank you both.

 PEN

I’m guessing that you are trying to check if objects have been scaled. If so you might want to have a look at my Reset X Form tool that is for down load on my site.