コード例 #1
0
def createConstraintBySelection(pActive, pType, pSnap, pLock):
    '''
    To allow users to query what is their existing selection
    and base the constraint nature as Maya's Child-first, Parent-later. 

    pActive : True = Constraint On, False = Not On
    pType : Constraint Type
    pLock : True = Locked, False = Not Locked
    '''
    lModels = fb.FBModelList()
    fb.FBGetSelectedModels(lModels, None, True, True)
    for s in lModels:
        print s.Name
    # Here we are doing a check if there are 2 objects in selection, or if != 2, then throw an error window
    lSelectedObj = [
        fb.FBFindObjectByFullName(model.FullName) for model in lModels
    ]
    # If two objects are selected, create the constraint
    if len(lSelectedObj) == 2:
        Con = fb.FBConstraintManager().TypeCreateConstraint(pType)
        Con.Name = "Child-" + str([lModels[0].Name]) + "_to_Parent-" + str(
            [lModels[1].Name]) + "-mToolbox"
        Con.ReferenceAdd(0, lModels[0])
        Con.ReferenceAdd(1, lModels[1])
        if pSnap == True:
            Con.Snap()
        Con.Active = pActive
        Con.Lock = pLock
    # If selection is not 2, error message.
    elif len(lSelectedObj) != 2:
        fb.FBMessageBox(
            "Error", "Can't create constraint, Please select only two objects",
            "OK")
コード例 #2
0
def selected():
    ordered_selected_models = pyfbsdk.FBModelList()
    pyfbsdk.FBGetSelectedModels(
        ordered_selected_models,
        None,  # Search all models, not just a particular branch
        True,  # Get selected (not deselected)
        True,  # Keep selection order
    )
    return ordered_selected_models
コード例 #3
0
ファイル: selection.py プロジェクト: MagNum3dArt/MB-Python
def GetLast():
    selected_objects = sdk.FBModelList()
    sdk.FBGetSelectedModels(selected_objects, None, True, True)
    if len(selected_objects) > 0:
        last_selected_object = selected_objects[-1]
        return last_selected_object
    else:
        sdk.FBMessageBox("Warning:", "Nothing is selected!", "OK")
        return
コード例 #4
0
def ObjCountCheck():
    lSelectedModels = fb.FBModelList()
    fb.FBGetSelectedModels(lSelectedModels, None, True, True)
    lSelectedObj = [
        fb.FBFindObjectByFullName(model.FullName) for model in lSelectedModels
    ]
    if len(lSelectedObj) == 2:
        createConstraintBySelection()
    elif len(lSelectedObj) != 2:
        # Error: just a OK button.
        fb.FBMessageBox("Error: Wrong Number of Objects Selected",
                        "Please select two objects", "OK")
        return
コード例 #5
0
ファイル: scene.py プロジェクト: tpDcc/tpDcc-dccs-mobu
def get_selected_nodes():
    """
    Implements abstract function from scene.VoyagerScene class
    Returns a list with the selected DCCNodes
    :return: (list<gx.dcc.DCCNode>, int)
    """

    selected_nodes = pyfbsdk.FBModelList()

    top_model = None  # Search all models, not just a particular branch
    selection_state = True  # Return models that are selected, not deselected
    sort_by_select_order = True  # The last model in the list was selected most recently
    pyfbsdk.FBGetSelectedModels(selected_nodes, top_model, selection_state,
                                sort_by_select_order)
    selected_nodes_count = selected_nodes.GetCount()

    return selected_nodes, selected_nodes_count