thanks agian Adam,
was away for a few days
i can understand why you wouldnt use Iterators for alot of functions for
Speed issues. at the moment i actually want to get an Array Value of
some sort so i can see actual numbers to test if things are right. eg
[x,y,z] or is it UVW for normals?. i'm not sure what its going to return
me but at the moment if i try print any value i get 'NoneType'
so do i have to assign a ArrayType or FloatType to get and individual
value in API?
thanks for the help so far
john
Adam Mechtley wrote:
Yes—it stores the result in the object you pass as a parameter, since it is
passed by reference. As per my example:
meshIter0 = OpenMaya.MItGeometry(dag1)
points = OpenMaya.MPointArray()
meshIter0.allPositions(points, ObjectSpace)
# all the points are now stored in the points object
normals = OpenMaya.MVectorArray()
meshIter1.getNormals(normals, ObjectSpace)
# all the normals are now stored in the normals object
As per your original code:
while not meshIter1.isDone():
p1 = meshIter1.position(ObjectSpace)
normal=OpenMaya.MVector()
meshIter1.getNormal(normal, ObjectSpace)
# the normal is now stored in the normal object
meshIter1.next()
On Fri, Apr 9, 2010 at 9:04 AM, johnvdz <[email protected]> wrote:
Oh thanks Adam for that...
i wouldn't have got that.
so i also tried assigning the GetNormals() but that returns a status to so
i guess thats out to?
i guess the only other option is MfnMesh.GetVertexNormal?
or is that a status object to?
his there a way in python api to get normals? i would like to maybe use
normal in a Deformer node at some point.
john
Adam Mechtley wrote:
The problem is this line:
vector = meshIter1.getNormal(normal, ObjectSpace)
getNormal returns an MStatus object, which Python does not use, and which
will cause Maya to crash unfortunately if you try to capture it in Python.
Depending what you are wanting to do btw a better approach is:
normals = OM.MVectorArray()
meshIter1.getNormals(normals, OM.MSpace.kObject)
Thus you get all the normals in a single API call instead of looping
through
the whole thing and can then do whatever with them in Python. The more API
calls you have, the more translation happens across the SWIG layer, which
will cause your code to execute slower.
On Fri, Apr 9, 2010 at 8:27 AM, johnvdz <[email protected]>
wrote:
Hi all,
just trying the get the Normal direction of a vertex so i can offset a
point locally from its Normal.
at the moment i cant get a value from the Normal at all?
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
selList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(selList)
dag1= OpenMaya.MDagPath()
selList.getDagPath(0,dag1)
meshIter1 = OpenMaya.MItMeshVertex(dag1)
ObjectSpace=OpenMaya.MSpace.kObject
while not meshIter1.isDone():
p1 = meshIter1.position(ObjectSpace)
print p1.x,p1.y,p1.z
normal=OpenMaya.MVector()
vector = meshIter1.getNormal(normal, ObjectSpace)
meshIter1.next()
at the moment this crashes maya after it has finished the loop. i think
its
because i normal=OpenMaya.MVector() is inside the loop.
i have tried this outside the loop but i get "None" as a Print result of
'vector'. I'm pritty new to API so i could have done a few things wrong.
anyway any answers would be appreciated
john
--
http://groups.google.com/group/python_inside_maya
To unsubscribe, reply using "remove me" as the subject.
--
http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya