Previous Thread  Next Thread

chat icon to include python files in an other script in Blender

c-leo

Posted: Fri Jul 11, 2003 5:10 pm
Joined: 01 Jul 2003
Posts: 8
i would like import a file in a blender plugin, which is in the same directory

so i 've written the import, but when i use a class of the file imported, i have this mistake:
NameError: name 'Md3Frame' is not defined

How to resolve this problem?
Reply with quote


theeth

Posted: Fri Jul 11, 2003 5:33 pm
Joined: 16 Oct 2002
Posts: 1177
add the path to this module to the python path variable

Code:

import sys
sys.path.append("c:/blah/blah/blah/")


Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Reply with quote


c-leo

Posted: Mon Jul 14, 2003 7:39 pm
Joined: 01 Jul 2003
Posts: 8
it doesn't work

Here is an example of what i would like doing

my file "module.py"

class Class:
def __init__ (self):
pass

my file "main.py"
import module
import sys
sys.path.append("/home/info/An-01-02/levimond/blender/plugins")
myClass = Class ()


i want execute "main.py" in Blender but i get this mistake:
Traceback (most recent call last):
File "main.py.001", line 6, in ?
NameError: name 'Class' is not defined

So, how can i resolve this problem ?
Reply with quote


theeth

Posted: Mon Jul 14, 2003 9:25 pm
Joined: 16 Oct 2002
Posts: 1177
use either this

Code:

from module import *

...

myClass = Class()


or this

Code:

import module

...

myClass = module.Class()


Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group