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

MotionBuilder Python Script03 -

作者: Houdinini | 来源:发表于2019-07-19 20:56 被阅读10次
    WATCHING MYSELF
    好快一个周过去了,这个周又学了不少东西,之后可能会多开几个板块来介绍MoBu。在Help & Document中提到了Motionbuilder的文档比较稀少,而最新的一版也是2009年的版本,百度谷歌都很难找到相应的个人文档,于是我便去MotionBuilder SDK Help中翻了一翻,发现相应的例子库还是比较丰富的,我就整理了一下,这几天会优先向大家分享Motionbuilder里面的UI模块!顺便补一下之前PyQt的坑

    一、ArrowButton

    ArrowButton is Arrow with Button

    来看一下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 which shows the FBArrowButton and how to show/hide content
    #
    # Topic: FBArrowButton
    #
    
    from pyfbsdk import *
    from pyfbsdk_additions import *
    
    
    def PopulateLayout(mainLyt):
        anchor = FBAttachType.kFBAttachTop
        anchorRegion = ""
        for i in range(3):
            lytName = "Border" + str(i)
            lyt = FBLayout()
            x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
            y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
            w = FBAddRegionParam(200, FBAttachType.kFBAttachNone, "")
            h = FBAddRegionParam(200, FBAttachType.kFBAttachNone, "")
            lyt.AddRegion(lytName, lytName, x, y, w, h)
            lyt.SetBorder(lytName, FBBorderStyle.kFBStandardBorder, True, True, 1, 0, 90, 0)
    
            arrowName = "ButtonArrow" + str(i)
            x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
            y = FBAddRegionParam(10, anchor, anchorRegion)
            w = FBAddRegionParam(0, FBAttachType.kFBAttachNone, "")
            h = FBAddRegionParam(0, FBAttachType.kFBAttachNone, "")
            mainLyt.AddRegion(arrowName, arrowName, x, y, w, h)
    
            b = FBArrowButton()
            mainLyt.SetControl(arrowName, b)
    
            # important : we set the content AFTER having added the button arrow
            # to its parent layout
            b.SetContent("A layout border" + str(i), lyt, 250, 250)
            anchor = FBAttachType.kFBAttachBottom
            anchorRegion = arrowName
    
        # dummy label to show the layout moves
        x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
        y = FBAddRegionParam(10, FBAttachType.kFBAttachBottom, arrowName)
        w = FBAddRegionParam(100, FBAttachType.kFBAttachNone, "")
        h = FBAddRegionParam(25, FBAttachType.kFBAttachNone, "")
    
        l = FBLabel()
        l.Caption = "Dummy label!"
        mainLyt.AddRegion("DummyLabel", "DummyLabel", x, y, w, h)
        mainLyt.SetControl("DummyLabel", l)
    
    
    def CreateTool():
        # Tool creation will serve as the hub for all other controls
        t = FBCreateUniqueTool("Arrow Button Example")
        PopulateLayout(t)
        ShowTool(t)
    
    
    CreateTool()
    
    
    

    其中有部分注释,就不需要我解释了,拿到编辑器,执行一下试一试,再decomposition and refactor,理解其中函数的意义!

    二、结语

    这里展示了其中的一个例子

    之后我会把整理好的例子集发出来

    同时尽量更新完这个板块

    做到体系化模块化

    同时同步更新其他板块的内容

    共勉!

    相关文章

      网友评论

        本文标题:MotionBuilder Python Script03 -

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