confused High priority How to provide floor plan parameters in a file

This topic has been viewed 9558 times and has 10 replies
Thread status: Active
How can I do this? [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
atinesh
Posts: 5
Joined: Fri Aug 31, 2018 12:25 pm
Country: India

How to provide floor plan parameters in a file

Post by atinesh »

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.

Building Parameters:
  1. Floor Plan Area
  2. Wall Position
  3. Wall Thickness
  4. Door & Window Size
  5. Door & Window Position
  6. etc.
    [/list=a]
    Note: We are not concerned about furniture's
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

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:

Code: Select all

<?xml version='1.0'?>
<home version='5500' name='Simple.sh3d'>
  <doorOrWindow name='Door' catalogId='eTeks#door'
    model='com/eteks/sweethome3d/io/resources/door.obj' 
    icon='com/eteks/sweethome3d/io/resources/door.png' 
    x='2.5' y='75.3' angle='4.712389' width='91.5' depth='14.5' height='208.5' 
    modelMirrored='true' movable='false' cutOutShape='M0,0 v1 h1 v-1 z' wallCutOutOnBothSides='true'>
      <sash xAxis='0.05464481' yAxis='0.5862069' width='0.89071035' startAngle='0.0' endAngle='-1.5707964'/>
  </doorOrWindow>
  <doorOrWindow name='Window' catalogId='eTeks#window85x163'
    model='com/eteks/sweethome3d/io/resources/window85x163.obj' 
    icon='com/eteks/sweethome3d/io/resources/window85x163.png' 
    x='209.0' y='298.6' elevation='47.0' angle='3.1415927' width='91.0' depth='10.2' height='174.0' 
    movable='false' cutOutShape='M0,0 v1 h1 v-1 z' wallCutOutOnBothSides='true'>
      <sash xAxis='0.021978023' yAxis='0.7352941' width='0.94505495' startAngle='0.0' endAngle='-1.5707964'/>
  </doorOrWindow>
  <wall id='wall0' wallAtStart='wall3' wallAtEnd='wall1' 
    xStart='0.0' yStart='0.0' xEnd='300.0' yEnd='0.0' height='250.0' thickness='7.5'/>
  <wall id='wall1' wallAtStart='wall0' wallAtEnd='wall2' 
    xStart='300.0' yStart='0.0' xEnd='300.0' yEnd='300.0' height='250.0' thickness='7.5'/>
  <wall id='wall2' wallAtStart='wall1' wallAtEnd='wall3' 
    xStart='300.0' yStart='300.0' xEnd='0.0' yEnd='300.0' height='250.0' thickness='7.5'/>
  <wall id='wall3' wallAtStart='wall2' wallAtEnd='wall0' 
    xStart='0.0' yStart='300.0' xEnd='0.0' yEnd='0.0' height='250.0' thickness='7.5'/>
  <room areaVisible='true'>
    <point x='296.25' y='3.75'/>
    <point x='296.25' y='296.25'/>
    <point x='3.75' y='296.25'/>
    <point x='3.75' y='3.75'/>
  </room>
</home>
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 [font=courier new]Home.xml[/font] entry of a SH3D zip file) will give you plenty of information if needed.
Emmanuel Puybaret, Sweet Home 3D creator
atinesh
Posts: 5
Joined: Fri Aug 31, 2018 12:25 pm
Country: India

Re: How to provide floor plan parameters in a file

Post by atinesh »

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:

Code: Select all

...
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 [font=courier new]Home.xml[/font] 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.
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

The simplest way is probably to use a [font=courier new].sh3d[/font] extension for your file instead [font=courier new].xml[/font], 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 [font=courier new]-open[/font] parameter and the file you want:

Code: Select all

[i]path/to/[/i]SweetHome3D.exe -open [i]path/to/[/i]project.sh3d
But caution, if you will save, the generated SH3D file will be at default file format, i.e. a zip file containing a [font=courier new]Home.xml[/font] entry and other entries for images and 3D models.
Emmanuel Puybaret, Sweet Home 3D creator
fritzz
Posts: 3
Joined: Fri Feb 21, 2020 8:08 pm
Country: US

Re: How to provide floor plan parameters in a file

Post by fritzz »

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.
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

Welcome on the forum, Fritzz.

If you opened a .sh3d file with a zip utility, you may have noticed it contains a file named [font=courier new]ContentDigests[/font] too. This text file helps to check the consistency of a .sh3d file at opening time. When you externally change the resources referenced by [font=courier new]Home.xml[/font] contained in a .sh3d file, you should remove the existing [font=courier new]ContentDigests[/font]. 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 [font=courier new]catalogId[/font] and [font=courier new]image[/font] attributes of its textures from existing values found in the default catalog or in the [font=courier new]PluginTexturesCatalog.properties[/font] file of other texture libraries. Just pay attention to avoid a leading slash / in the value of the [font=courier new]image[/font] attribute (like I did in the [font=courier new]model[/font] and [font=courier new]icon[/font] attributes of the example I posted last time).
Emmanuel Puybaret, Sweet Home 3D creator
fritzz
Posts: 3
Joined: Fri Feb 21, 2020 8:08 pm
Country: US

Re: How to provide floor plan parameters in a file

Post by fritzz »

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?
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

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 [font=courier new]catalogId[/font] attribute, removed [font=courier new]ContentDigests[/font] and [font=courier new]Home[/font] 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 [font=courier new]2>log.txt[/font] after [font=courier new]SweetHome3D.exe[/font] to send error logs to the file [font=courier new]log.txt[/font]).
Attachments
BoxWithManuallySetTexture.sh3d
(14.06 KiB) Downloaded 382 times
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

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 [font=courier new]Contributions.sh3t[/font] textures library imported in Sweet Home 3D. [font=courier new]Contributions.sh3t[/font] is available in this ZIP file.
As explained previously, I set [font=courier new]catalogId[/font] attribute with "Puybaret#pine" and [font=courier new]image[/font] attribute with "contributions/pine.jpg", these values coming from the properties [font=courier new]id#7[/font] and [font=courier new]image#7[/font] in [font=courier new]PluginTexturesCatalog.properties[/font] of [font=courier new]Contributions.sh3t[/font] file.
Attachments
BoxWithTextureSetFromContributionsLibrary.sh3d
(1.3 KiB) Downloaded 346 times
Emmanuel Puybaret, Sweet Home 3D creator
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to provide floor plan parameters in a file

Post by Puybaret »

Finally, note that the [font=courier new]image[/font], [font=courier new]icon[/font], [font=courier new]planIcon[/font] and [font=courier new]model[/font] 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 [font=courier new]jar:[/font] protocol with the syntax [font=courier new]jar:urlZipFile!/entry[/font]

Please, don't abuse of URLs referencing sweethome3d.com!
Attachments
BoxWithTextureSetFromImageURL.sh3d
(1.35 KiB) Downloaded 354 times
Emmanuel Puybaret, Sweet Home 3D creator
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest