Python pymel.core.createNode() Examples
The following are 30
code examples of pymel.core.createNode().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pymel.core
, or try the search function
.

Example #1
Source File: sharedShape.py From fossil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def getConditionNode(plug, level): ''' ''' conditions = PyNode(plug).listConnections(type='condition', p=True, d=True, s=False) for condition in conditions: if condition.attrName() == 'ft' and condition.node().secondTerm.get() == level: return condition.node() condition = createNode('condition', n=plug.split('.')[1] + '_%i' % level) condition.secondTerm.set(level) condition.operation.set(3) connectAttr( plug, condition.firstTerm, f=True ) condition.colorIfTrue.set(1, 1, 1) condition.colorIfFalse.set(0, 0, 0) return condition
Example #2
Source File: extension.py From anima with MIT License | 6 votes |
def create_shot(self, name='', handle=default_handle_count): """Creates a new shot. :param str name: A string value for the newly created shot name, if skipped or given empty, the next empty shot name will be generated. :param int handle: An integer value for the handle attribute. Default is 10. :returns: The created :class:`~pm.nt.Shot` instance """ shot = pm.createNode('shot') shot.shotName.set(name) shot.set_handle(handle=handle) shot.set_output('') # connect to the sequencer shot.message >> self.shots.next_available return shot
Example #3
Source File: auxiliary.py From anima with MIT License | 6 votes |
def create_arnold_stand_in(path=None): """A fixed version of original arnold script of SolidAngle Arnold core API """ if not pm.objExists('ArnoldStandInDefaultLightSet'): pm.createNode( "objectSet", name="ArnoldStandInDefaultLightSet", shared=True ) pm.lightlink( object='ArnoldStandInDefaultLightSet', light='defaultLightSet' ) stand_in = pm.createNode('aiStandIn', n='ArnoldStandInShape') # temp fix until we can correct in c++ plugin stand_in.setAttr('visibleInReflections', True) stand_in.setAttr('visibleInRefractions', True) pm.sets('ArnoldStandInDefaultLightSet', add=stand_in) if path: stand_in.setAttr('dso', path) return stand_in
Example #4
Source File: node.py From mgear_core with MIT License | 6 votes |
def createVertexPositionNode(inShape, vId=0, output=None, name="mgear_vertexPosition"): """Creates a mgear_vertexPosition node""" node = pm.createNode("mgear_vertexPosition", n=name) inShape.worldMesh.connect(node.inputShape) node.vertex.set(vId) if output: pm.connectAttr(output.parentInverseMatrix, node.drivenParentInverseMatrix) pm.connectAttr(node.output, output.translate) return node ############################################# # CREATE MULTI NODES #############################################
Example #5
Source File: rigging.py From anima with MIT License | 6 votes |
def setup_stretchy_spline_ik_curve(cls): """ """ selection = pm.ls(sl=1) curve = selection[0] curve_info = pm.createNode("curveInfo") mult_div = pm.createNode("multiplyDivide") curve_shape = pm.listRelatives(curve, s=1) curve_shape[0].worldSpace >> curve_info.ic curve_info.arcLength >> mult_div.input1X curve_length = curve_info.arcLength.get() mult_div.input2X.set(curve_length) mult_div.operation.set(2) pm.select(mult_div, curve_info, curve_shape[0], add=True)
Example #6
Source File: node.py From mgear_core with MIT License | 6 votes |
def createCurveInfoNode(crv): """Create and connect a curveInfo node. Arguments: crv (dagNode): The curve. Returns: pyNode: the newly created node. >>> crv_node = nod.createCurveInfoNode(self.slv_crv) """ node = pm.createNode("curveInfo") shape = pm.listRelatives(crv, shapes=True)[0] pm.connectAttr(shape + ".local", node + ".inputCurve") return node # TODO: update using plusMinusAverage node
Example #7
Source File: node.py From mgear_core with MIT License | 6 votes |
def createDecomposeMatrixNode(m): """ Create and connect a decomposeMatrix node. Arguments: m(str or attr): The matrix attribute name. Returns: pyNode: the newly created node. >>> dm_node = nod.createDecomposeMatrixNode(mulmat_node+".output") """ node = pm.createNode("decomposeMatrix") pm.connectAttr(m, node + ".inputMatrix") return node
Example #8
Source File: applyop.py From mgear_core with MIT License | 6 votes |
def gear_inverseRotorder_op(out_obj, in_obj): """ Apply a sn_inverseRotorder_op operator Arguments: out_obj (dagNode): Output object. in_obj (dagNode): Input object. Returns: pyNode: The newly created operator. """ node = pm.createNode("mgear_inverseRotOrder") pm.connectAttr(in_obj + ".ro", node + ".ro") pm.connectAttr(node + ".output", out_obj + ".ro") return node
Example #9
Source File: maya.py From anima with MIT License | 6 votes |
def test_next_available_with_all_connected_attribute(self): """testing if the next available attribute will be returned when no empty plugs are present """ sequence_manager = pm.ls(type=pm.nt.SequenceManager)[0] # connect new sequences seq1 = pm.createNode('sequence') seq2 = pm.createNode('sequence') seq3 = pm.createNode('sequence') seq1.message >> sequence_manager.sequences[0] seq2.message >> sequence_manager.sequences[1] seq3.message >> sequence_manager.sequences[2] attr = sequence_manager.sequences.next_available self.assertIsInstance( attr, pm.general.Attribute ) self.assertEqual( 3, sequence_manager.sequences.next_available.index() )
Example #10
Source File: rigutils.py From DynRigBuilder with MIT License | 6 votes |
def createFollicle(target=None, param=[0.5,0.5], name="follicle"): """ Create follicle. :param target: `PyNode` target that the follicle connected to :param param: `list` [u, v] follicle uv parameter :param name: `string` follicle name :return: `PyNode` follicle ransform node """ follicle = pm.createNode("follicle") follicle.parameterU.set(param[0]) follicle.parameterV.set(param[1]) if target: targetShape = target.getShape() targetShape.worldMatrix.connect(follicle.inputWorldMatrix) if targetShape.nodeType() == "nurbsSurface": targetShape.local.connect(follicle.inputSurface) elif targetShape.nodeType() == "mesh": targetShape.outMesh.connect(follicle.inputMesh) folTransform = follicle.getParent() follicle.outRotate.connect(folTransform.rotate) follicle.outTranslate.connect(folTransform.translate) pm.rename(folTransform, name) return folTransform
Example #11
Source File: applyop.py From mgear_core with MIT License | 6 votes |
def gear_intmatrix_op(mA, mB, blend=0): """ create mGear interpolate Matrix node. Arguments: mA (matrix): Input matrix A. mB (matrix): Input matrix A. blend (float or connection): Blending value. Returns: pyNode: Newly created mGear_intMatrix node """ node = pm.createNode("mgear_intMatrix") pm.connectAttr(mA, node + ".matrixA") pm.connectAttr(mB, node + ".matrixB") if (isinstance(blend, str) or isinstance(blend, unicode) or isinstance(blend, pm.Attribute)): pm.connectAttr(blend, node + ".blend") else: pm.setAttr(node + ".blend", blend) return node
Example #12
Source File: mayautils.py From DynRigBuilder with MIT License | 6 votes |
def createParentTransform(suffix="grp", targetNode=None): """ Create a parent transform of the node that matches the node position. :param suffix: `string` parent node name :param targetNode: `PyNode` node to add parent transform :return: `PyNode` result transform node """ if not targetNode: try: targetNode = pm.ls(sl=True)[0] except: print "No target node is specified." return None grpNode = pm.createNode("transform", n="{0}_{1}".format(targetNode.name(),suffix)) pm.delete(pm.parentConstraint(targetNode, grpNode, mo=False)) grpNode.setParent(targetNode.getParent()) targetNode.setParent(grpNode) return grpNode
Example #13
Source File: sharedShape.py From fossil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get(create=True): ''' Returns the shared shape if it exists and makes it if it doesn't if create=True (default). ''' obj = core.findNode.mainGroup() if not obj: return None shape = find(obj) if shape: return shape if create: return _makeSharedShape(obj, 'sharedShape', 'sharedShape') else: return None ''' shape = cmds.createNode( 'nurbsCurve', p=obj.longName() ) cmds.addAttr( shape, ln='sharedShape', at='message' ) cmds.rename( shape, 'sharedShape' ) return obj.longName() + '|sharedShape' '''
Example #14
Source File: sqCopyPasteShapes.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
def _duplicate_shape(old_shape): new_shape = pymel.createNode('nurbsCurve') # Transfert various attributes mel_dst = '{0}.create'.format(new_shape) # prevent annoying pymel warning pymel.connectAttr(old_shape.local, mel_dst) new_shape.create.evaluate() # Force maya to cache the shape before unconnecting pymel.disconnectAttr(old_shape.local, mel_dst) # Transfert various attributes for att_name in transferable_shape_attrs: att_old = old_shape.attr(att_name) att_new = new_shape.attr(att_name) att_new.set(att_old.get()) return new_shape
Example #15
Source File: core.py From metanode with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create(cls, name): """ Create a new Metanode. :param string name: The name for the created node. :return: Metanode class wrapping the newly created node. """ network_node = pm.createNode(NODE_TYPE) network_node.rename(name) for coreAttrName, coreAttrArgs in cls.attr_core().iteritems(): value = coreAttrArgs.pop('value') network_node.addAttr(coreAttrName, **coreAttrArgs) network_node.attr(coreAttrName).set(value) network_node.attr(coreAttrName).setLocked(True) for coreAttrName, coreAttrArgs in cls.attr_class().iteritems(): network_node.addAttr(coreAttrName, **coreAttrArgs) return cls(network_node)
Example #16
Source File: extension.py From anima with MIT License | 5 votes |
def create_sequence(self, name=None): """Creates a new sequence :return: pm.nodetypes.Sequence """ sequencer = pm.createNode('sequencer') if not name: name = '' sequencer.set_sequence_name(name) sequencer.message >> self.sequences.next_available return sequencer
Example #17
Source File: node.py From mgear_core with MIT License | 5 votes |
def createNegateNodeMulti(name, inputs=[]): """Create and connect multiple negate nodes Arguments: name (str): The name for the new node. inputs (list of attr): The list of attributes to negate Returns: list: The output attributes list. """ s = "XYZ" count = 0 i = 0 outputs = [] for input in inputs: if count == 0: real_name = name + "_" + str(i) node_name = pm.createNode("multiplyDivide", n=real_name) i += 1 pm.connectAttr(input, node_name + ".input1" + s[count], f=True) pm.setAttr(node_name + ".input2" + s[count], -1) outputs.append(node_name + ".output" + s[count]) count = (count + 1) % 3 return outputs
Example #18
Source File: auxiliary.py From anima with MIT License | 5 votes |
def create_rs_proxy_node(path=None): """Creates Redshift Proxies showing a proxy object """ proxy_mesh_node = pm.createNode('RedshiftProxyMesh') proxy_mesh_node.fileName.set(path) proxy_mesh_shape = pm.createNode('mesh') proxy_mesh_node.outMesh >> proxy_mesh_shape.inMesh # assign default material pm.sets('initialShadingGroup', fe=proxy_mesh_shape) return proxy_mesh_node, proxy_mesh_shape
Example #19
Source File: auxiliary.py From anima with MIT License | 5 votes |
def create_barn_door(self): """creates the barn door node """ light_shape = self.light.getShape() inputs = light_shape.inputs(type='aiBarndoor') if inputs: self.barn_door = inputs[0] else: self.barn_door = pm.createNode('aiBarndoor') self.barn_door.attr('message') >> \ light_shape.attr('aiFilters').next_available
Example #20
Source File: sharedShape.py From fossil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _makeSharedShape(obj, name, shapeType): ''' shapeType should be either 'sharedShape' or 'kinematicSwitch' Returns a string of the shape, ex 'Foot_L|sharedShape' (to bypass pymel warnings) ''' shape = cmds.createNode( 'nurbsCurve', p=obj.longName() ) # 2017 added a bunch of keyable attrs so get rid of them if possible. for attr in cmds.listAttr(shape, k=True): try: cmds.setAttr(shape + '.' + attr, k=False, l=True) except Exception as e: # noqa #print( e ) pass # Make it a valid curve so it doesn't get deleted during optimize scene # but lock and hide it. mel.eval('''setAttr "%s.cc" -type "nurbsCurve" 1 1 0 no 3 2 0 1 2 0 0 0 0 0 0 ;''' % shape ) setAttr(shape + '.visibility', False, l=True) # noqa addAttr(shape, ln=core.shape.sharedShapeTag, at='message') cmds.addAttr( shape, ln=shapeType, at='message' ) cmds.rename( shape, name ) return obj.longName() + '|' + name
Example #21
Source File: rigging.py From anima with MIT License | 5 votes |
def create_follicle(cls, component): """creates a follicle at given component """ follicle_shape = pm.createNode('follicle') geometry = component.node() uv = None if isinstance(geometry, pm.nt.Mesh): geometry.attr('outMesh') >> follicle_shape.attr('inputMesh') # get uv uv = component.getUV() elif isinstance(geometry, pm.nt.NurbsSurface): geometry.attr('local') >> follicle_shape.attr('inputSurface') # get uv # TODO: Fix this uv = [0, 0] geometry.attr('worldMatrix[0]') >> follicle_shape.attr( 'inputWorldMatrix') follicle_shape.setAttr('pu', uv[0]) follicle_shape.setAttr('pv', uv[1]) # set simulation to static follicle_shape.setAttr('simulationMethod', 0) # connect to its transform node follicle = follicle_shape.getParent() follicle_shape.attr('outTranslate') >> follicle.attr('t') follicle_shape.attr('outRotate') >> follicle.attr('r') return follicle
Example #22
Source File: render.py From anima with MIT License | 5 votes |
def convert_to_linear(cls): """adds a gamma_gain node in between the selected nodes outputs to make the result linear """ # # convert to linear # selection = pm.ls(sl=1) for file_node in selection: # get the connections outputs = file_node.outputs(plugs=True) if not len(outputs): continue # and insert a mip_gamma_gain gamma_node = pm.createNode('mip_gamma_gain') gamma_node.setAttr('gamma', 2.2) gamma_node.setAttr('reverse', True) # connect the file_node to gamma_node try: file_node.outValue >> gamma_node.input file_node.outValueA >> gamma_node.inputA except AttributeError: file_node.outColor >> gamma_node.input # do all the connections from the output of the gamma for output in outputs: try: gamma_node.outValue >> output except RuntimeError: gamma_node.outValueA >> output pm.select(selection)
Example #23
Source File: modeling.py From anima with MIT License | 5 votes |
def vertex_aligned_locator(cls): """creates vertex aligned locator, select 3 vertices """ selection = pm.ls(os=1, fl=1) # get the axises p0 = selection[0].getPosition(space='world') p1 = selection[1].getPosition(space='world') p2 = selection[2].getPosition(space='world') v1 = p0 - p1 v2 = p2 - p1 #v3 = p0 - p2 v1.normalize() v2.normalize() dcm = pm.createNode('decomposeMatrix') x = v1 z = v2 y = z ^ x y.normalize() dcm.inputMatrix.set( [x[0], x[1], x[2], 0, y[0], y[1], y[2], 0, z[0], z[1], z[2], 0, 0, 0, 0, 1], type='matrix') loc = pm.spaceLocator() loc.t.set(p1) loc.r.set(dcm.outputRotate.get()) pm.delete(dcm)
Example #24
Source File: animation.py From anima with MIT License | 5 votes |
def attach_follicle(cls): """attaches a follicle on selected mesh vertices """ pnts = pm.ls(sl=1) for pnt in pnts: mesh = pnt.node() follicle = pm.createNode('follicle') mesh.worldMesh[0] >> follicle.inputMesh uv = pnts[0].getUV() follicle.parameterU.set(uv[0]) follicle.parameterV.set(uv[1]) follicle_t = follicle.getParent() follicle.outTranslate >> follicle_t.t follicle.outRotate >> follicle_t.r
Example #25
Source File: shapes.py From anima with MIT License | 5 votes |
def transform(cls, name=''): node = pm.createNode("transform") cls.rename(node, name) return node
Example #26
Source File: network.py From anima with MIT License | 5 votes |
def _createNetwork(self): """creates a networkNode. This node holds all the limb nodes """ #creates a networkNode. This node holds all the maya nodes self._name = self._name + "_Network" pm.createNode("network", n= self.name)
Example #27
Source File: mayautils.py From DynRigBuilder with MIT License | 5 votes |
def aimObject(toTarget, fromTarget): """ Aim object to the target. :param toTarget: `PyNode` or `list` object or world position to aim to :param fromTarget: `PyNode` object to transform :return: """ if isinstance(toTarget, list): targetObj = pm.createNode("transform") pm.xform(targetObj, t=toTarget, ws=1) pm.delete(pm.aimConstraint(targetObj, fromTarget, mo=0, wut=0)) pm.delete(targetObj) else: pm.delete(pm.aimConstraint(toTarget, fromTarget, mo=0, wut=0))
Example #28
Source File: curve.py From anima with MIT License | 5 votes |
def _create_curveInfo(self): #create a new CurveInfo Node self._curveInfo = pm.createNode("curveInfo", n= self._curveNode + "_curveInfo") pm.connectAttr(self._curveNode.worldSpace, self._curveInfo.inputCurve) return self._curveInfo
Example #29
Source File: rigutils.py From DynRigBuilder with MIT License | 5 votes |
def buildJointChainFromCurve(curve, jointNum, prefix, suffix, rebuildCurve=False, orientJoint="xyz", saoType="yup"): """ Build joint chain along the curve. :param curve: `PyNode` curve that defines the joint position :param jointNum: `int` number of joints in the chain :param prefix: `string` prefix string in joint name :param suffix: `string` suffix string in joint name :param rebuildCurve: `bool` if true, rebuild the input curve to make sure the joints are evenly positioned, but can't guarantee the joints lands exacly on the input curve :param orientJoint: `string` orient joint flag :param saoType: `string` secondary axis orient flag :return: `list` list of joint nodes in the joint chain. sorted by hierarchy. """ if rebuildCurve: curve = pm.rebuildCurve(curve, rpo=0, end=1, kr=0, rt=0, d=7, ch=0, s=64)[0] poci = pm.createNode("pointOnCurveInfo") poci.turnOnPercentage.set(1) curve.worldSpace[0].connect(poci.inputCurve) joints = [] ratio = 1.0/(jointNum-1.0) pm.select(d=1) for i in range(jointNum): poci.parameter.set(ratio*i) joint = pm.joint(n="{0}_{1:0>2d}_{2}".format(prefix, i, suffix), p=poci.position.get()) joints.append(joint) pm.joint(joints, oj=orientJoint, sao=saoType) return joints
Example #30
Source File: test_ai2rs.py From anima with MIT License | 5 votes |
def test_node_type_is_not_on_the_spec_sheet(self): """testing if no error will be raised when the given node type is not on the conversion spec sheet """ # create a surface node node = pm.createNode('surface') conversion_man = ai2rs.ConversionManager() rs_material = conversion_man.convert(node) self.assertIsNone(rs_material)