djx
I'm not much of a programmer, so forgive me if this is a silly question.
I have written a class that calls the following
soup().create('boundingObject',bSkipSel=True)


This works fine if I write the class in the maya script editor, but if I import it from a file, then I get a NameError when I try to instantiate the class.

Is there some way to import soup into my class? Or am I trying to do it completely wrong?

thanks
David
Reply 0 0
pshipkov
Not far ago there was another person who asked similar question. I got his script and ran it - everything was fine. Today i verified that again:
created .py scriptie like this:

class main(object):
  def __init__(self):
    soup().createNode("boundingObject")

imported it in Maya, ran it - worked ok. Just to make sure - you are loading the plugin before running your script ?

Reply 0 0
djx
Thanks Peter. That'skind of what I already was doing, but to be sure I copy and pasted those 3 lines into soupDev.py
Then I did this
import soupDev
b = soupDev.main()


But it still gives me the "global name 'soup' is not defined" error. Obviously am I doing something wrong. Any ideas?

I do have the plugin loaded, btw.
If I add main() to the end of the file and do execfile('soupDev.py') then it works, but I want to be able to import it.

thanks

Reply 0 0
djx
I ended up getting it to work like this.
soupDev.py.....

class main:
    def __init__(self,soup):
        soup.create('boundingObject')

Then in maya I do this...

import soupDev
b = soupDev.main(soup())

I'm happy its working, and I dont want to waste your time Peter, but I'd love to hear if you (or anybody else) think this is a good solution, or if I missed something obvious with your previous advice.

cheers
David
Reply 0 0
Reply