JAVA: How to change the default furniture catalog?

This topic has been viewed 10075 times and has 7 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
Sweeto
Posts: 5
Joined: Tue Nov 24, 2015 3:15 pm

JAVA: How to change the default furniture catalog?

Post by Sweeto »

Hello guys,

I want to modify the default folders and furniture, that are displayed on startup. I have set up Sweet Home 3D in Eclipse. I am fairly new to Java, I must confess.

What I have found so far is this post: http://www.sweethome3d.com/support/forum/viewthread_thread,2422#10982 , but it explains, how to remove the default folders completely by editing the build.xml file.

The previously mentioned post let me to the location, where I could change the folder's and furniture's names:

Code: Select all

D:\Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io 
You can also find the DefaultFurnitureCatalog class at this location.

Could you please point me in the right direction? What do I have to do to add my own furniture models to the default menu? Is there another config file? In which folder do I have to put the model files?

Greetings,

Sweeto
Sweeto
Posts: 5
Joined: Tue Nov 24, 2015 3:15 pm

Re: JAVA: How to change the default furniture catalog?

Post by Sweeto »

Ok, I've finally found the right file, where I can set the path of the default furniture files. Apparently all furniture files, that have been added in this file, have the extension ".obj" (exception: the light sources are also categorized as furniture, but they don't have an obj-file).

1. All files, that are nessesary to change the default categories/folders and default furniture are in this folder or in it's subfolders:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io
1.1 All of the model files (.obj) and preview images (.png) are at this location:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io\resources
1.2 All of the contributed model files and preview images are at this location:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io\resources\contributions
2. Some files from the io-folder (see above):
2.1 ContributedFurnitureCatalog.properties (used to set the path, size,...)

Code: Select all

id#1=Sheep#spiralStaircase
name#1=Spiral staircase
tags#1=
category#1=Miscellaneous
icon#1=/com/eteks/sweethome3d/io/resources/contributions/spiralStaircase.png
model#1=/com/eteks/sweethome3d/io/resources/contributions/spiralStaircase.obj
width#1=148.4
depth#1=133.1
height#1=271
dropOnTopElevation#1=-1
movable#1=false
doorOrWindow#1=false
staircaseCutOutShape#1=M0,0.35 h0.47 l0.375,-0.35 l0.088,0.118 A0.5,0.5 0 1,1 0,0.35 z
creator#1=Sheep

2.2 ContributedFurnitureCatalog_de.properties (language file, used for translation only)

Code: Select all

name#1=Wendeltreppe
tags#1=
category#1=Verschiedenes
2.3 DefaultFurnitureCatalog.properties

Code: Select all

id#1=eTeks#bed140x190
name#1=Bed 140x190
tags#1=
category#1=Bedroom
icon#1=/com/eteks/sweethome3d/io/resources/bed140x190.png
model#1=/com/eteks/sweethome3d/io/resources/bed140x190.obj
width#1=158
depth#1=208
height#1=70
dropOnTopElevation#1=48
movable#1=true
doorOrWindow#1=false
creator#1=eTeks
2.4 DefaultFurnitureCatalog_de.properties

Code: Select all

name#1=Bett 140x190
tags#1=
category#1=Schlafzimmer
Sweeto
Posts: 5
Joined: Tue Nov 24, 2015 3:15 pm

Re: JAVA: How to change the default furniture catalog?

Post by Sweeto »

The function readDefaultFurnitureCatalogs in

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io\DefaultFurnitureCatalog.java
reads the default furniture catalog, the contributed furniture catalog and the additional furniture catalog:

Code: Select all

 
  private void readDefaultFurnitureCatalogs(UserPreferences preferences,
                                            Map<FurnitureCategory, Map<CatalogPieceOfFurniture, 
Integer>> furnitureHomonymsCounter,
                                            List<String> identifiedFurniture) {
    // Try to load com.eteks.sweethome3d.io.DefaultFurnitureCatalog property file from classpath 
    String defaultFurnitureCatalogFamily = DefaultFurnitureCatalog.class.getName();
    readFurnitureCatalog(defaultFurnitureCatalogFamily, 
        preferences, furnitureHomonymsCounter, identifiedFurniture);
    
    // Try to load com.eteks.sweethome3d.io.ContributedFurnitureCatalog property file from classpath 
    String classPackage = defaultFurnitureCatalogFamily.substring(0, defaultFurnitureCatalogFamily.lastIndexOf("."));
    readFurnitureCatalog(classPackage + "." + CONTRIBUTED_FURNITURE_CATALOG_FAMILY, 
        preferences, furnitureHomonymsCounter, identifiedFurniture);
    
    // Try to load com.eteks.sweethome3d.io.AdditionalFurnitureCatalog property file from classpath
    readFurnitureCatalog(classPackage + "." + ADDITIONAL_FURNITURE_CATALOG_FAMILY, 
        preferences, furnitureHomonymsCounter, identifiedFurniture);
  }
Sweeto
Posts: 5
Joined: Tue Nov 24, 2015 3:15 pm

Re: JAVA: How to change the default furniture catalog?

Post by Sweeto »

At first I have added the obj- and png-files to this folder:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io\resources
And edited the language property file and the normal property file (see above) in:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\src\com\eteks\sweethome3d\io
But it did not work.


Then I have added the obj and png-files to this folder:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\classes\com\eteks\sweethome3d\io\resources
And edited the property files in:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\classes\com\eteks\sweethome3d\io
Now it works! :)

What is the right way to do this? Do I really have to add the obj and png files in the classes folder (it doesn't make sense to me)? I am sorry, for those basic programming questions.
User avatar
digitaltrails
Posts: 95
Joined: Sun Dec 28, 2014 12:20 am
Country: Wellington, New Zealand, New Zealand
Contact:

Re: JAVA: How to change the default furniture catalog?

Post by digitaltrails »

The properties and resources in the source (src) hierarchy are copied to the build output class hierarchy when the software is built by the build process. You would need to run ant to do a build.
User avatar
digitaltrails
Posts: 95
Joined: Sun Dec 28, 2014 12:20 am
Country: Wellington, New Zealand, New Zealand
Contact:

Re: JAVA: How to change the default furniture catalog?

Post by digitaltrails »

The properties and resources in the source (src) hierarchy are copied to the build output class hierarchy when the software is built by the build process. You would need to run ant to do a build.
I should have mentioned - see "copy todir" in the build.xml file.
Sweeto
Posts: 5
Joined: Tue Nov 24, 2015 3:15 pm

Re: JAVA: How to change the default furniture catalog?

Post by Sweeto »

Hello digitaltrails,

thank you for your answer.

I have watched this video to understand how to build a project with ant: https://www.youtube.com/watch?v=qOhfl9gayB8

The options for an ant build are in the "build.xml"-file, which is located in this folder:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\ 

The "build.xml"-file does not contain any command, that will tell ant to copy files to this folder (the default output folder of my eclipse project):

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\classes 

Instead ant copies the files to this folder (the build folder gets deleted at the end of the build process):

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\build\classes 
I could add

Code: Select all

<copy todir="classes\com\eteks\sweethome3d\io\resources"> 
to the "build.xml" file to copy the furniture files (png, obj). Is this the right way to do it? Why doesn't the default ant build copy the files?

Have a nice weekend!

Greetings,

Sweeto
User avatar
digitaltrails
Posts: 95
Joined: Sun Dec 28, 2014 12:20 am
Country: Wellington, New Zealand, New Zealand
Contact:

Re: JAVA: How to change the default furniture catalog?

Post by digitaltrails »

I assume you're using eclipse. The directory SweetHome3D-5.1-src/classes is used by eclipse to store class files it compiles. This is used by internally by eclipse, and also when running/debugging from within eclipse. Eclipse automatically includes the Project's source folders in it's run class paths, so it it is unnecessary to copy source resources and property files to eclipse's class folder.

If you wanted to use eclipse's class folder outside of eclipse, you could do what eclipse does, and add the src folder to the class path of your java command (then both will searched).

If I wanted to run outside of eclipse, I would build with ant and create all the necessary jars in the output build folder, then put the jars on the classpath (using the run scripts in the install folder as a guide). In practice, I just copy jars from the Ant build into my original "official" SH3D installation replacing the official ones with my own.

Note: Ant builds are a separate thing from eclipse's automatic compiles. Eclipse uses it's own compiler, own dependency tracking, and own classpath definitions, all normally quite separate from Ant's.
Plus eclipse also has it's own separate run/debug-time classpaths. Keeping eclipse and Ant in agreement is a headache - various tools are available to help better integrate eclipse with external build tools such as Ant, but none are completely perfect. It's not uncommon to burn time on sorting out dependency problems when eclipse and the external build tools get subtlety out of sync.

Hello digitaltrails,

thank you for your answer.

I have watched this video to understand how to build a project with ant: https://www.youtube.com/watch?v=qOhfl9gayB8

The options for an ant build are in the "build.xml"-file, which is located in this folder:

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\ 

The "build.xml"-file does not contain any command, that will tell ant to copy files to this folder (the default output folder of my eclipse project):

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\classes 

Instead ant copies the files to this folder (the build folder gets deleted at the end of the build process):

Code: Select all

Path_To_Sweet_Home_3D\SweetHome3D-5.1-src\build\classes 
I could add

Code: Select all

<copy todir="classes\com\eteks\sweethome3d\io\resources"> 
to the "build.xml" file to copy the furniture files (png, obj). Is this the right way to do it? Why doesn't the default ant build copy the files?

Have a nice weekend!

Greetings,

Sweeto
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest