← Back to team overview

yade-users team mailing list archive

Re: [Question #235552]: How to pass a python class to a C++ class

 

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

    Status: Open => Answered

Bruno Chareyre proposed the following answer:
Hi Reza,

Your compilation problem is because you are not simply trying to pass an
argument. The syntax you are using is for registering an attribute (*),
which is more demanding in terms of object type (it has to inherit from
serializable).
It should be possible to achieve what you want by passing arguments, as
shown by Christian. The main bad side is that the template list will be
lost if you save the simulation and reload it latter. If it is really a
problem, you can probably register standard vectors to handle the data,
in the form below:

class Factory {
void setTemplates(python::list templates) {//convert templates into
lists of Vector3r and Real registered below }
YADE_CLASS_...
((vector<vector<Vector3r> >, positions, ...))
((vector<vector<Real> >, radii, ...))
}

HTH

Bruno


(*) https://www.yade-dem.org/doc/prog.html#attribute-registration

On 11/09/13 13:56, Reza Housseini wrote:
> Question #235552 on Yade changed:
> https://answers.launchpad.net/yade/+question/235552
>
> Reza Housseini gave more information on the question:
> Hi Christian
>
> Thanks for your answer. I took my implementation from the
> yadeWrapper.cpp file. But nonetheless it's not working with a
> python::object as an argument type.
>
> The ClumpsFactory is similar to the SpheresFacory, it's spitting out
> clumps for a defined massFlowRate during the simulation.
>


-- 
_______________
Bruno Chareyre
Associate Professor
ENSE³ - Grenoble INP
Lab. 3SR
BP 53
38041 Grenoble cedex 9
Tél : +33 4 56 52 86 21
Fax : +33 4 76 82 70 43
________________

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