本文整理匯總了Python中maya.OpenMaya.MDagPath方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenMaya.MDagPath方法的具體用法?Python OpenMaya.MDagPath怎麽用?Python OpenMaya.MDagPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.OpenMaya
的用法示例。
在下文中一共展示了OpenMaya.MDagPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getSkinWeights
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getSkinWeights(dag, skinCluster, component):
"""
Get the skin weights of the original vertex and of its connected vertices.
:param OpenMaya.MDagPath dag:
:param OpenMayaAnim.MFnSkinCluster skinCluster:
:param OpenMaya.MFn.kMeshVertComponent component:
:return: skin weights and number of influences
:rtype: tuple(OpenMaya.MDoubleArray, int)
"""
# weights variables
weights = OpenMaya.MDoubleArray()
# influences variables
influenceMSU = OpenMaya.MScriptUtil()
influencePTR = influenceMSU.asUintPtr()
# get weights
skinCluster.getWeights(dag, component, weights, influencePTR)
# get num influences
num = OpenMaya.MScriptUtil.getUint(influencePTR)
return weights, num
示例2: modify_radius
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def modify_radius(self):
""" modify the brush radius """
delta_x = self.state.last_x - self.state.cursor_x
view = window_utils.active_view()
cam_dag = om.MDagPath()
view.getCamera(cam_dag)
cam_node_fn = node_utils.get_dgfn_from_dagpath(cam_dag.fullPathName())
cam_coi = cam_node_fn.findPlug('centerOfInterest').asDouble()
step = delta_x * (cam_coi * -0.01)
if (self.state.radius + step) >= 0.01:
self.state.radius += step
else:
self.state.radius = 0.01
示例3: get_mesh_fn
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def get_mesh_fn(target):
""" get mesh function set for the given target
:param target: dag path of the mesh
:return MFnMesh """
if isinstance(target, str) or isinstance(target, unicode):
slls = om.MSelectionList()
slls.add(target)
ground_path = om.MDagPath()
slls.getDagPath(0, ground_path)
ground_path.extendToShapeDirectlyBelow(0)
ground_node = ground_path.node()
elif isinstance(target, om.MObject):
ground_node = target
ground_path = target
elif isinstance(target, om.MDagPath):
ground_node = target.node()
ground_path = target
else:
raise TypeError('Must be of type str, MObject or MDagPath, is type: {}'.format(type(target)))
if ground_node.hasFn(om.MFn.kMesh):
return om.MFnMesh(ground_path)
else:
raise TypeError('Target must be of type kMesh')
示例4: getGeometryComponents
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getGeometryComponents(skinCls):
"""Get the geometry components from skincluster
Arguments:
skinCls (PyNode): The skincluster node
Returns:
dagPath: The dagpath for the components
componets: The skincluster componets
"""
fnSet = OpenMaya.MFnSet(skinCls.__apimfn__().deformerSet())
members = OpenMaya.MSelectionList()
fnSet.getMembers(members, False)
dagPath = OpenMaya.MDagPath()
components = OpenMaya.MObject()
members.getDagPath(0, dagPath, components)
return dagPath, components
示例5: getCurrentWeights
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getCurrentWeights(skinCls, dagPath, components):
"""Get the skincluster weights
Arguments:
skinCls (PyNode): The skincluster node
dagPath (MDagPath): The skincluster dagpath
components (MObject): The skincluster components
Returns:
MDoubleArray: The skincluster weights
"""
weights = OpenMaya.MDoubleArray()
util = OpenMaya.MScriptUtil()
util.createFromInt(0)
pUInt = util.asUintPtr()
skinCls.__apimfn__().getWeights(dagPath, components, weights, pUInt)
return weights
######################################
# Skin Collectors
######################################
示例6: getComponent
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getComponent(name):
"""
Args:
name (str)
Returns:
MOBject
"""
selList = om.MSelectionList()
selList.add (name)
dagPath = om.MDagPath()
component = om.MObject()
selList.getDagPath(0, dagPath, component)
return component
#----------------------------------------------------------------------
示例7: getDagPathComponents
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getDagPathComponents(compList):
"""
Args:
compList (list)
Returns:
MObject
"""
currSel = cmds.ls(sl=1, l=1)
cmds.select(compList, r=1)
selList = om.MSelectionList()
om.MGlobal.getActiveSelectionList(selList)
dagPath = om.MDagPath()
components = om.MObject()
selList.getDagPath(0, dagPath, components)
cmds.select(cl=1)
try:
cmds.select(currSel, r=1)
except:
pass
return dagPath, components
#----------------------------------------------------------------------
示例8: getNormals
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getNormals(dag):
"""
Get the average normal in world space of each vertex on the provided mesh.
The reason why OpenMaya.MItMeshVertex function has to be used is that the
MFnMesh class returns incorrect normal results.
:param OpenMaya.MDagPath dag:
:return: Normals
:rtype: list
"""
# variables
normals = []
iter = OpenMaya.MItMeshVertex(dag)
while not iter.isDone():
# get normal data
normal = OpenMaya.MVector()
iter.getNormal(normal, OpenMaya.MSpace.kWorld)
normals.append(normal)
iter.next()
return normals
示例9: getConnectedVertices
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getConnectedVertices(dag, component):
"""
index -> OpenMaya.MFn.kMeshVertComponent
:param OpenMaya.MDagPath dag:
:param OpenMaya.MFn.kMeshVertComponent component:
:return: Initialized component(s), number of connected vertices
:rtype: tuple(OpenMaya.MFn.kMeshVertComponent, int)
"""
connected = OpenMaya.MIntArray()
# get connected vertices
iter = OpenMaya.MItMeshVertex(dag, component)
iter.getConnectedVertices(connected)
# get component of connected vertices
component = asComponent(connected)
return component, len(connected)
示例10: dagPath
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def dagPath(self):
"""Return a om.MDagPath for this node
Example:
>>> _ = cmds.file(new=True, force=True)
>>> parent = createNode("transform", name="Parent")
>>> child = createNode("transform", name="Child", parent=parent)
>>> path = child.dagPath()
>>> str(path)
'Child'
>>> str(path.pop())
'Parent'
"""
return om.MDagPath.getAPathTo(self._mobject)
示例11: _encodedagpath1
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def _encodedagpath1(path):
"""Convert `path` to Maya API 1.0 MObject
Arguments:
path (str): Absolute or relative path to DAG or DG node
Raises:
ExistError on `path` not existing
"""
selectionList = om1.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError("'%s' does not exist" % path)
dagpath = om1.MDagPath()
selectionList.getDagPath(0, dagpath)
return dagpath
示例12: sortKey
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def sortKey(self):
"""
Computed property that builds a sort key based on a
combination of attributes.
Allows sorting to consider multiple keys.
"""
if self.dagObj:
self.apiType = self.dagObj.apiType()
dagCopy = om.MDagPath(self.dagObj)
try:
dagCopy.extendToShape()
self.shapeApiType = dagCopy.apiType()
except RuntimeError:
self.shapeApiType = om.MFn.kInvalid
key = '%s%s%s' % (self.apiType, self.shapeApiType, self.name)
return key
示例13: sortKey
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def sortKey(self):
"""
Computed property that builds a sort key based on a
combination of attributes.
Allows sorting to consider multiple keys.
"""
if self.dagObj:
dagCopy = om.MDagPath(self.dagObj)
try:
dagCopy.extendToShape()
self.apiType = dagCopy.apiType()
except RuntimeError:
self.apiType = self.dagObj.apiType()
key = '{0}{1}'.format(self.apiType, self.name)
return key
示例14: getCurveFn
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def getCurveFn(self):
inputCurvePlug = OpenMaya.MPlug(self.thisMObject(), instanceAlongCurveLocator.inputCurveAttr)
curve = getSingleSourceObjectFromPlug(inputCurvePlug)
# Get Fn from a DAG path to get the world transformations correctly
if curve is not None:
path = OpenMaya.MDagPath()
trFn = OpenMaya.MFnDagNode(curve)
trFn.getPath(path)
path.extendToShape()
if path.node().hasFn(OpenMaya.MFn.kNurbsCurve):
return OpenMaya.MFnNurbsCurve(path)
return None
# Calculate expected instances by the instancing mode
示例15: gather_influence_weights
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPath [as 別名]
def gather_influence_weights(self, dag_path, components):
"""Gathers all the influence weights
:param dag_path: MDagPath of the deformed geometry.
:param components: Component MObject of the deformed components.
"""
weights = self.__get_current_weights(dag_path, components)
influence_paths = OpenMaya.MDagPathArray()
influence_count = self.fn.influenceObjects(influence_paths)
components_per_influence = weights.length() // influence_count
for ii in range(influence_paths.length()):
influence_name = influence_paths[ii].partialPathName()
# We want to store the weights by influence without the namespace so it is easier
# to import if the namespace is different
influence_without_namespace = shortcuts.remove_namespace_from_name(
influence_name
)
self.data["weights"][influence_without_namespace] = [
weights[jj * influence_count + ii]
for jj in range(components_per_influence)
]