Strange problem

Dear all

I'm trying my hand writing some script. I want to create a hacaoideas.py file to be later import into abaqus scripting namespace. 

I tried with this one.

 

hacaoideas.py
------------------------------------------------

def contour(list,model_name,sketch_name): for i in range(0,len(list)-1):    

mdb.models[model_name].sketches[sketch_name].Line(list[i],list[i+1])     mdb.models[model_name].sketches[sketch_name].Line(list[len(list)-1],0)
print 'Countour on the following list of points created'
print '[%s]'%','.join(map(str,list))

-----------------------------------------------

Then in the scripting context of _abaqus2_.guiLog, I typed (I was using Abaqus PDE)

 

import hacaoideas

from abaqus import *

from part import *

mdb.Model('Beam')

mdb.models['Beam'].Part(name='Beam-Part',dimensionality=THREE_D, type=DEFORMABLE_BODY)

mysketch=mdb.models['Beam'].ConstrainedSketch(name='base',sheetSize=10)

point =[(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0)]

hacaoideas.contour(point,'Beam','base')

 

then, Abaqus prompted for error

NameError: global name 'mdb' is not defined. Exit from main file....v...v

 

 

I don't understand the problem here. Should I import abaqus in hacaoideas.py??