Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 180 times and has 4 replies
Waldemar.Hersacher
Member



Germany
Joined: Jan 6, 2024
Post Count: 49
Status: Offline
Reply to this Post  Reply with Quote 
Keep folder structure intact

I was creating some doors to match the thickness of the walls. I added the doors to a furniture library.

Since this a normal zip archive I unpacked it and moved all common files one level up. These files are the material files and the texture. In the obj-file I changed the path of the mtl-file to the correct location. Then I packed the files and placed the furniture library in the subfolder of SH3D.
( I didn't do that with the obj-files but I expect that this will work too)

Inserting the doors shows it completely with all materials.

Saving the home and reopening it the material is gone.

I unpacked the sh3d-file and added the missing mtl-file and texture. I packed it again and opened the home. The material is here again.

But with the next save the additional files have been gone.

Since I have just a few doors the advantage is not so big. But I think with a library like Keet's doors with a lot of double identical files this might be remarkable.

But there is something to take care of:
The files of the furniture libraries will be on the same level. Inserting objects might overwrite an already exiting mtl-file or texture from another library.

One possible solution to this can be:
When for the first time an object is inserted from a library copy the mtl-file(s) and texture file(s) to the sh3d-file giving each a unique number (which is already done to the other files and folders). You need to create an entry with a tag like <UsedLibrary> to create a reference between the file names in the library and the file names in sh3d in the home.xml file.
In the obj-file you need to replace the original mtl-file name with the new file name.
If another object is inserted from the same library you just need to change the mtl-file name.
You can optimize that to only copy those files which are really needed by the object and if another object from the same library is used you need to add only the missing files.

You don't need to do that in the case as it is today that the obj-file, the mtl-file and all textures are in the same subfolder.
----------------------------------------
MSI GP60, Linux Mint 21.3 Virginia base: Ubuntu 22.04 jammy, SH3D 7.5 with Photo-video rendering 2.8
[Jun 18, 2025, 10:13:16 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 1423
Status: Offline
Reply to this Post  Reply with Quote 
Re: Keep folder structure intact

Multiple OBJ files that use the same single MTL file? That should not be a problem, the OBJ file references the MTL file to read the material properties, it doesn't change it. There's no requirement for the MTL file to have the same filename as the OBJ file. I use this often when I generate a series of objects (with C# code) that use the same material. It makes no sense to create what is virtually a copy for each OBJ file.
I'm not sure how that translates when you add it to a library, I'll have to investigate that. I know that when you import an OBJ file into the library it copies a set of OBJ, MTL, and textures to a subdirectory in the library file for that model. In the root of the library a thumbnail image is generated.
I think there is a way to avoid multiple copies of the same textures in the .sh3d project file, I think that is what happens when you use a texture from the default texture catalog: only an id/name is used. Again, I'll have to investigate how much of that is true and how it works.

The question is what do you want to achieve? I remember a post from Emmanuel where he said that textures are only read once when loading the project, even if the image is referenced by multiple models. Unfortunately I can't find that post to get the correct wording of the statement.
----------------------------------------
Dodecagon.nl
1000+ 3D models, manuals, and projects
[Jun 19, 2025, 7:29:59 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Waldemar.Hersacher
Member



Germany
Joined: Jan 6, 2024
Post Count: 49
Status: Offline
Reply to this Post  Reply with Quote 
Re: Keep folder structure intact

There is another thing to take care of. This is the possibility to change the material/color of an object.

I added the same door twice to the home. In the sh3d-file only one subfolder is created. I changed the texture resp. the color of one of the doors. This change is added to the home.xml file in the entry of the object I changed.

This will not lead to a problem.
----------------------------------------
MSI GP60, Linux Mint 21.3 Virginia base: Ubuntu 22.04 jammy, SH3D 7.5 with Photo-video rendering 2.8
[Jun 19, 2025, 10:10:37 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Waldemar.Hersacher
Member



Germany
Joined: Jan 6, 2024
Post Count: 49
Status: Offline
Reply to this Post  Reply with Quote 
Re: Keep folder structure intact

I'm not sure how that translates when you add it to a library, I'll have to investigate that.


The editor will create a subfolder and copy the obj-file in it. It copies the mtl-file and renames it to the same name as the obj-file. The obj-file is changed to reference to the the mtl-file. It copies the texture and renames it to have the name of the obj-file an underscore and its original name. The mtl-file is changed to reference to this texture.

If you add multiple objects you will get the same mtl-file and texture multiple times with different names in the subfolder of each obj.

In my case with three doors with a white panel and three doors with a wooden panel I have the following sizes:
sh3f: 101.543 Bytes -> 92.331 Bytes
sh3d: 303.417 Bytes -> 103.476 Bytes

If you are interested you can download the files.
WaHeModDoors.sh3f
WaHeModDoors_common.sh3f
Version_14_wood.sh3d
Version_14_wood_common.sh3d
----------------------------------------
MSI GP60, Linux Mint 21.3 Virginia base: Ubuntu 22.04 jammy, SH3D 7.5 with Photo-video rendering 2.8
[Jun 19, 2025, 11:39:25 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 1423
Status: Offline
Reply to this Post  Reply with Quote 
Re: Keep folder structure intact

It looks like you understand how objects are organized inside a .sh3d project file.

For others a little expansion on this.
This is a definition in the Home.xml file in the .sh3d file. It defines a model that is added to the project and it describes exactly what you see in your 2D and 3D views.
<pieceOfFurniture id='pieceOfFurniture-9ba18dbf-8b8f-4788-bf3f-30328b35a1fc' level='level-de4bbef8-27e5-41fc-8f1a-ce81a27ae213' name='Cable' model='61/Cable.obj' icon='59' x='28.017944' y='-8.1' elevation='21.6' width='74.1501' depth='3.0' height='52.11289' modelSize='66014'>
<material name='Cable' color='FF1969CC'/>
</pieceOfFurniture>

Let's split that up:
<pieceOfFurniture Start of object definition
id='pieceOfFurniture-9ba18dbf-8b8f-4788-bf3f-30328b35a1fc' Sets a unique id for the object
level='level-de4bbef8-27e5-41fc-8f1a-ce81a27ae213' Id of the level at which the object resides
name='Cable' The name of the object
model='61/Cable.obj' The subdirectory inside the .sh3d file where the object resides ("61") and its OBJ filename ("Cable.obj")
icon='59' The thumbnail icon in the model list
x='28.017944' y='-8.1' elevation='21.6' Position and elevation
width='74.1501' depth='3.0' height='52.11289' The bounding box dimensions of the object
modelSize='66014' The model size (bytes)
>

<material name='Cable' color='FF1969CC'/> A material that may differ from what is in the MTL file of the object

</pieceOfFurniture> End of object definition

Notice that <material > is a child node of <pieceOfFurniture > and not one of the attributes of <pieceOfFurniture >. It has its own attributes "name" and "color".
Depending on the type of object more or different attributes are possible and depending on the materials there can be more lines with <material > or other child nodes.

When you load a project each object is loaded from the subdirectory with the OBJ andf MTL files. Those files do not change when you change material or resize an object. Those changes are save in the <pieceOfFurniture> definition. When you first add a model to your project that definition will reflect the original values as read from the OBJ and MTL files. The important thing to remember is the difference between the stored object and the definition in the Home.Xml file. In the subdirectory the original model remains untouched where the definition in the Home.xml file decribes how you made it look in your plan with changed colors, sizes, etc.

When you have lost a model but you know you have it somewhere in a project you can extract the model from its subdirectory to restore your lost object. Of course you can also export it but that will be including the changes you made in the project, not the original model.
----------------------------------------
Dodecagon.nl
1000+ 3D models, manuals, and projects
[Jun 19, 2025, 11:56:29 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved