美文网首页工具癖
MotionBuilder Python Script13 -

MotionBuilder Python Script13 -

作者: Houdinini | 来源:发表于2019-07-29 20:42 被阅读32次
Rigging!

搞了一天猴,还没搞定,难受

昨天讲了MessageBox的一些内容,今天我们再来看看MotionBuilder中MessageBox的其他内容

一、MessageGetUserValue

获取用户输入数值操作

先来看一下UI效果


UI_FBMessageBox

这里展示了包括 Char、String、Int、Float等用户获取输入,来看一下代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Topic: FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType
#

from pyfbsdk import FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType


# First, let's have a utility function to test the different input types.
def TestMessageBox(pVal, pType):
    # The result from the call will be a tuple containing the index of the
    # button pressed (or -1 in case of error). The second element will be
    # the value entered.
    lRes = FBMessageBoxGetUserValue("Value type: '%s'" % pType, "Value: ", pVal, pType, "Ok")

    # Did the user press 'Ok'?
    if lRes[0]:
        # Show the value entered.
        FBMessageBox("Result", "Value entered: '%s'" % lRes[1], "Ok")
    else:
        # Or tell that there was an error...
        FBMessageBox("Result", "Got an error", "Ok")

    del (lRes)


# The message box does not handle booleans well... let's skip those for now.
# TestMessageBox( True, FBPopupInputType.kFBPopupBool )
# TestMessageBox( False, FBPopupInputType.kFBPopupBool )

# Lets try to get a single character, no default value.
TestMessageBox(None, FBPopupInputType.kFBPopupChar)

# Now with 'X' as a default value.
TestMessageBox('X', FBPopupInputType.kFBPopupChar)

# Now with a string.
TestMessageBox("Default  string value", FBPopupInputType.kFBPopupString)

# Now as if we were asking for a password. No default value for the password.
TestMessageBox(None, FBPopupInputType.kFBPopupPassword)

# An integer...
TestMessageBox(33, FBPopupInputType.kFBPopupInt)

# A float...
TestMessageBox(3.14e3, FBPopupInputType.kFBPopupFloat)

# A double...
TestMessageBox(3.1416, FBPopupInputType.kFBPopupFloat)

# Cleanup.
del (TestMessageBox, FBMessageBoxGetUserValue, FBMessageBox, FBPopupInputType)

一行一行,敲一敲!decomposition and refactor!

二、结语

有什么问题可以留言!

继续!

共勉!

相关文章

网友评论

    本文标题:MotionBuilder Python Script13 -

    本文链接:https://www.haomeiwen.com/subject/xtiirctx.html