Esempio n. 1
0
	def testFullPathName( self ) :

		node = maya.cmds.createNode( "ieOpHolderNode" )
		fnPH = IECoreMaya.FnParameterisedHolder( node )
		self.assertEqual( node, fnPH.fullPathName() )

		procedural = maya.cmds.createNode( "ieProceduralHolder" )
		fnPH = IECoreMaya.FnParameterisedHolder( procedural )
		self.assertEqual( maya.cmds.ls( procedural, long=True )[0], fnPH.fullPathName() )
    def testBoxDefaultValue(self):

        node = maya.cmds.createNode("ieOpHolderNode")
        fnPH = IECoreMaya.FnParameterisedHolder(node)

        op = IECore.ClassLoader.defaultOpLoader().load("parameterTypes", 1)()
        op.parameters().removeParameter("m")  # no color4f support in maya

        fnPH.setParameterised(op)

        node, plug = fnPH.parameterPlugPath(op["s"]).split(".")
        self.assertEqual(
            maya.cmds.attributeQuery(plug + "Min", listDefault=True,
                                     node=node), [-1.0, -1.0])
        self.assertEqual(
            maya.cmds.attributeQuery(plug + "Max", listDefault=True,
                                     node=node), [1.0, 1.0])

        node, plug = fnPH.parameterPlugPath(op["t"]).split(".")
        self.assertEqual(
            maya.cmds.attributeQuery(plug + "Min", listDefault=True,
                                     node=node), [-1.0, -1.0, -1.0])
        self.assertEqual(
            maya.cmds.attributeQuery(plug + "Max", listDefault=True,
                                     node=node), [1.0, 1.0, 1.0])
    def __drawHeaderParameterControls(self, formLayout, attachForm,
                                      attachControl, lastControl, uiKey):

        fnPH = IECoreMaya.FnParameterisedHolder(self.__vectorParent().node())
        for parameter in self.__parameter.values():

            forHeader = False
            with IECore.IgnoredExceptions(KeyError):
                forHeader = parameter.userData()["UI"][uiKey].value

            if forHeader:

                control = self.__drawHeaderParameterControl(parameter, fnPH)

                if control:

                    attachForm += [
                        (control, "top", 0),
                        (control, "bottom", 0),
                    ]
                    attachControl += [
                        (control, "left", 0, lastControl),
                    ]

                    lastControl = control

        return lastControl
def copyClass( plugPath, parentPlugPath ) :

	global _ieCoreParameterClipboardUIBuffer
	global _ieCoreParameterClipboardUILastParameterList
	global _ieCoreParameterClipboardUILastNode
	global _ieCoreParameterClipboardUILastRoot
	
	parts = plugPath.split( "." )
	fnPh = IECoreMaya.FnParameterisedHolder( parts[0] )
	parameter = fnPh.plugParameter( plugPath )
	parent = fnPh.plugParameter( parentPlugPath )

	# We need to make sure that the values in the parameterised are in sync
	fnPh.setParameterisedValues()
	
	# This bit is slightly irritating, but we have to get all 
	# The child parameters of the target class, so we only save that one
	paramList = []
	__getParameters( parameter, paramList )
	_ieCoreParameterClipboardUIBuffer = IECore.BasicPreset( fnPh.getParameterised()[0], parent, paramList )
	
	# For now, we only support pasting values linked. Otherwise, we'd have to go find
	# any classes we instantiated to know their plug prefix...
	_ieCoreParameterClipboardUILastParameterList = None
	_ieCoreParameterClipboardUILastNode = None
	_ieCoreParameterClipboardUILastRoot = None
Esempio n. 5
0
    def __defaultFileDialogCallback(self, selection):

        if selection:

            self.parameter.setValue(IECore.StringData(selection[0]))
            fnPH = IECoreMaya.FnParameterisedHolder(self.node())
            fnPH.setNodeValue(self.parameter)
Esempio n. 6
0
	def __labelPlugPath( self ) :
	
		if "label" in self.__parameter :
			fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() )
			return fnPH.parameterPlugPath( self.__parameter["label"] )
			
		return ""
    def test(self):

        node = maya.cmds.createNode("ieOpHolderNode")
        fnPH = IECoreMaya.FnParameterisedHolder(node)
        self.assertEqual(fnPH.getParameterised(), (None, "", 0, ""))

        op = TestOp()
        fnPH.setParameterised(op)
        parameterisedTuple = fnPH.getParameterised()
        self.assert_(parameterisedTuple[0].isSame(op))
        self.assertEqual(parameterisedTuple[1:], ("", 0, ""))
        self.assertEqual(parameterisedTuple[0](), IECore.IntData(10))

        iPlug = fnPH.parameterPlug(op["i"])
        self.assert_(isinstance(iPlug, maya.OpenMaya.MPlug))
        self.assert_(iPlug.asInt(), 1)

        self.assert_(fnPH.plugParameter(iPlug).isSame(op["i"]))
        self.assert_(fnPH.plugParameter(iPlug.name()).isSame(op["i"]))

        iPlug.setInt(2)
        fnPH.setParameterisedValue(op["i"])
        self.assert_(op["i"].getNumericValue(), 2)

        op["i"].setNumericValue(3)
        fnPH.setNodeValue(op["i"])
        self.assert_(iPlug.asInt(), 3)

        iPlug.setInt(10)
        fnPH.setParameterisedValues()
        self.assert_(op["i"].getNumericValue(), 10)

        op["i"].setNumericValue(11)
        fnPH.setNodeValues()
        self.assert_(iPlug.asInt(), 11)
    def _setClass(self, parameterName, className, classVersion):

        fnPH = IECoreMaya.FnParameterisedHolder(self.node())

        # We have to remove this class from the UI first, or, if the parameter list changes,
        # maya can crash as it tries to redraw the AE. See the notes at the top.
        classesWithoutThis = [
            c[1:] for c in self.parameter.getClasses(True)
            if c[1] != parameterName
        ]
        self.__updateChildUIs(classesWithoutThis)

        classes = [c[1:] for c in self.parameter.getClasses(True)]
        if parameterName:
            foundParameter = False
            for i in range(0, len(classes)):
                if classes[i][0] == parameterName:
                    foundParameter = True
                    break
            if not foundParameter:
                raise RuntimeError("Parameter \"%s\" not present" %
                                   parameterName)
            classes[i] = (parameterName, className, classVersion)
        else:
            # no parameter name - add a new parameter
            parameterNames = set([c[0] for c in classes])
            for i in range(0, len(classes) + 1):
                parameterName = "p%d" % i
                if parameterName not in parameterNames:
                    break

            classes.append((parameterName, className, classVersion))

        with fnPH.parameterModificationContext():
            self.parameter.setClasses(classes)
Esempio n. 9
0
	def testRoundTripColor( self ) :

		node = maya.cmds.createNode( "ieParameterisedHolderNode" )

		parameterised = SplineParameterHandlerTest.TestClassColor()
		fnPH = IECoreMaya.FnParameterisedHolder( node )
		fnPH.setParameterised( parameterised )

		random.seed( 205 )
		numTests = 10

		for i in range( 0, numTests ) :

			numPoints = int( random.random() * 12 ) + 2

			splinePoints = []

			for j in range( 0, numPoints ) :

				splinePoints.append( ( random.random(), IECore.Color3f( random.random(), random.random(), random.random() ) ) )

			splinePoints.sort()

			splinePoints.insert( 0, splinePoints[0] )
			splinePoints.append( splinePoints[-1] )
			assert( len( splinePoints ) >= 4 )

			splineData = IECore.SplinefColor3fData(
				IECore.SplinefColor3f(
					IECore.CubicBasisf.catmullRom(),
					splinePoints
				)
			)

			parameterised.parameters()["spline"].setValue( splineData )

			# Put the value to the node's attributes
			fnPH.setNodeValue( parameterised.parameters()["spline"], False )

			# Retrieve the value from the node's attributes
			fnPH.setParameterisedValue( parameterised.parameters()["spline"] )

			# The parameter value should not have changed

			data = parameterised.parameters()["spline"].getValue()
			self.assertEqual( len( data.value ), len( splineData.value ) )

			for i in range( 0, len( data.value ) ) :

				self.assertAlmostEqual( data.value.keys()[i], splineData.value.keys()[i] )

				c1 = data.value.values()[i]
				c2 = splineData.value.values()[i]

				v1 = IECore.V3f( c1[0], c1[1], c1[2] )
				v2 = IECore.V3f( c2[0], c2[1], c2[2] )


				self.assert_( ( v1 - v2 ).length() < 1.e-4 )
	def __updateLabel( self ) :
	
		IECoreMaya.FnParameterisedHolder( self.node() ).setParameterisedValues()

		maya.cmds.iconTextStaticLabel(
			self.__popupControl,
			edit = True,
			label = self.parameter.getCurrentPresetName(),
		)
Esempio n. 11
0
	def __moveLayer( self, oldIndex, newIndex ) :
	
		classes = [ c[1:] for c in self.__vectorParent().parameter.getClasses( True ) ]
		cl = classes[oldIndex]
		del classes[oldIndex]
		classes[newIndex:newIndex] = [ cl ]
				
		fnPH = IECoreMaya.FnParameterisedHolder( self.__vectorParent().node() )
		with fnPH.parameterModificationContext() :
			self.__vectorParent().parameter.setClasses( classes )
def pasteLinked( plugPath ) :
	
	global _ieCoreParameterClipboardUIBuffer
	global _ieCoreParameterClipboardUILastParameterList
	global _ieCoreParameterClipboardUILastNode
	global _ieCoreParameterClipboardUILastRoot
		
	if not _ieCoreParameterClipboardUIBuffer or not isinstance( _ieCoreParameterClipboardUIBuffer, IECore.Preset ) :
		return
		
	parts = plugPath.split( "." )
	fnPh = IECoreMaya.FnParameterisedHolder( parts[0] )
	parameter = fnPh.plugParameter( plugPath )
	
	if not _ieCoreParameterClipboardUIBuffer.applicableTo( fnPh.getParameterised()[0], parameter ):
		raise RuntimeError, "The parameters on the clipboard are not applicable to '%s'" % plugPath
	
	# Apply the preset to make sure that the children are there
	fnPh.setParameterisedValues()
	
	with fnPh.parameterModificationContext() : 
		_ieCoreParameterClipboardUIBuffer( fnPh.getParameterised()[0], parameter )
		
	# Connect up
	if not maya.cmds.objExists( _ieCoreParameterClipboardUILastNode ) :
		raise RuntimeError, "The source node '%s' no longer exists." % _ieCoreParameterClipboardUILastNode
	
	if not _ieCoreParameterClipboardUILastRoot :
		raise RuntimeError, "Unable to link, the source root parameter is not known." % _ieCoreParameterClipboardUILastNode
	
	
	sourceNodeHolder = IECoreMaya.FnParameterisedHolder( _ieCoreParameterClipboardUILastNode )
	sourceRootPlugPath = sourceNodeHolder.parameterPlugPath( _ieCoreParameterClipboardUILastRoot )
		
	if sourceRootPlugPath == plugPath :
		raise RuntimeError, "The source and destination parameters are the same, unable to link."
	
	for p in _ieCoreParameterClipboardUILastParameterList :
		sourcePlugPath = sourceNodeHolder.parameterPlugPath( p )
		destPlugPath = sourcePlugPath.replace( sourceRootPlugPath, plugPath )
		if maya.cmds.objExists( sourcePlugPath ) and maya.cmds.objExists( destPlugPath ) :
			maya.cmds.connectAttr( sourcePlugPath, destPlugPath, force=True )
	def __setClass( self, className, classVersion, searchPathEnvVar ) :

		fnPH = IECoreMaya.FnParameterisedHolder( self.node() )

		# To stop maya crashing, we need to delete the UI for the existing class
		# before we change it in C++, otherwise, an AE update gets triggered after
		# we have removed the parameters, but before we have removed the UI.
		self._deleteChildParameterUIs()

		with fnPH.parameterModificationContext() :
			self.parameter.setClass( className, classVersion, searchPathEnvVar )
	def replace( self, node, parameter ) :

		IECoreMaya.ParameterUI.replace( self, node, parameter )
		currentParent = maya.cmds.setParent( query=True )

		visibleFields = IECore.StringVectorData( ( "translate", "rotate", "scale", "shear" ) )
		with IECore.IgnoredExceptions( KeyError ) :
			userDataFields = parameter.userData()["UI"]["visibleFields"]
			visibleFields = []
			for u in userDataFields :
				if u not in TransformationMatrixParameterUI._allFields:
					IECore.msg(
						IECore.Msg.Level.Warning,
						"TransformationMatrixParameterUI",
						"Invalid field '%s' requested in UI userData for '%s'. Available fields are %s."
						  % ( u, parameter.name, TransformationMatrixParameterUI._allFields )
					)
					continue
				visibleFields.append( u )

		for f in self._fields.keys() :
			if f not in visibleFields :
				maya.cmds.deleteUI( self._fields[f][0] )
				del self._fields[f]

		fnPH = IECoreMaya.FnParameterisedHolder( node )
		baseName = fnPH.parameterPlugPath( parameter )

		self._addPopupMenu( parentUI=self._label, attributeName=baseName )

		for f in visibleFields :

			if f not in self._fields :
				layout = maya.cmds.rowLayout(
					numberOfColumns = 4,
					parent = self._outerColumn,
					columnWidth4 = [ IECoreMaya.ParameterUI.textColumnWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex, IECoreMaya.ParameterUI.singleWidgetWidthIndex ]
				)
				maya.cmds.text( label=f, font="smallPlainLabelFont", align="right" )
				self._fields[f] = ( layout, maya.cmds.floatField(), maya.cmds.floatField(), maya.cmds.floatField() )

			maya.cmds.connectControl( self._fields[f][1], "%s%s%i" % ( baseName, f, 0 ) )
			maya.cmds.connectControl( self._fields[f][2], "%s%s%i" % ( baseName, f, 1 ) )
			maya.cmds.connectControl( self._fields[f][3], "%s%s%i" % ( baseName, f, 2 ) )

		maya.cmds.button(
			self._manip,
			edit = True,
			# The manip is currently only registered for float types
			visible = isinstance( parameter, IECore.TransformationMatrixfParameter ),
			command = self._createCallback( IECore.curry( IECoreMaya.ManipulatorUI.manipulateParameter, node, parameter ) )
		)

		maya.cmds.setParent( currentParent )
Esempio n. 15
0
	def _removeClass( self, parameterName ) :
	
		fnPH = IECoreMaya.FnParameterisedHolder( self.node() )
		
		classes = [ c[1:] for c in self.parameter.getClasses( True ) if c[1] != parameterName ]
		
		# We have to do a pre-update here, to make sure we delete the UI for any classes we
		# are going to remove, before we remove them in C++. See the notes at the top.
		self.__updateChildUIs( classes )
		
		with fnPH.parameterModificationContext() :
			self.parameter.setClasses( classes )
	def copyCallback( node, rootParameter, parameters ):
		
		global _ieCoreParameterClipboardUIBuffer
		global _ieCoreParameterClipboardUILastParameterList
		global _ieCoreParameterClipboardUILastNode
		global _ieCoreParameterClipboardUILastRoot
		
		fnPh = IECoreMaya.FnParameterisedHolder( node )
		preset = IECore.BasicPreset( fnPh.getParameterised()[0], rootParameter, parameters=parameters )
		
		_ieCoreParameterClipboardUIBuffer = preset
		_ieCoreParameterClipboardUILastParameterList = parameters
		_ieCoreParameterClipboardUILastNode = node
		_ieCoreParameterClipboardUILastRoot = rootParameter
Esempio n. 17
0
	def testArrayPlugCreation( self ) :

		op = IECore.Op( 'test op', IECore.IntParameter( 'result', '', 0 ) )
		op.parameters().addParameters( [
			IECore.V3fVectorParameter( 'v3fVector', '', IECore.V3fVectorData() ),
			IECore.V3dVectorParameter( 'v3dVector', '', IECore.V3dVectorData() ),
			IECore.StringVectorParameter( 'stringVector', '', IECore.StringVectorData() ),
			IECore.DoubleVectorParameter( 'doubleVector', '', IECore.DoubleVectorData() ),
			IECore.FloatVectorParameter( 'floatVector', '', IECore.FloatVectorData() ),
			IECore.IntVectorParameter( 'intVector', '', IECore.IntVectorData() ),
			IECore.BoolVectorParameter( 'boolVector', '', IECore.BoolVectorData() ),
			IECore.M44fVectorParameter( 'm44fVector', '', IECore.M44fVectorData() ),
			IECore.M44dVectorParameter( 'm44dVector', '', IECore.M44dVectorData() ),
		] )
		
		node = maya.cmds.createNode( 'ieOpHolderNode' )
		fnPH = IECoreMaya.FnParameterisedHolder( node )
		
		self.assert_( not maya.cmds.objExists( node+'.parm_v3fVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_v3dVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_stringVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_doubleVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_floatVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_intVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_boolVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_m44fVector' ) )
		self.assert_( not maya.cmds.objExists( node+'.parm_m44dVector' ) )
		
		fnPH.setParameterised( op )
		
		self.assert_( maya.cmds.objExists( node+'.parm_v3fVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_v3dVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_stringVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_doubleVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_floatVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_intVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_boolVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_m44fVector' ) )
		self.assert_( maya.cmds.objExists( node+'.parm_m44dVector' ) )
				
		self.assertEqual( maya.cmds.getAttr( node+'.parm_v3fVector', type=True ), 'vectorArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_v3dVector', type=True ), 'vectorArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_stringVector', type=True ), 'stringArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_doubleVector', type=True ), 'doubleArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_floatVector', type=True ), 'doubleArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_intVector', type=True ), 'Int32Array' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_boolVector', type=True ), 'Int32Array' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_m44fVector', type=True ), 'doubleArray' )
		self.assertEqual( maya.cmds.getAttr( node+'.parm_m44dVector', type=True ), 'doubleArray' )
Esempio n. 18
0
	def testMatrixVectorPlugs( self ) :

		m44fVector = IECore.M44fVectorData( [ IECore.M44f( 1 ), IECore.M44f( 2 ), IECore.M44f( 3 ) ] )
		m44dVector = IECore.M44dVectorData( [ IECore.M44d( 1 ), IECore.M44d( 2 ), IECore.M44d( 3 ) ] )
		reverseM44fVector = IECore.M44fVectorData( [ IECore.M44f( 3 ), IECore.M44f( 2 ), IECore.M44f( 1 ) ] )
		reverseM44dVector = IECore.M44dVectorData( [ IECore.M44d( 3 ), IECore.M44d( 2 ), IECore.M44d( 1 ) ] )
		
		mayaArray = []
		for i in range( 0, 3 ) :
			for j in range( 0, 16 ) :
				mayaArray.append( i+1 )
		
		reverseMayaArray = list(mayaArray)
		reverseMayaArray.reverse()
		
		op = IECore.Op( 'test op', IECore.IntParameter( 'result', '', 0 ) )
		op.parameters().addParameters( [
			IECore.M44fVectorParameter( 'm44fVector', '', IECore.M44fVectorData() ),
			IECore.M44dVectorParameter( 'm44dVector', '', IECore.M44dVectorData() ),
		] )
		
		node = maya.cmds.createNode( 'ieOpHolderNode' )
		fnPH = IECoreMaya.FnParameterisedHolder( node )
		fnPH.setParameterised( op )
		
		# set from cortex to maya
		self.assertNotEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44fVector' ) )
		self.assertNotEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44dVector' ) )
		fnPH.getParameterised()[0].parameters()['m44fVector'].setValue( m44fVector )
		fnPH.getParameterised()[0].parameters()['m44dVector'].setValue( m44dVector )
		fnPH.setNodeValues()
		self.assertEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44fVector' ) )
		self.assertEqual( mayaArray, maya.cmds.getAttr( node+'.parm_m44dVector' ) )
		
		# set from maya to cortex
		self.assertNotEqual( reverseM44fVector, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() )
		self.assertNotEqual( reverseM44dVector, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() )
		maya.cmds.setAttr( node+'.parm_m44fVector', reverseMayaArray, type="doubleArray" )
		maya.cmds.setAttr( node+'.parm_m44dVector', reverseMayaArray, type="doubleArray" )
		fnPH.setParameterisedValues()		
		self.assertEqual( reverseM44fVector, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() )
		self.assertEqual( reverseM44dVector, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() )
		
		# set to incorrect length from maya
		maya.cmds.setAttr( node+'.parm_m44fVector', [0,1,2], type="doubleArray" )
		maya.cmds.setAttr( node+'.parm_m44dVector', [0,1,2], type="doubleArray" )
		fnPH.setParameterisedValues()
		self.assertEqual( None, fnPH.getParameterised()[0].parameters()['m44fVector'].getValue() )
		self.assertEqual( None, fnPH.getParameterised()[0].parameters()['m44dVector'].getValue() )
    def __attributeChanged(self, changeType, plug, otherPlug, userData):

        if not (changeType & maya.OpenMaya.MNodeMessage.kAttributeSet):
            return

        fnPH = IECoreMaya.FnParameterisedHolder(self.__vectorParent().node())
        for index, parameter in enumerate(self.__presetParameters):

            try:
                myPlug = fnPH.parameterPlug(parameter)
            except:
                # this situation can occur when our parameter has been removed but the
                # ui we represent is not quite yet dead
                continue

            if plug == myPlug:
                self.__updatePresetLabel(index)
