我尝试在 python 中创建一个类(使用 XSI / Softimage)来覆盖默认方法。
class transform(object):
def __init__ (self) :
self.object = self._build()
self.type = ''
def _build (self):
object = None
return object
@property
def name(self):
name = xsi.getValue(str(self.object) + '.Name')
return str(name)
@name.setter
def name(self, value):
name = xsi.setValue(str(self.object) + '.Name', value)
self.object = str(name)
################## TRANSLATE ######################
@property
def tx(self):
tx = xsi.getValue(str(self.object) + '.kine.local.posx')
return tx
@tx.setter
def tx(self, value):
tx = xsi.setValue(str(self.object) + '.kine.local.posx', value)
@property
def ty(self):
ty = xsi.getValue(str(self.object) + '.kine.local.posy')
return ty
@ty.setter
def ty(self, value):
ty = xsi.setValue(str(self.object) + '.kine.local.posy', value)
@property
def tz(self):
tz = xsi.getValue(str(self.object) + '.kine.local.posz')
return tz
@tz.setter
def tz(self, value):
tz = xsi.setValue(str(self.object) + '.kine.local.posz', value)
但正如你所看到的,我重复了很多。我怎样才能简化这个?也许与元类?