I'm a beginner for python in maya,
i want to use python create vector variables, just like jscript or mel
vector $myVec
how can I do it in python in maya, isn't Tkinter, or just use python itself??
Thanks a lot
Yeah.Y
I'm a beginner for python in maya,
i want to use python create vector variables, just like jscript or mel
vector $myVec
how can I do it in python in maya, isn't Tkinter, or just use python itself??
Thanks a lot
Yeah.Y
I found the answer by myself, just use pymel or API
Good Luck!!
Yeah.Y
learning python atm, and i found this on vectors
CODE
class Vector:
def __init__(self, data):
self.data = data
def __repr__(self):
return repr(self.data)
def __add__(self, other):
data = []
for j in range(len(self.data)):
data.append(self.data[j] + other.data[j])
return Vector(data)
def __sub__(self, other):
data = []
for j in range(len(self.data)):
data.append(self.data[j] - other.data[j])
return Vector(data)
you can then do somthing like this
CODE
x = Vector([1.0, 2.0, 3.0])
y = Vector([2.0, 2.0, 2.0])
print x + y,
#or
print x - y,
depending on what else you want to do u need to add more lines of code to the class
how would i write a line in the vector class to do this ??
CODE
x = Vector([1.0, 2.0, 3.0])
x / 2
# Result: [0.5, 1.0, 1.5] #
i dont want to do this:
CODE
def __div__(self, other):
data = []
for j in range(len(self.data)):
data.append(self.data[j] / other.data[0])
return Vector(data)
###
x = Vector([1.0, 2.0, 3.0])
y = Vector([2.0,])
x / y
i tried to change "data = []" declaration, but since the script is using append it must be a list in this case. if anyone could post a alternate method of doing a vector class ( keeping it simple) it would help me learning about classes