Esempio n. 20
0
def __createMeshOpNode( className, classVersion, **kw ):

	shortClassName = className.split( '/' ).pop()

	modifierNodeName = cmds.createNode( "ieOpHolderNode", name = shortClassName + "#" )

	ph = IECoreMaya.FnParameterisedHolder( modifierNodeName )
	op = ph.setParameterised( className, classVersion, "IECORE_OP_PATHS" )

	__setParameters( op, kw )

	selList = OpenMaya.MSelectionList()
	selList.add( modifierNodeName )
	modifierNode = OpenMaya.MObject()
	s = selList.getDependNode( 0, modifierNode )

	return modifierNode
def manipulateParameter(node,
                        parameter,
                        contextName="ieParameterManipulatorContext"):

    fnPH = IECoreMaya.FnParameterisedHolder(node)
    plugPath = fnPH.parameterPlugPath(parameter)

    if not maya.cmds.contextInfo(contextName, exists=True):
        maya.cmds.ieParameterisedHolderManipContext(contextName)

    maya.cmds.ieParameterisedHolderManipContext(
        contextName,
        edit=True,
        mode="targeted",
        targetPlug=plugPath.split(".")[-1])

    maya.cmds.setToolTo(contextName)
Esempio n. 22
0
    def __parameterIsCollapsible(self, node=None, parameter=None):

        if node is None:
            node = self.node()
        if parameter is None:
            parameter = self.parameter

        fnPH = IECoreMaya.FnParameterisedHolder(node)

        collapsible = not parameter.isSame(
            fnPH.getParameterised()[0].parameters())
        with IECore.IgnoredExceptions(KeyError):
            collapsible = parameter.userData()["UI"]["collapsible"].value
        with IECore.IgnoredExceptions(KeyError):
            collapsible = parameter.userData()["UI"]["collapsable"].value

        collapsible = self.__kw.get("withCompoundFrame", False) or collapsible

        return collapsible
Esempio n. 23
0
        def addControl(self, node, longParameterName):

            fnPH = IECoreMaya.FnParameterisedHolder(node)
            parameterised = fnPH.getParameterised()[0]

            parameter = parameterised.parameters()

            for p in longParameterName.split('.'):

                if p:

                    parameter = getattr(parameter, p)

            assert (self.containerLayout)
            maya.cmds.setParent(self.containerLayout)

            if not (node, longParameterName) in self.parameterLayouts:

                n = longParameterName.split(".")

                if type(n) is list:

                    # Take off the last element (to retrieve the parent parameter name),
                    # because ParameterUI.create will add it again.
                    n.pop()
                    parentParameterName = ".".join(n)

                else:

                    parentParameterName = longParameterName

                newLayout = IECoreMaya.ParameterUI.create(
                    node,
                    parameter,
                    labelWithNodeName=True,
                    longParameterName=parentParameterName,
                    withCompoundFrame=True).layout()

                self.parameters.append((node, longParameterName))
                self.parameterLayouts[(node, longParameterName)] = newLayout

                maya.cmds.file(modified=True)
