.. _FabricForMaya.pre-2.0: Using the Splice Maya plugin (legacy) ====================================== .. note:: The Splice Maya (pre-2.0) feature are still supported in 2.0, but might be deprecated in future release. Launch Maya and load the Splice plugin, you should see a new entry in the top menus which says :dfn:`Splice`. In order to start using the Splice Editor UI you need to create a Splice Maya node, to do so just open the Splice top menu and create a spliceMayaNode. Open maya's Attribute Editor and click the button Open Splice Editor. If the Splice Editor was already open it will simply refresh to point at the currently selected node once you click the button in the Attribute Editor. In order to make the node's interface compatible with a KL operator you need to add some attributes and ports, to do so you can use the Splice Editor and click on the button Add located under the Contained Ports part of the Editor. .. note:: A Splice Node uses Ports to store and retrieve KL data, Ports can be accessed within KL operators. If a Maya Attribute is added with the same name of a Port then the Port's data is automatically synchronized with the Maya attribute's data, the KL Port data will transfered in and out of maya depending if the Port was set as input or output. Once the interface of the node is defined in terms of ports and attributes you can add a KL operator from the Splice Editor Add button, under the Contained Operators part of the UI. When the operator is created the KL editor will show it along with the ports interface to interact with it. .. note:: KL Operators are global to the scope of Creation Splice, they don't belong exclusively to the node they've been created for and they can be applied to every Splice Maya node that has a compatible interface. That's it for the spliceMayaNode overview, have fun playing inside the body of the KL operator, if new to the KL language please refer to the :ref:`KLPG`. .. _nodetypes: Maya Nodes Types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The Splice Maya plugin comes with three node types, the :dfn:`spliceMayaNode` is a generic MPxNode where you can attach almost every kind of maya attribute type, it will be suited for any generic computation such as rigging or simulation solvers. The :dfn:`spliceMayaDeformer` is a deformer node that seamlessly works with maya's deformation tools and commands, it comes with two arrays of points, one as input and another for the output, any other necessary attribute can still be added to this node once instantiated. The :dfn:`spliceMayaDebugger` allows for custom OpenGL drawings generated inside a KL operator to be visualized inside maya's 3D viewport. Drawing inside a KL operator is done by using the InlineGeometryType. .. _mayascripting: Scripted Splice ^^^^^^^^^^^^^^^^^^^ Anything done with the Splice Editor graphical interface can also be automated in MEL and Python via the fabricSplice command, thus offering the possibility to include Splice nodes in scripted procedural rigs or other kind of automated scene setups. Referencing external KL files is also possible via the fabricSplice command, this could be useful to have KL operators under source control or share them with other people or simply to take advantage of external code editors. Once a scene is saved the code of eachKL operator is also stored along with the path to the KL file, on scene loading the code of the operator will be used if the specified KL file is not found anymore. For a full list of scripting actions and parameters, please see the :ref:`SPLICESCRIPTINGACTIONS` section. The following examples show how to interact with the fabricSplice command with Python syntax: .. code-block:: python from maya import cmds # creating a node and attaching an operator node = cmds.createNode('spliceMayaNode') cmds.fabricSplice('addInputPort', node, '{"portName":"in1", "dataType":"Scalar", "addMayaAttr":true}') cmds.fabricSplice('addInputPort', node, '{"portName":"in2", "dataType":"Scalar", "addMayaAttr":true}') cmds.fabricSplice('addOutputPort', node, '{"portName":"out", "dataType":"Scalar", "addMayaAttr":true}') cmds.fabricSplice('addKLOperator', node, '{"opName":"helloWorldOp"}', """ operator helloWorldOp(Scalar in1, Scalar in2, io Scalar out) { report('computing KL in maya!'); report(in1 + " + " + in2); out = in1 + in2; } """) cmds.setAttr(node + '.in1', 1.0) cmds.setAttr(node + '.in2', 2.0) print cmds.getAttr(node + '.out') == 3.0 # referencing an external KL operator file cmds.fabricSplice('setKLOperatorFile', node, '{"opName":"helloWorldOp", "fileName":"/somePath/helloWorldOp.kl"}') Port UI Limits ^^^^^^^^^^^^^^^^^^^^ Any unconsumed flag added to the :dfn:`addInputPort`, :dfn:`addOutputPort` or :dfn:`addIOPort` actions will be setup as additional flag data on the resulting ports. This data will also be persisted with the maya scene or with exported splice files. Some of the optional flags are used for UI hints, for example :dfn:`uiMin`, :dfn:`uiMax`, :dfn:`uiSoftMin` and :dfn:`uiSoftMax`. With these you can define slider ranges for :dfn:`Integer` or :dfn:`Scalar` ports. .. code-block:: python cmds.fabricSplice('addInputPort', node, '{"portName":"slider", "dataType":"Scalar", "addMayaAttr":true, "uiMin": -10.0, "uiMax": 10.0}') Compound Attributes ^^^^^^^^^^^^^^^^^^^^^^^^^ .. versionadded:: 1.12.0 Using the :ref:`compoundparam` KL type maya compound attributes can now be transfered to and from Splice. :ref:`compoundparam` objects are a way of describing hierarchical parameters. With this version we support all of the basic types, excluding geometries such as MFnMesh etc. The actual compound attribute is not created by Splice however, it needs to be created by the maya user (or responsible scripts). The Splice conversion layer will then turn the data into the right nested data structure in KL. Of course :ref:`compoundparam` objects supported hierarchical nesting, so you can put a :ref:`compoundparam` into another :ref:`compoundparam`. .. code-block:: python import maya.cmds as cmds import maya.OpenMaya as OpenMaya import maya.OpenMayaMPx as OpenMayaMPx node = cmds.createNode('spliceMayaNode') cmds.select(node, r=True) # setup the compound attribute cmds.addAttr(node, ln='values', at='compound', nc=4) cmds.addAttr(node, ln='a', at='bool', p='values') cmds.addAttr(node, ln='b', at='long', p='values') cmds.addAttr(node, ln='c', at='float', p='values') cmds.addAttr(node, ln='d', at='double3', p='values') cmds.addAttr(node, ln='dX', at='double', p='d') cmds.addAttr(node, ln='dY', at='double', p='d') cmds.addAttr(node, ln='dZ', at='double', p='d') # create a port for the compound cmds.fabricSplice('addIOPort', node, '{"portName":"values", "dataType":"CompoundParam", "addMayaAttr":false}') cmds.fabricSplice('addOutputPort', node, '{"portName":"result", "dataType":"Scalar", "addMayaAttr":true}') # create a KL operator for it cmds.fabricSplice('addKLOperator', node, '{"opName": "testCompoundOp"}', ''' require Parameters; operator testCompoundOp(io CompoundParam values) { for(Size i=0;i