1
2 """General utility methods"""
3 __docformat__ = "restructuredtext"
4
5 import maya.OpenMaya as api
6 import mrv.maya.undo as undo
7
8 MScriptUtil = api.MScriptUtil
9
10
11
12
13
14
16 """
17 :return: MVector containing result of function with signature
18 function(double [3])"""
19 su = MScriptUtil()
20 su.createFromDouble(0.0, 0.0, 0.0)
21 ptr = su.asDoublePtr()
22 function(ptr)
23
24 return api.MVector(su.getDoubleArrayItem(ptr,0), su.getDoubleArrayItem(ptr,1), su.getDoubleArrayItem(ptr,2))
25
27 """
28 :return: tuple containing result of function with signature
29 function(float& f1, float& f2)"""
30 suf1 = MScriptUtil()
31 suf2 = MScriptUtil()
32 pf1 = suf1.asFloatPtr()
33 pf2 = suf2.asFloatPtr()
34
35 function(pf1, pf2)
36
37 return (MScriptUtil.getFloat(pf1), MScriptUtil.getFloat(pf2))
38
40 """Set the value in vec_value to passed in function as double [3] and
41 return the result"""
42 su = MScriptUtil()
43 su.createFromList([vec_value.x, vec_value.y, vec_value.z], 3)
44 ptr = su.asDoublePtr()
45 return function(ptr)
46
47
49 """function supports the signature function(double [3] const) and will
50 change the underlying instance to the respective values as retrieved
51 from the passed in vector.
52 The calling method must be enclosed in an undoable decorator.
53
54 :param vec_old_value: vector with the old value of the corresponding getX method
55 :param vec_new_value: vector with new value that is to be set"""
56 op = undo.GenericOperation()
57 op.setDoitCmd( in_double3_as_vector, function, vec_new_value)
58 op.setUndoitCmd( in_double3_as_vector, function, vec_old_value )
59 return op.doIt()
60
61
62
63