How to set the material file name programatically

This topic has been viewed 1905 times and has 1 replies
Thread status: Active
How can I do this? [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
avnerm
Posts: 4
Joined: Thu Apr 26, 2018 8:03 am

How to set the material file name programatically

Post by avnerm »

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?

Thanks,
Avner
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to set the material file name programatically

Post by Puybaret »

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
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 2 guests