def copy( plugPath, showUI=False ) :

	global _ieCoreParameterClipboardUIBuffer
	global _ieCoreParameterClipboardUILastParameterList
	global _ieCoreParameterClipboardUILastNode
	global _ieCoreParameterClipboardUILastRoot

	parts = plugPath.split( "." )
	fnPh = IECoreMaya.FnParameterisedHolder( parts[0] )
	parameter = fnPh.plugParameter( plugPath )

	def copyCallback( node, rootParameter, parameters ):
		
		global _ieCoreParameterClipboardUIBuffer
		global _ieCoreParameterClipboardUILastParameterList
		global _ieCoreParameterClipboardUILastNode
		global _ieCoreParameterClipboardUILastRoot
		
		fnPh = IECoreMaya.FnParameterisedHolder( node )
		preset = IECore.BasicPreset( fnPh.getParameterised()[0], rootParameter, parameters=parameters )
		
		_ieCoreParameterClipboardUIBuffer = preset
		_ieCoreParameterClipboardUILastParameterList = parameters
		_ieCoreParameterClipboardUILastNode = node
		_ieCoreParameterClipboardUILastRoot = rootParameter
	
	# We need to make sure that the values in the parameterised are in sync
	fnPh.setParameterisedValues()
	
	if showUI :

		IECoreMaya.PresetsUI( parts[0], parameter ).selectParameters( copyCallback )
	
	else :
		
		paramList = []
		__getParameters( parameter, paramList )

		_ieCoreParameterClipboardUIBuffer = IECore.BasicPreset( fnPh.getParameterised()[0], parameter )
		_ieCoreParameterClipboardUILastParameterList = paramList
		_ieCoreParameterClipboardUILastNode = fnPh.fullPathName()
		_ieCoreParameterClipboardUILastRoot = parameter
Esempio n. 25
0
def __menuCallback(definition, parameter, node):

    active = False
    with IECore.IgnoredExceptions(KeyError):
        active = parameter.userData()["maya"]["useGeometryCombiner"].value

    if not active:
        return

    definition.append("/InputGeometryDivider", {"divider": True})

    plugPath = IECoreMaya.FnParameterisedHolder(node).parameterPlugPath(
        parameter)

    definition.append("/Input Geometry/Add Selected",
                      {"command": IECore.curry(__addSelected, plugPath)})
    definition.append("/Input Geometry/Remove Selected",
                      {"command": IECore.curry(__removeSelected, plugPath)})
    definition.append("/Input Geometry/Select",
                      {"command": IECore.curry(__select, plugPath)})
def paste( plugPath ) :

	global _ieCoreParameterClipboardUIBuffer
	global _ieCoreParameterClipboardUILastParameterList
	global _ieCoreParameterClipboardUILastNode
	global _ieCoreParameterClipboardUILastRoot
		
	if not _ieCoreParameterClipboardUIBuffer or not isinstance( _ieCoreParameterClipboardUIBuffer, IECore.Preset ) :
		return
		
	parts = plugPath.split( "." )
	fnPh = IECoreMaya.FnParameterisedHolder( parts[0] )
	parameter = fnPh.plugParameter( plugPath )
	
	if not _ieCoreParameterClipboardUIBuffer.applicableTo( fnPh.getParameterised()[0], parameter ):
		raise RuntimeError, "The parameters on the clipboard are not applicable to '%s'" % plugPath
	
	fnPh.setParameterisedValues()
	
	with fnPh.parameterModificationContext() : 
		_ieCoreParameterClipboardUIBuffer( fnPh.getParameterised()[0], parameter )
Esempio n. 27
0
    def plug(self):

        fnPH = IECoreMaya.FnParameterisedHolder(self.node())
        return fnPH.parameterPlug(self.parameter)
Esempio n. 28
0
    def nodeName(self):

        fnPH = IECoreMaya.FnParameterisedHolder(self.node())
        return fnPH.fullPathName()
Esempio n. 29
0
    def __selectValue(self, selection=None):

        self.parameter.setValue(selection)
        IECoreMaya.FnParameterisedHolder(self.node()).setNodeValue(
            self.parameter)
Esempio n. 30
0
    def plugName(self):

        fnPH = IECoreMaya.FnParameterisedHolder(self.node())
        plug = fnPH.parameterPlug(self.parameter)
        return str(fnPH.fullPathName() + "." + plug.partialName())