← Back to team overview

yade-users team mailing list archive

Re: [Question #267838]: How to use function updateAttrs

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Mike,

updateAttrs is used mainly in serialization (saving/loading) of objects. In
your case, you can directly use

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

if you want to use updateAttrs, is accepts dictionary, whose keys are
srting names of attributes. So it could be

O.bodies[10000].state.updateAttrs({"pos":(0,0,0)})

However, it does not work. Sometimes the variables (like pos) are
internally treated in different way, e.g. pos is one part od Se3 instance,
containing position and orientation, so setting position with updateAttrs
would look like:

s = O.bodies[10000].state
s.updateAttrs({"se3":((0,0,0),s.ori)}) # (0,0,0) is new position, one part
of se3, the other part being orientation

As a conclusion, I would suggest to try to avoid using updateAttrs if
possible :-)

cheers
Jan


2015-06-06 15:46 GMT+02:00 MikeZhao
<question267838@xxxxxxxxxxxxxxxxxxxxx>:

> New question #267838 on Yade:
> https://answers.launchpad.net/yade/+question/267838
>
> There are many updateAttrs function in different classes, According to my
> knowledge, this function is used to change attributes of classes with a
> dictionary. But what's the parameter that I should give?
>
> For instance, I'd like to update  yade.O.bodies[10000].state.pos to
> [0,0,0], I write a code like that:
>
> yade.O.bodies[10000].state.updateAttrs({yade.O.bodies[10000].state.pos:[0,0,0]})
>
> and the result is:
> TypeError: No registered converter was able to produce a C++ rvalue of
> type std::string from this Python object of type Vector3
>
> How should I modify it?
>
> Hope to get some help,
>
> thanks.
>
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

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