OpenJSCAD.org
OpenJSCAD.org copied to clipboard
Naming Objects
I would like to be able to assign (programmatically) names to objects and have those names be used when exporting to X3D, STL, ... where the export formats support names, so that I can more easily reference the objects in X3D. Support for the animation capabilities of X3D would be great as well.
I have been asked to reassign this issue here: https://github.com/EinsteinsWorkshop/BlocksCAD/issues/17#issuecomment-308742189
@thesourcerer8 Thanks!
We'll see if this is possible, but think so.
@thesourcerer8 can you help define what you would like the X3D file to contain? there's a lot of possibilities.
https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#NamingConventions
https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#Meshes
I'm thinking that a DEF attribrutue could be added.
Yes, a DEF attribute seems to be the way to do it.
Do you want names in another export format, like DXF?
I think it would be a good idea to put the names in all the output formats that support them.
Support of 'name' attribute added to V2 DXF serializer. #684
Comment... each serializer should provide a list of supported attributes, such as 'name' or 'class' or 'id'. In addition, these attributes need to be preserved by generalize(), possibly a new option.
From the forum... concerning SVG serialization
'class' element for sure is interesting as it will ease styling. About 'id', yes it must be used carefully to ensure that each object has its unique id, generally I use names forged from data (line between triangle 23 and 111 has id 'L_23_111', etc.). 'name' is deprecated so it's maybe wise to avoid it, on very old js code I remember i used 'tag', as svg doesn't use it, as svg can use custom attributes, it can be anything. And it would be really great to have exported svg from jscad with such fine details, because it will allow rework those outputs with great ease.
Support of 'id' and ‘class’ attributes added to V2 SVG serializer. #974
Summary of serializers:
- AMF TBD
- DXF support for 'name' attribute #684
- OBJ TBD
- STL impossible as format does not support
- SVG support for 'id' and 'class' attribute #974
- X3D impossible to add names directly to entities
- 3MF support for 'name' attribute #1036
Closing this issue as the relevant serializers have been changed to support names, ids, etc.