India
Joined: Aug 31, 2018
Post Count: 5
Status:
Offline
How to provide floor plan parameters in a file
Hello friends,
We are working on a project where we need to tune building parameters (mentioned below) by some algorithms and visualize it's CAD output. Building parameters will be defined in the file such as .txt, .csv, etc. we just need to import these parameters into CAD software and visualize it. We searched a lot and came across Sweet Home 3D , we tried exploring developers guide section but cannot decide whether it can be done or not. Can we achieve this task with Sweet Home 3D , If not then which other software will be helpful for this task. Any suggestion would be of great help, Thank you.
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
You could create a XML file that respects Sweet Home 3D DTD, then open it with SweetHome3D. Here's a simple file which describes 4 walls, a room, a door and a window:
Don't forget that the coordinates of a wall or a door/window are measured in their middle. For doors and windows, you can reference files available in the program and listed here. Looking at demos and files generated by Sweet Home 3D (the XML is stored in the Home.xml entry of a SH3D zip file) will give you plenty of information if needed.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
India
Joined: Aug 31, 2018
Post Count: 5
Status:
Offline
Re: How to provide floor plan parameters in a file
You could create a XML file that respects Sweet Home 3D DTD, then open it with SweetHome3D. Here's a simple file which describes 4 walls, a room, a door and a window:
...
Don't forget that the coordinates of a wall or a door/window are measured in their middle. For doors and windows, you can reference files available in the program and listed here. Looking at demos and files generated by Sweet Home 3D (the XML is stored in the Home.xml entry of a SH3D zip file) will give you plenty of information if needed.
Hello Puybaret, Thanks for the response. How can I load this .xml in sweethome3D, I couldn't find any option in the menu.
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
The simplest way is probably to use a .sh3d extension for your file instead .xml, so the open file dialog will let you select it. You can also use a command line tu run Sweet Home 3D application followed by -open parameter and the file you want:
But caution, if you will save, the generated SH3D file will be at default file format, i.e. a zip file containing a Home.xml entry and other entries for images and 3D models.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
US
Joined: Feb 21, 2020
Post Count: 3
Status:
Offline
Re: How to provide floor plan parameters in a file
Exactly the info I was seeking and works great...except for textures! Once added to an open file, textures are saved in Home.xml (of the .sh3d zip) perfectly. But the program seems unable to find even its own textures and refuses to open any xml that contains one.
Is there a trick to make this work?
To replicate, create a new file, add walls and rooms with colors only, save, open the .sh3d zip and extract Home.xml. See that the program opens the .xml as expected.
Now repeat the above steps but add just one texture before saving. The program will then throw an error instead of opening the .xml.
To verify the texture is the cause, manually edit the .xml to remove the texture and see the program return to opening the file normally.
I've done everything obvious to help the program find its own texture, but nothing has worked. This is the only obstacle blocking the usage of spreadsheets for composition.
Longtime sh3d tinkerer (and admirer), hope to be a hardcore user shortly.
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
Welcome on the forum, Fritzz.
If you opened a .sh3d file with a zip utility, you may have noticed it contains a file named ContentDigests too. This text file helps to check the consistency of a .sh3d file at opening time. When you externally change the resources referenced by Home.xml contained in a .sh3d file, you should remove the existing ContentDigests. As it’s optional, you will just lose the consistency check at opening, that’s all!
If you want to directly open a XML file without its texture images stored in a .sh3d file, you’ll have to indicate the catalogId and image attributes of its textures from existing values found in the default catalog or in the PluginTexturesCatalog.properties file of other texture libraries. Just pay attention to avoid a leading slash / in the value of the image attribute (like I did in the model and icon attributes of the example I posted last time).
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
US
Joined: Feb 21, 2020
Post Count: 3
Status:
Offline
Re: How to provide floor plan parameters in a file
Thanks, great community here. And thanks for the guidance; here's what I've found:
Success opening the plain .xml, but only when 'image=' value matches the spec on the default catalog page you linked. Ex. "/com/eteks/sweethome3d/io/resources/textures/smallRedBricks.jpg"
Important to note: The leading slash has to be removed.
This makes it possible to read, modify and write XMLs using 'built-in' images, many thanks.
But still no joy using arbitrary images. Tried all kinds of things, from using fully-qualified filenames to playing with the ContentDigests and Home files -- just can't get the program to open the .xml when an arbitrary image is specified. Ex.:
Do as above w/ texture, save and close, extract Home.xml and file '0', rename '0' as arbtex.jpg (or anything), and manually edit the .xml to match. It will not open! Nor will it open using any other texture image. Please some more magic to make this work?
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
Great you could make it work partly!
Here's a SH3D file where I replaced the image "2" by "sea.jpg", used as a texture of a simple box. Then I removed the obsolete catalogId attribute, removed ContentDigests and Home files, saved the SH3D file and it worked like expected. You're probably very close to a working solution.
Maybe we could get more information about the opening error, if you shared the error logs: just run the program from a Terminal window to get it (under Windows, add 2>log.txt after SweetHome3D.exe to send error logs to the file log.txt).
---------------------------------------- BoxWithManuallySetTexture.sh3d
(14395 bytes)
(Download count: 117)
(Box with a manually set texture)
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
And here's a home XML file renamed with a SH3D extension, to be able to open it in Sweet Home 3D. This file references a box of the default catalog and a pine texture found in Contributions.sh3t textures library imported in Sweet Home 3D. Contributions.sh3t is available in this ZIP file. As explained previously, I set catalogId attribute with "Puybaret#pine" and image attribute with "contributions/pine.jpg", these values coming from the properties id#7 and image#7 in PluginTexturesCatalog.properties of Contributions.sh3t file.
---------------------------------------- BoxWithTextureSetFromContributionsLibrary.sh3d
(1330 bytes)
(Download count: 94)
(Box with a texture set from Contributions.sh3t library)
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
France
Joined: Nov 7, 2005
Post Count: 9420
Status:
Offline
Re: How to provide floor plan parameters in a file
Finally, note that the image, icon, planIcon and model attributes can also be URLs, like in the attached example showing Sweet Home 3D logo on the texturable box referenced on sweethome3d.com server. When you want to reference an entry within a zip file, you can use jar: protocol with the syntax jar:urlZipFile!/entry
Please, don't abuse of URLs referencing sweethome3d.com!
---------------------------------------- BoxWithTextureSetFromImageURL.sh3d
(1384 bytes)
(Download count: 83)
(Box with texture set from image URL)
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator