美文网首页
MotionBuilder Python Script23 -

MotionBuilder Python Script23 -

作者: Houdinini | 来源:发表于2021-06-20 21:37 被阅读0次
    差点彻底断掉

    自从3月份更新了一篇之后就又断掉了,对于现在的UI例子文档只不过是录个gif再贴上官方代码,非常简单的事竟然会持续断更,罪过罪过...

    之后尽量把这套example的代码贴完!

    一、RadioButton

    单选按钮控件

    先看一下UI效果


    Radiobox Example.gif

    再看一下效果实现的代码

    # 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 with radio buttons and show how to manage them with a FBButtonGroup.
    #
    # Topic: FBAttachType, FBButtonStyle, FBButton, FBButtonGroup
    #
    
    from pyfbsdk import *
    from pyfbsdk_additions import *
    
    def BtnRadioCallback(control, event):
        print control.Caption, " has been clicked!"
    
    def PopulateLayout(mainLyt):
        group = FBButtonGroup()
        group.AddCallback(BtnRadioCallback)
        anchor = ""
        attachType = FBAttachType.kFBAttachTop
        
        for i in range(5):
            name = "BtnRadio " + str(i)
            b = FBButton()
            group.Add(b)
            
            b.Caption = name
            b.Style = FBButtonStyle.kFBRadioButton
        
            x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
            y = FBAddRegionParam(10,attachType,anchor)
            w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
            h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
        
            mainLyt.AddRegion(name,name, x, y, w, h)
        
            mainLyt.SetControl(name,b)
                    
            attachType = FBAttachType.kFBAttachBottom
            anchor = name
    
    def CreateTool():    
        # Tool creation will serve as the hub for all other controls
        t = FBCreateUniqueTool("Radiobox Example")
        
        PopulateLayout(t)    
        ShowTool(t)
    
    
    CreateTool()
    

    二、结语

    有问题可以留言~

    共勉!

    相关文章

      网友评论

          本文标题:MotionBuilder Python Script23 -

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