美文网首页程序员工具癖
MotionBuilder Python Script08 -

MotionBuilder Python Script08 -

作者: Houdinini | 来源:发表于2019-07-24 20:00 被阅读1次
中国风AC帅啊!
买了个新键盘,cherry轴敲起来就是舒服啊!

今天我们来看一下怎么实现Motionbuilder中的close事件!

一、CloseTool

How to shut down。

先来看一下UI效果


UI效果

简洁明了直接关掉,来看一下代码:

#!/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.
#
# Script description:
# Create a tool that will create and close a FBPopup
#
# Topic: FBTool
#

from pyfbsdk import *
from pyfbsdk_additions import *


# a Popup is really a layout. It should be populated/initialized
def CloseCallback(control, event):
    CloseTool(globalTool)


def PopulateLayout(mainLyt):
    # create a button on the tool that will show the popup
    b = FBButton()
    b.Caption = "Close Me!"

    x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
    y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
    w = FBAddRegionParam(50, FBAttachType.kFBAttachNone, "")
    h = FBAddRegionParam(25, FBAttachType.kFBAttachNone, "")

    mainLyt.AddRegion("Btn", "Btn", x, y, w, h)
    mainLyt.SetControl("Btn", b)

    b.OnClick.Add(CloseCallback)


def CreateTool():
    # Tool creation will serve as the hub for all other controls
    global globalTool
    globalTool = FBCreateUniqueTool("Close Tool Example")
    globalTool.StartSizeX = 200
    globalTool.StartSizeY = 100
    PopulateLayout(globalTool)
    ShowTool(globalTool)


CreateTool()

简单清晰!

二、结语

有点少

咱们再更新一篇!

相关文章

网友评论

    本文标题:MotionBuilder Python Script08 -

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