← Back to team overview

yade-users team mailing list archive

Re: [Question #657126]: Performing a penetration test

 

Question #657126 on Yade changed:
https://answers.launchpad.net/yade/+question/657126

Jan Stránský proposed the following answer:
> But when you run it using the script , you do not know the ID of the
sphere

of course you (can) know it :-) id is returned by O.bodies.append and
you can access it as body.id, see below

it is a good idea to do things step by step. E.g. it is possible (and OK
in many cases where you are not much interested in the specific body) to
use

O.bodies.append(sphere((0,0,0.30),0.05,material=idSteel))

but then the created body as well as its id "is lost".  For this
situation, a better approach is the one from my previous answer:

hammer = sphere((0,0,0.30),0.05,material=idSteel) # first create a body
hammerID = O.bodies.append(hammer) # than append it to simulation and "save" its ID
...
hammerID = hammer.id # ID can be also accessed directly from the body

then it does not matter if you use

hammer.whatever
or
O.bodies[hammerID].whatever

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.