Float compare problem

Hello people,

i have the following script:

rollout SelectVertexTool "SelectVertexTool" width:204 height:276
(
groupBox grp1 "Select Vertex Tool" pos:[8,8] width:188 height:260
editText Lz "" pos:[80,33] width:110 height:24
label lbl1 " Z" pos:[19,37] width:56 height:19
editText Lx "" pos:[80,64] width:110 height:24
label lbl2 " X" pos:[19,68] width:56 height:19
editText Ly "" pos:[80,95] width:110 height:24
label lbl3 " Y" pos:[19,99] width:56 height:19
button btn1 "DO!" pos:[24,144] width:160 height:104

on btn1 pressed do
(
zValue = Lz.text as float
xValue = Lx.text as float
yValue = Ly.text as float
zValue=zValue
local vert_selection = #{}
local base_obj = $.baseobject
local num_verts = polyop.getNumVerts base_obj

if Lz.text != "" do (
for f = 1 to num_verts do
(
vert_pos = polyop.getVert base_obj f
vert_posZ = vert_pos.z as float
vert_posZ = vert_posZ
print vert_posZ
if zValue == vert_posZ do (
print "asdsadasdasd"
vert_selection[f] = true
)
)
print zValue
)
if Lx.text != "" do (
for f = 1 to num_verts do
(

vert_pos = polyop.getVert base_obj f
vert_posX = vert_pos.x as float
if vert_posX == xValue do (
vert_selection[f] = true
)
)
)

if Ly.text != "" do (
for f = 1 to num_verts do
(
vert_pos = polyop.getVert base_obj f
vert_posY = vert_pos.y as float
if vert_posY == yValue do (
vert_selection[f] = true
)
)

)
polyop.setVertSelection base_obj vert_selection
max modify mode
modPanel.setCurrentObject base_obj
subobjectlevel = 1
)
)

VTool = newRolloutFloater "SelectVertexTool" 225 300
addrollout SelectVertexTool VTool

The problems is that the comparisation does not work.
If the vertex position is for example 3.3631, and i put that in the textbox. the if does not seem to get that the two values are the same.
value 0.0 works

i have tried everything but i'm getting kinda hopeless...

perhaps any1 can help me out..

Many thanks in advance

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
martinskinner's picture

Check your system units. Hi,

Check your system units.

Hi, I had look at your script and tried it out. I had a little trouble at first too.

I think it's a unit miss-match. So i did the good old
b = box() -- this creates a box 25 units square
as my object, calapsed it to a poly, and then tried entering 25.0 in your Z edittext and hitting GO!, it worked fine; selecting the top verts at suboject level.

Return your units type to generic and they should match up.

Hope this was of help.

Martin

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.