Hi all I am trying to do and learn some maya api (I have zero knowledge of
them)
The following code was taken from an example that I have read online and
while testing it out, I have a few questions in mind..
1. In that test() function, as the world_pos variable is calling out to the
Point class, how would I know which of the 4 functions in class Point it is
trying to call from?
2. Also, I tried to insert a print statement to show me what type it will
return by using type(world_pos), it give me result <class
'spPaint3dContext.Point'> as I was expecting results such as dict, list
etc. Then when I insert it into the functions within class, it is telling
me that it is part of MVector etc..
So, is that any ways that I can expect it to tell me similar like dict/list
etc?
class Point(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def asMPoint(self):
return om.MPoint(self.x, self.y, self.z)
def asMFPoint(self):
return om.MFloatPoint(self.x, self.y, self.z)
def asMVector(self):
return om.MVector(self.x, self.y, self.z)
def asMFVector(self):
return om.MFloatVector(self.x, self.y, self.z)
def test(v1, v2):
...
...
click_pos = om.MPoint()
world_pos = Point(click_pos.x, click_pos.y, click_pos.z)
# Suppose the following values for click _pos x, y and z...
# click_pos.x : -13.2409
# click_pos.y : 44.7756
# click_pos.z : -66.3071
This is a bit off-topic but I have this function where it has '2' return
variables but they are controlled by this 'smooth' parameter.
The reason that this function was wrote it this way was due to a checkbox,
thus if it is checked - smooth = True, unchecked - smooth = False
Was wondering if this is an acceptable way for me to write it this way?
def getNormal(self, smooth = False):
if smooth:
normal = om.MVector()
fn_mesh = om.MFnMesh(self.dagMeshTargetSurface)
fn_mesh.getClosestNormal(self.hitPoint.asMPoint(), normal, om.MSpace
.kWorld, None)
return normal
else:
hit_facept = om.MScriptUtil()
om.MScriptUtil().setInt(hit_facept.asIntPtr(),self.hit_face)
itMesh = om.MItMeshPolygon(self.dagMeshTargetSurface)
itMesh.setIndex(self.hit_face, hit_facept.asIntPtr())
triVertsArray = om.MPointArray()
triIndexArray = om.MIntArray()
itMesh.getTriangle(self.hit_triangle, triVertsArray, triIndexArray,
om.MSpace.kWorld)
return self.getCrossProduct(triVertsArray[0], triVertsArray[1],
triVertsArray[2])
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/76b30274-4600-4022-a450-90b9c75c399b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.