On Wednesday, 17 April 2013 10:59:46 UTC+1, Mat  wrote:
> are you saying you want to add functions to a variable?  in that sense i 
> think a class would work for you.  can you explain what type of magic trick 
> would exist and what the goal is?  Do you not want to update the main code at 
> all? just changing some other module and adding it?  
> 
> 
> 
> "I basically want to have a piece of main code with lets say "place holders" 
> that will be fill in once I run commands. This way I hope to be able to add 
> new and more parts to the script to core code as we need them rather than 
> code it 1 by 1 to each iteration."
> 
> 
> 
> that sounds like you just want to import some module mymodule.py and have 
> some function calls that you already know you will do later and what you will 
> pass the functions and what you will get back, then later fill in the module. 
>  I cant think of when that would be useful since you need to either use the 
> info or not, and you will still need to edit the main code.
> 
> 
> 
> 
> On Wed, Apr 17, 2013 at 6:29 PM, Daz <[email protected]> wrote:
> 
> Heya
> 
> 
> 
> I actually have 2 questions atm. I'm scripting some tools for studio where I 
> work and I think its time for me to start thinking a bit more about structure 
> and how can I get the code to look and behave better rather than just trying 
> to get it to do the stuff I want it to do...
> 
> 
> 
> 
> So one of the tools I wrote is an semi-automatic material manager. As it is 
> now it work pretty good, however any changes I want to do result in a lot of 
> copy/paste and its very time consuming. Now atm each iteration that happen is 
> just a copy of main code + new variables. I was wondering if there is a way 
> to code some kind off (well I think it is) class so that script can call back 
> to it, plug new variables and then do the magic trick...
> 
> 
> 
> 
> Now I did read about classes a while back and yesterday and my tiny brain 
> still don't get it atm... - no worries I'll get there eventually...
> 
> 
> 
> In any case here is a graphical thing I'd like to do, its better for me to 
> show it rather than write it...
> 
> 
> 
> http://imgur.com/gUbZJ2j
> 
> 
> 
> I basically want to have a piece of main code with lets say "place holders" 
> that will be fill in once I run commands. This way I hope to be able to add 
> new and more parts to the script to core code as we need them rather than 
> code it 1 by 1 to each iteration.
> 
> 
> 
> 
> So is the Classes the right thing I need or what is it the thing I need to 
> research?
> 
> 
> 
> So as to second issue. I tried to do the thing above but not much luck tho... 
> I didnt use classes. I wanted to just use functions but o well... Any ideas 
> why this code is not working ?
> 
> 
> 
> NOT working:
> 
> http://pastebin.com/h2TP6Vmm
> 
> 
> 
> Working:
> 
> http://pastebin.com/v02SZ7Vg
> 
> 
> 
> --
> 
> 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 post to this group, send email to [email protected].
> 
> For more options, visit https://groups.google.com/groups/opt_out.

Heya

Tanks for fast reply!

Well at the moment I have lets say this http://pastebin.com/v02SZ7Vg 

Which share 50% of the same code lets call it CODE_A. I have 25x def like that 
1 for each material. The issue is that if I want to change the CODE_A and add a 
check or something like that, I have to go over 25 def and do it 1 by 1. What I 
would like to have is 1 core code and top that will be called back from each 
def once I run command. Like this http://pastebin.com/h2TP6Vmm - but this dont 
work, I dont know why :(

I basically want to learn and see if I can write in a way that all code that is 
sharable or repeatable in many sub functions could possibly referenced rather 
than preloaded which each function.

-- 
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to