Still NameError: global name 'inGtsSurface' is not defined
I apologise for the duplicate question, but the answered tag might give the wrong impression
Good evening all,
So, i tried to wrap my code in a python class and call it from somewhere else using python (e.g. python run.py).
However, when i run it i get the following terminal output
Traceback (most recent call last):
File "run.py", line 17, in <module>
simulation.
File "/home/
pred = inGtsSurface(s)
NameError: global name 'inGtsSurface' is not defined
Specifically, the code is
from yade.pack import *
from yade import ymport
import sys
from yade import qt
import gts
sys.path.
from yadeimport import *
import math
class simul():
def __init__(self):
self.g=(0,0,9.81)
def run(self):
from yade import ymport
import sys
from yade import qt
facets = ymport.
rod1 = O.bodies.
s = gts.Surface()
for facet in facets:
vs = [facet.state.pos + facet.state.ori*v for v in facet.shape.
vs = [gts.Vertex(
es = [gts.Edge(
f = gts.Face(
s.add(f)
print s.is_closed()
threshold = 1e-3
s.cleanup(
print s.is_closed()
assert s.is_closed()
# use gts to filter spheres
pred = inGtsSurface(s)
O.engines=[
ForceReset
InsertionS
Interactio
# handle sphere+sphere and facet+sphere collisions
),
NewtonInte
]
sp=pack.
sp.makeCloud(
# remove spheres completely inside walls
for c,r in sp:
if pred(c,0):
continue
O.
O.dt = 0
O.step() # interactions are created afterwards
toErase = set()
for i in O.interactions:
b1,b2 = [O.bodies[i] for i in (i.id1,i.id2)]
if any(isinstance(
toErase = [b for b in toErase if isinstance(
for b in toErase:
O.
O.dt=
def irun(self,num):
print O.time
O.run(num,1)
and the python file calling it is
import os
import math
import operator
import gts
import sys
sys.path.
os.system("ln -s /usr/bin/yade yadeimport.py")
from yadeimport import *
from myclass import simul
simulation=simul()
simulation.run()
simulation.
simulation.
simulation.
Thank you very much for any help, and again sorry for the duplicate,
incidently, the maze file is
http://
John
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- JOHN
- Solved:
- Last query:
- Last reply: