Thank you guys the answers. I have developed a big-system in pymel, and I would just like to use the advatage of pymel and I think I will write more wrappers top of it. If something is good why change it or rewrite, do I? I mean the class, pymel.core.Attribute is well-designed (I mentioned in previous mail) so it's not worth to rewrite a new class just because I want to extend it. Later I will jump into pymel more deep, but now I do not know a lot about it, how was built in deep layer. Probably I will attept to develope this staff.
David 2014. február 21., péntek 18:15:36 UTC+1 időpontban elrond79 a következőt írta: > > Though... it probably wouldn't be hard to extend the basic concepts behind > virtual (node) subclasses to attributes. The potential audience seems much > smaller than for virtual nodes, though... so unless there's large demand, I > don't think it's anything we'd implement anytime soon. > If anyone wants to take a whack at implementing it themselves, we're open > to submissions! =) > > > On Thu, Feb 20, 2014 at 10:02 AM, Chad Dombrova <[email protected]<javascript:> > > wrote: > >> >>> The tutorial is about how to create subclass for nodes. >>> What if I want to inherit pymel.core.Attribute class for my subclass? >>> >> >> the advantage of virtual classes is deep integration: you register your >> new virtual node class -- which also tells pymel how to identify nodes that >> should be cast to this type -- and pymel's core commands will casts the >> appropriate nodes to instances of your class. >> >> virtual classes are not currently supported for Attributes. it's also >> not straightforward to directly subclass pymel nodes and attributes, >> because at the lowest level the PyNode class performs a type check on >> instantiation. This allows you to do type assertions when you directly >> instantiate a node type class. for example, here i'm asserting that I want >> a DAG node, but i've stupidly given it a depend node as an argument: >> >> pm.nt.DagNode('lambert1') >> # Error: Determined type is Lambert, which is not a subclass of desired >> type DagNode >> # Traceback (most recent call last): >> # File "<maya console>", line 1, in <module> >> # File >> "/Volumes/sv-dev01/devRepo/chad/python/pymel/pymel/core/general.py", line >> 1943, in __new__ >> # raise TypeError, "Determined type is %s, which is not a subclass of >> desired type %s" % ( pymelType.__name__, cls.__name__ ) >> # TypeError: Determined type is Lambert, which is not a subclass of >> desired type DagNode # >> >> This same, low-level check prevents this from working: >> >> class MyFloatAttribute(Attribute): >> def somethingDumb(self): >> print self.get() + 2.0 >> >> at = MyFloatAttribute('persp.tx') >> # Error: Determined type is Attribute, which is not a subclass of desired >> type MyFloatAttribute >> # Traceback (most recent call last): >> # File "<maya console>", line 5, in <module> >> # File >> "/Volumes/sv-dev01/devRepo/chad/python/pymel/pymel/core/general.py", line >> 1943, in __new__ >> # raise TypeError, "Determined type is %s, which is not a subclass of >> desired type %s" % ( pymelType.__name__, cls.__name__ ) >> # TypeError: Determined type is Attribute, which is not a subclass of >> desired type MyFloatAttribute # >> >> You might consider using a "has-A" object-oriented design, rather than an >> "is-A". in other words, you special class has an attribute on it which it >> uses to perform its specialized function, rather than actually being an >> attribute. >> >> -chad >> >> >> >> >> >> -- >> 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] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/CAGq9Q7FiwHPT_%2Bs228Z20BG_ObXS1Nh7yOVR4058S8Sk7vhTrw%40mail.gmail.com >> . >> >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- 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/562debfc-a61d-4bc8-a51a-726aca94f470%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
