PDA

View Full Version : -- Unable to convert: undefined to type: Float


ghostlake114
06-07-2008, 11:23 AM
This is the snippet


on alignMinU pressed do
(
local uvsel = uv.getselectedvertices() as array

local mid = 0
mid = amin (for i in uvsel collect (uv.getvertexposition currenttime i).x)

--mid = uvsel.count
mid = mid

undo "Align Min U" on
(
uv.forceupdate false
uv.movex mid
uv.forceupdate true
uv.updateview()
)
)


So problem happen If user dont select any vertices but press the button. The mid variable will become undefined.

I dont know what undefined variable is. I want to add an if command to check mid value is "undefined" or not to go to align Min U.

Thanks for any help

magicm
06-07-2008, 11:58 AM
You can check if the uvsel array contains any vertices by querying its .count property:

on alignMinU pressed do
(
local uvsel = uv.getselectedvertices() as array
if uvsel.count > 0 then
(
local mid = amin (for i in uvsel collect (uv.getvertexposition currenttime i).x)

undo "Align Min U" on
(
uv.forceupdate false
uv.movex mid
uv.forceupdate true
uv.updateview()
)
)
)
Martijn

ghostlake114
06-07-2008, 12:22 PM
Thanks :D

How stupid am I :surprised

CGTalk Moderation
06-07-2008, 12:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.