Results 1 to 2 of 2

Thread: How to use daeElement -> clone()

  1. #1

    How to use daeElement -> clone()

    Hi,

    I m trying to clone an element, update some of its values and push it to its library:

    if (domJoint *joint = daeSafeCast<domJoint>(inst_joint->getUrl().getElement()))
    {
    if (daeElement *new_joint = joint->clone())
    {
    // calc new id ...
    // ...

    new_joint->setAttribute("new_id", id.c_str()); // this crashes, new_joint is neither NULL nor an daeElement
    // ...

    // parent is the "library_joints" element
    joint->getParent()->add(new_joint);
    }
    }

    Can someone help me?

  2. #2

    Re: How to use daeElement -> clone()

    Solved:

    This assignment is necessary:

    Code :
    new_joint = joint->getParent()->add(new_joint);

    Then, the access to attributes/elements of new_joint is possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •