Change particle position in python

Asked by Chiara Modenese

Hi folks,

I tried to change particle position in py considering only one component as:

O.bodies[0].state.pos[2]=2; # or O.bodies[0].state.se3[0][2]=2;

but this did not work. Then, if I try to do that by using Vector3, something like:

O.bodies[0].state.pos=Vector3(2,2,2)

it works. Why is that one cannot change a single vector component in py?

Chiara

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
Last query:
Last reply:
Revision history for this message
Best Bruno Chareyre (bruno-chareyre) said :
#1

"Vector3r pos" is a registered attribute. "Real pos[1]" (or whatever) is
not.
I guess per-component definition could be enabled in python wrapping of
eigen, but nobody expected such usage.
You can always type :

O.bodies[0].state.pos=Vector3(O.bodies[0].state.pos[0],XXX,O.bodies[0].state.pos[2])

B

Revision history for this message
Chiara Modenese (chiara-modenese) said :
#2

Ok, I see now. Thanks for workaround.
Chiara

Revision history for this message
Chiara Modenese (chiara-modenese) said :
#3

Thanks Chareyre, that solved my question.