Пример #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 debugDialog(self, msg, *args, **kwargs):
        """
        Log 'msg % args' with severity 'DEBUG'.

        To pass exception information, use the keyword argument exc_info with
        a true value, e.g.

        logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
        """
        print "Using PCSlogging subclass"

        if self.isEnabledFor(DEBUGDIALOG):
            self._log(DEBUG, msg, args, **kwargs)

            title = 'logger.debugDialog'
            if len(args) > 1:
                title = args[1]
            try:
                from maya import cmds

                result = cmds.confirmDialog(t=title,
                                            m=msg,
                                            b=['OK', 'Cancel'],
                                            db='OK',
                                            cb='Cancel',
                                            ds='Cancel')
                if result == "Cancel":
                    print "*** Canceled ***"
                    sys.exit()
            except RuntimeError:
                import pyfbsdk

                pyfbsdk.FBMessageBox(title, msg, "OK")
            finally:
                print "Not in Maya or MoBu?"
Пример #3
0
def Get(model = None):
    if model:
        name = ln.Split(model.LongName)[-1]
        return name
    else:
        sdk.FBMessageBox( "Warning:", "There is NO object to get it's Name!", "OK" )
        return
	def __init__( self ):
		# check the selection
		self.selection = vmobu.core.get_selection_order( )
		if self.selection and len( self.selection ) > 1:
			result = self.main( )
			if result:
				pyfbsdk.FBMessageBox( 'One Point Constraint', 'Success! Be sure to resolve this constraint before exporting etc as to not break our hierarchy!', 'OK' )
		else:
			vmobu.core.confirm_dialog( title = 'One Point Constraint Error', message = 'Please selection two objects to constrain together.', button_one_label = 'OK')
Пример #5
0
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
Пример #6
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
Пример #7
0
def setup():
    """
    adds package to python folder in motionbuilder
    """
    package_path = this_path("AnimIO")
    python_path = pyfbsdk.FBSystem().GetPythonStartupPath()[0]
    dest_path = os.path.join(python_path, "AnimIO")

    # remove dir if exists to reinstall
    if os.path.exists(dest_path):

        result = pyfbsdk.FBMessageBox("Reinstall", "Reinstall AnimIO?", "Ok",
                                      "Cancel")

        if result == 1:
            shutil.rmtree(dest_path)
        else:
            raise RuntimeError("AnimIO not reinstalled!")

    shutil.copytree(package_path, dest_path)

    pyfbsdk.FBMessageBox("Installed", "AnimIO has been installed", "Ok")
	def main( self ):
		# Unpack the selection
		child = self.selection[ 0 ]
		parent  = self.selection[ 1 ]

		# Check to see if a OPC constraint is already controlling this obj.
		existing_constraint = vmobu.core.get_object_by_name( 'OPC_{0}'.format( child.LongName ), use_namespace=True, case_sensitive=False, models_only=False, single_only=True )
		if existing_constraint:
			pyfbsdk.FBMessageBox( 'One Point Constraint Error', 'There is already a one point constraint applied to {0}. \n Resolve this constraint before continuing!'.format( child.LongName ), 'OK' )
			return False

		# Create the null
		null = self.create_null( child )
		# Constrain the null to the parent in the selection
		vmobu.core.create_constraint_parent( null, parent, name = 'OPC_{0}'.format( child.LongName ), snap = True )
		vmobu.core.unselect_all_components( )

		# Parent the child to the null
		child.Parent = null

		return True
Пример #9
0
    def infoDialog(self, msg, *args, **kwargs):
        """
        Log 'msg % args' with severity 'INFO'.

        To pass exception information, use the keyword argument exc_info with
        a true value, e.g.

        logger.info("Houston, we have a %s", "thorny problem", exc_info=1)
        """
        print "Using PCSlogging subclass"

        if self.isEnabledFor(INFODIALOG):
            self._log(INFO, msg, args, **kwargs)

            title = 'logger.infoDialog'
            if len(args) > 1:
                title = args[1]
            try:
                # noinspection PyUnresolvedReferences
                import maya.cmds

                result = maya.cmds.confirmDialog(t=title,
                                                 m=msg,
                                                 b=['OK', 'Cancel'],
                                                 db='OK',
                                                 cb='Cancel',
                                                 ds='Cancel')
                if result == "Cancel":
                    print "*** Canceled ***"
                    sys.exit()
            except ImportError:
                import pyfbsdk

                pyfbsdk.FBMessageBox(title, msg, "OK")
            finally:
                print "Not in Maya or MoBu?"