- This topic has 6 replies, 3 voices, and was last updated 4 years, 8 months ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › [SOLVED] Available objects in the factory (python or xml)
Tagged: 64_bits, Linux_other, python, SOFA_1906
I am trying to create some SOFA scenes , but I’m having some trouble trying to know the name of the objects or the properties it has.
In python for example I have:
def createScene(node):
node.addObject("GridMeshCreator", resolution=[2,2])
I copied this from a .scn file
<GridMeshCreator name="loader" filename="nofile" resolution="2 2" />
but its not clear at all what all the available properties for a particular object, which objects are available in the factory (and which with templates) and what type each property is. For example, in the GridMeshCreator example, resolution in .scn is a string but in python is a list.
It would be nice to have documentation to know object names, available templates, properties and type of property.
Hey Juan José,
You are right, it is not simple to have a global idea of the available components and their templates/datas. In my case, I always have the source code of Sofa close and look at the constructors of the component for which I want to see their data. The available templates are usually in the .cpp of the component (looking for RegisterObject
calls).
I think it would not be too hard to implement a python bindings that look through the object factory of Sofa and gives you the list of registered components and their template, I’ll have a look at this.
For the data values requiring a list, it is up to you to give a string or a list. For example, both
node.addObject("GridMeshCreator", resolution="2 2")
and
node.addObject("GridMeshCreator", resolution=[2,2])
should work.
Thanks for your feedback !
Wow, awesome work! Ill check ASAP!
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.