How to group furniture using a plug-in?

This topic has been viewed 6453 times and has 2 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
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

How to group furniture using a plug-in?

Post by enkonyito »

Using a plug-in, I want to group furniture added to the plan for a specific action.
My concern is that a new furniture group can only be defined by at least a furniture list and a name.
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to group furniture using a plug-in?

Post by Puybaret »

What other capabilities would you expect?
Look at FurnitureController class to understand how a furniture group is created and handled. The difficult thing is probably to allow undo / redo on groups, but maybe you won't need that?
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: How to group furniture using a plug-in?

Post by enkonyito »

What other capabilities would you expect?
I thought it would be possible to create an empty group and then add the furniture to it separately.
Look at FurnitureController class to understand how a furniture group is created and handled.
It was the addFurnitureToGroup method that caused me problems because it is necessary to have a list of furniture and a group of furniture as a parameter.
The difficult thing is probably to allow undo / redo on groups, but maybe you won't need that?
As it is to add new light sources in the plan, the undo/redo function is not negligible.

Even though it's not very intuitive, I was able to work around the issues by using the methods provided by the FurnitureController class.

Code: Select all

getHomeController().getPlanController().setSelectedLevel(lightLevel);
List<HomePieceOfFurniture> singleLightSource = new ArrayList<HomePieceOfFurniture>();
singleLightSource.add(lightSourceClone);
getHomeController().getFurnitureController().addFurniture(singleLightSource);
severalLightSources.add(lightSourceClone);
...
getHomeController().getFurnitureController().setSelectedFurniture(severalLightSources);
getHomeController().getFurnitureController().groupSelectedFurniture();
HomeFurnitureGroup lightSourcesGroup = (HomeFurnitureGroup) getHome().getSelectedItems().get(0);
EnkoNyito
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest