Broken structure when trying to add more than one emedded component
- Dominant language
- Python
- Stars
- 10
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
```python
tree = deftree.DefTree()
root = tree.get_root()
root.add_attribute( "name", "world" )
root.add_attribute( "scale_along_z", "0" )
root_go = root.add_element( "embedded_instances" )
root_go.add_attribute( "id", "name0" )
go_data = root_go.add_element( "data" )
for i in range( 0, 2 ):
collisionobject_component = go_data.add_element( "embedded_components" )
collisionobject_component.add_attribute( "id", "collisionobject0" )
collisionobject_component.add_attribute( "type", "collisionobject" )
component_data = collisionobject_component.add_element( "data" )
component_data.add_attribute( "collision_shape", "" )
component_data.add_attribute( "type", "COLLISION_OBJECT_TYPE_STATIC" )
component_data.add_attribute( "mass", "0.0" )
component_data.add_attribute( "friction", "0.1" )
component_data.add_attribute( "restitution", "0.5" )
component_data.add_attribute( "group", "default" )
tree.write( "output.collection" )
```
If I add just one block of "embedded_components" then the structure of the file is correct but when it comes to adding two or more embedded_components then it generates broken structure. What do I do wrong?
Outputs:
1. One block of embedded_components generates a correct structure:
```textproto
name: "world"
scale_along_z: 0
embedded_instances {
id: "name0"
children: "model0"
data: "embedded_components {\n"
" id: \"collisionobject0\"\n"
" type: \"collisionobject\"\n"
" data: \"collision_shape: \\\"\\\"\\n"
"type: COLLISION_OBJECT_TYPE_STATIC\\n"
"mass: 0.0\\n"
"friction: 0.1\\n"
"restitution: 0.5\\n"
"group: \\\"default\\\"\\n"
"\"\n"
"}\n"
""
}
```
2. Two blocks - broken structure:
```textproto
name: "world"
scale_along_z: 0
embedded_instances {
id: "name0"
children: "model0"
data: " embedded_components {\n"
" id: "collisionobject0"\n"
" type: "collisionobject"\n"
" data: "collision_shape: \\"\\"\\n"
"type: COLLISION_OBJECT_TYPE_STATIC\\n"
"mass: 0.0\\n"
"friction: 0.1\\n"
"restitution: 0.5\\n"
"group: \\"default\\"\\n"
""\n"
" embedded_components {\n"
" id: "collisionobject0"\n"
" type: "collisionobject"\n"
" data: "collision_shape: \\"\\"\\n"
"type: COLLISION_OBJECT_TYPE_STATIC\\n"
"mass: 0.0\\n"
"friction: 0.1\\n"
"restitution: 0.5\\n"
"group: \\"default\\"\\n"
""\n"
""
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.