Skip to content

[SofaPython3] Add in DataHelper dedicated to-string conversion from basedata#189

Merged
fredroy merged 1 commit intosofa-framework:masterfrom
CRIStAL-PADR:pr-add-basedata-to-string-conversion
Sep 23, 2021
Merged

[SofaPython3] Add in DataHelper dedicated to-string conversion from basedata#189
fredroy merged 1 commit intosofa-framework:masterfrom
CRIStAL-PADR:pr-add-basedata-to-string-conversion

Conversation

@damienmarchal
Copy link
Contributor

In SofaPython it was possible do write:
node.createObject("MechanicalObejct", position=loader.position)
This was working as loader.position was returning the values of the data field.

In SofaPython3 ithis will fails as loader.position is not returning anymore the values but the data:
node.createObject("MechanicalObejct", position=loader.position)
  

Object creation is still using a systematic to-string conversion (see PR #45), so the data are converted to string using the "repr" operator which does not necesserly generate a sofa-compatible string.
When the object to convert is a BaseData... it is much better to rely on the getValueString() fonction which returns a string compatible with sofa.
 

…ata field to increase compatibility with SofaPython(2)
@fredroy fredroy merged commit 7be1b21 into sofa-framework:master Sep 23, 2021
@guparan guparan added this to the v21.12 milestone Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants