Joined: Apr 26, 2018
Post Count: 4
Status:
Offline
How to set the material file name programatically
Hi, I have a home 3d model with many walls. I added a image file as texture to one of the walls and exported the model to obj format I noticed that a new material was created in the .mtl file with the name wall_74_212. I want to to add texture to every wall and set the wall name programatically, from a script which is external to sh3d.
My questions: What is the indexing logic in the material name? (why the name wall_74_212 ?) Is there a way to programatically set the material name?
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to set the material file name programatically
You shouldn't rely on these numbers. In current implementation, "74" means that it's the material of the 74th wall in your home, and "212" is the 212th shape being exported in the OBJ file. If ever you remove or simply change a wall, you might get different numbers. If you want to set the texture by program on each wall, either you read a SH3D file, update its content and save it with Sweet Home 3D Java API, or you study SH3D file format to update such files with other programming languages (quickly said, a SH3D file is a ZIP file with a Home.xml entry that respects SweetHome3D.dtd + 3D models + images).
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator