← Back to team overview

yade-users team mailing list archive

[Question #235866]: problem with PyRunner when importing Yade in python

 

New question #235866 on Yade:
https://answers.launchpad.net/yade/+question/235866

Hi,
I imported Yade in python like described in [1].
This works but when I create a class in which Yade is called and add a PyRunner that calls a function of the class, I get an error:
NameError: name 'self' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module

Can somebody help me with that, please?

here is the code:
import sys
sys.path.append('/home/dummy/Yade/YadePythonImport')
from yadePythonImport import *

class MyYadeSim():
    def __init__(self):
        self.data = []        
        O.engines=[ForceResetter(),
        	   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
        	   InteractionLoop(
        		  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
        		  [Ip2_FrictMat_FrictMat_MindlinPhys()],
        		  [Law2_ScGeom_MindlinPhys_Mindlin()]       
        	   ),NewtonIntegrator(gravity=(0,0,-9.81), label='newtonIntegrator'),
            PyRunner(iterPeriod=1, command="self.storeData()", label='storage')
        	]
    def run(self):
        O.run(10,True)
        print self.data
    def storeData(self):
        self.data.append(O.time)
if __name__ == "__main__":
    mySim = MyYadeSim()
    mySim.run()

------
[1] https://yade-dem.org/doc/user.html#importing-yade-in-other-python-applications

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.