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: 8
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 4326 times and has 7 replies Next Thread
josleen
Newbie



222
Joined: Feb 27, 2011
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
sad Add furniture progamatically !!!

Hi All,

How can I create furniture programatically on my home? I created walls and rooms but I am unable get the furniture. What classes are involved? Do I need to read from the io resources?

Thanks !!!
[Apr 3, 2011, 12:42:36 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
alied
Member
Member's Avatar

Argentina
Joined: Sep 8, 2009
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

typing from memory:
Home myHome = new Home();
HomePieceofFurniture hpf = new HomePieceofFurniture(somePieceOfFurniture);
myHome.addFurniture(hpf);

The point is, you need a instance of a class implementing PieceOfFurniture e.g. CatalogPieceOFFurniture, which you can get from a FurnitureCatalog. Then, add it to your Home object. easy if you see it.

Good luck.
As I said, I'm typing from memory, so actual names of functions may differ.
[Apr 4, 2011, 3:04:57 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
alied
Member
Member's Avatar

Argentina
Joined: Sep 8, 2009
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

some useful URLs:
HomePieceOfFurniture constructor[1]
Adding a HomePieceOfFurniture to a Home[2], [3]
[1]http://www.sweethome3d.com/javadoc/com/eteks/...3d.model.PieceOfFurniture)
[2]http://www.sweethome3d.com/javadoc/com/eteks/...odel.HomePieceOfFurniture)
[3]http://www.sweethome3d.com/javadoc/com/eteks/...mePieceOfFurniture,%20int)
[Apr 7, 2011, 12:48:24 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
josleen
Newbie



222
Joined: Feb 27, 2011
Post Count: 10
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

@alied:

Thanks mate !!!
[Apr 7, 2011, 1:26:02 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
kleiba
Newbie




Joined: Nov 11, 2011
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

Hi,

sorry for piggybacking on this thread - I've tried using the steps outlined by alied, but still cannot add new furniture to my room :-(

Here's how I'm doing it right now:

Home home = new HomeFileRecorder().readHome(roomFile.getPath());

Content model = new URLContent(modelUrl);
PieceOfFurniture piece = new CatalogPieceOfFurniture("MyName", null, model, 100, 100, 100, ...);

HomePieceOfFurniture hpof = new HomePieceOfFurniture(piece);
hpof.setX(200);
hpof.setY(300);
hpof.setElevation(0);

home.addFurniture(hpof);

What happens with this code if I construct a HomeComponent3D around the home and display it in a JFrame is that I see the room and a white cube (1m edge length) at coordinates (200,300,0) -- BUT ONLY FOR ABOUT ONE SECOND!

Then it magically disappears from the scene again.

Very strange. If I query home.getFurniture() I can see that my new object is still in there, but as I said, it is only shown for one second and then it is suddenly gone.

Any help would be greatly appreciated.

Thanks,
Thomas
[Apr 30, 2012, 9:39:16 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

In which view does it disappear? Plan view? 3D view? Both?
Any stack traces?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Apr 30, 2012, 8:20:12 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
kleiba
Newbie




Joined: Nov 11, 2011
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

Hi Emmanuel,

Thanks for the quick reply! As I pointed out, I'm viewing the room through a HomeComponent3D component. Note that we are talking about a stand-alone application built on top of the SweetHome3D libraries, not a plugin that interacts with the SweetHome3D application itself.

I'd be happy to post the source code of a minimal example - basically it's not much more than the above code inside a main-method, plus the creation of a HomeComponent3D and a JFrame.

There are no stack traces because the program runs without complaints, i.e., no Exceptions are being thrown. It's just that the HomePieceOfFurniture object I add programmatically never gets displayed. Instead, I can see a 1^3m white cube for about one second where the HomePieceOfFurniture is supposed to be which then disappears.

A first guess was that perhaps the model data of the HomePieceOfFurniture was not found correctly, but I made sure that this is not the case, or else the URLContent constructor would complain anyway.

Thanks again for your help.

Cheers,
Thomas
[May 1, 2012, 12:42:33 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Add furniture progamatically !!!

I guess you see only the box displayed during the loading of the 3D model. Once the 3D model is loaded, the box is replaced by the loaded model, but maybe it's an empty model. Which 3D model file do you try to use?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[May 1, 2012, 9:04:06 PM] 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