Hey JP, " Instead of having to write a function where I pass in a ton of arguments" - that makes a sense I hadn't thought about it that way. So after animating with your code i am noticing popping, I have taken a closer look why its popping but just FYI. You could try a match procedure, this is what I like to do. i.e record position, switch parent and then match to the recorded position.
I do like your code how you build and add parent switching attributes. Nice stuff. -T On Tue, Apr 13, 2010 at 10:47 AM, John Patrick <[email protected]> wrote: > Hey Te, > > I think one of the basic ideas I'm finding is that classes can be used to > increase the flexibility and modularity of code. It seems to make sense to > me to start thinking about using them when a certain task I want to perform > might have a lot of "options." Instead of having to write a function where > I pass in a ton of arguments and then do a bunch of argument checking within > the function, I can instantiate a class and use its methods to set up the > options. I think it makes sense when you are trying to write code that you > want to reuse a lot, but in slightly different ways. At least, that's where > my [limited] understanding is at. > > The code I posted ain't the best example of taking advantage of OOP (in > fact, it's quite bad imo)...but I think it's a personal stepping-stone to > breaking out of the procedural mindset. It seems like one of those things > you just have to work with and try out a lot before it starts to click. One > of the things I've found so far is that it can be a bit more work up front > to set up a class, so *not* using them unless there's a reason to is half > the battle. > > On Sun, Apr 11, 2010 at 4:23 PM, Te Wilson <[email protected]>wrote: > >> Hey JP, >> >> Pretty slick, I haven't animated with it but the first intital test seemed >> to work pretty well. So I am trying to cut my teeth with classes and >> instances when and where to best utilize class functions. Did you discover >> resaons or have suggestions "WHY to create classes, WHEN to >> create them"? >> >> >> On Fri, Apr 2, 2010 at 10:33 PM, JP <[email protected]> wrote: >> >>> Hey All, >>> >>> Just wanted to see if anyone felt like taking a peek at a space- >>> switching script I've been working on lately. I'm still trying to >>> wrap my head around the right way to use Python OOP functionality, and >>> I thought a script that created and removed children and parents might >>> be a good way to try and figure it out. The script is functional, but >>> I feel like it's not quite as robust as I'd like. >>> >>> Here's the script (It requires PyMEL 1.0 or greater to run): >>> http://pastebin.com/DiQexWQT >>> >>> If anyone has any tips, feedback, ideas, thoughts, etc - I'd love to >>> hear 'em. I'm trying to figure out WHY to create classes, WHEN to >>> creat e them, what advantages putting data in a class structure offers >>> over procedural programming, etc. >>> >>> Thanks! >>> >>> -JP >>> >>> -- >>> 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 >> > > > > -- > John Patrick > 404-242-2675 > [email protected] > http://www.canyourigit.com > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya
