Print at Dec 19, 2025, 6:17:03 PM View all posts in this thread on one page
Posted by tfstdsi at Jun 29, 2012, 5:26:36 PM
Adding new elements
hello,

I'm new in this project and I want to develop new tools, objects...
I learned how to develop a simple plugin from the tutorial,
now my objective is to add a new personalized element (for exemple in room "chambre" ) also how to create
a new category like the folder "chambre" in the application ,
the problem is that I' cant find the part of code in which i make these changes ,
so i participate in this forum hoping to find assistance .

thank you in advance.

Posted by Puybaret at Jul 1, 2012, 12:01:12 PM
Re: Adding new elements
Objects shown in the furniture catalog tree are CatalogPieceOfFurniture instances stored in FurnitureCategory and FurnitureCatalog objects. The furniture catalog in use in the program can be retrieved from UserPreferences instance that is proposed in plug-ins and many other places.
The best way to learn how catalog pieces are handled is to study the DefaultFurnitureCatalog and FileUserPreferences classes. Modifying the current catalog will be automatically reflected in the catalog tree component, so try to understand first how to create these pieces and add them in the user preferences catalog with these two classes.

By the way, it would be nice to explain what is your goal?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by anandunadkat at Jan 16, 2013, 11:31:29 AM
Re: Adding new elements
I am trying to do the same thing. I want to add new objects to the current library within my plugin. I am really struggling because i am new to sweet home 3d and java.

It would be a great help if someone knew how it can be done. I am basically trying to create a plugin to import a bathroom template with basic furniture but some furniture is not in the library so i want to import it through java code. i have a create new object method but it doesnt work

Posted by Sajmmon at Jan 16, 2013, 11:28:56 PM
Re: Adding new elements
So you wish to embed OBJ models in your plugin, so that your users did not need to download separatelly a plugin and a library of furniture. In my opinion you can either:

- use aformentioned classes,
- copy furniture library to a folder from which SH3D loads them

the first way gives you models immediatelly, but they disappear after startup. The second way is persistent, but models will be visible after restarting the application.

Hope I helped

Posted by anandunadkat at Jan 17, 2013, 10:15:41 AM
Re: Adding new elements
So to give you an idea, i have pasted the code below.

public static void addRightAngleRail(Home home,
UserPreferences preferences, Float homeLength, Float homeBreadth) {
HomePieceOfFurniture furniture;
furniture =createFurniture(preferences,7 , 2, homeLength,homeBreadth-100);
furniture.setColor(-255);
furniture.setAngle(1.57f);
home.addPieceOfFurniture(furniture);

As you can see i have created a new object, but it doesnt want to appear, are you saying that i copy the furniture library to my eclipse project folder?

Posted by Sajmmon at Jan 17, 2013, 9:14:34 PM
Re: Adding new elements
Please have a look at my reply in thread:

http://www.sweethome3d.com/support/forum/viewthread_thread,3776

Good luck!