|
Sweet Home 3D Forum » List all forums » » Forum: Developers » » » Thread: Plugin Development Issue » » » » Post: Re: Plugin Development Issue |
Print at Feb 5, 2026, 3:14:13 PM |
| Posted by Samanyu at Jul 23, 2024, 8:40:37 AM |
|
Re: Plugin Development Issue Hi Puybaret, I have followed the guide and I was getting some errors on this line. getHome().getFurniture. So to resolve this, I just did 1 small change in Volume Plugin class. I passed getHome method in the constructor of VolumeAction class and then initialized the Home class variable there. Do you think that my small code change is causing some issues? Also, is there any specific java version I should use to make it work? I am using OpenJDK 17 right now. VolumeAction.java package com.eteks.test; import javax.swing.JOptionPane; import com.eteks.sweethome3d.model.Home; import com.eteks.sweethome3d.model.PieceOfFurniture; import com.eteks.sweethome3d.plugin.PluginAction; public class VolumeAction extends PluginAction { private final Home home; public VolumeAction(Home home) { this.home = home; putPropertyValue(Property.NAME, "Compute volume"); putPropertyValue(Property.MENU, "Tools"); // Enables the action by default setEnabled(true); System.out.println("VolumeAction initialized"); } @Override public void execute() { System.out.println("VolumeAction executed"); float volumeInCm3 = 0; // Compute the sum of the volume of the bounding box of // each movable piece of furniture in home for (PieceOfFurniture piece : home.getFurniture()) { if (piece.isMovable()) { volumeInCm3 += piece.getWidth() * piece.getDepth() * piece.getHeight(); } } // Display the result in a message box (\u00b3 is for 3 in supercript) String message = String.format( "The maximum volume of the movable furniture in home is %.2f m\u00b3.", volumeInCm3 / 1000000); JOptionPane.showMessageDialog(null, message); } } VolumePlugin.java package com.eteks.test; import com.eteks.sweethome3d.plugin.Plugin; import com.eteks.sweethome3d.plugin.PluginAction; public class VolumePlugin extends Plugin { public VolumePlugin() { System.out.println("VolumePlugin loaded"); } @Override public PluginAction[] getActions() { return new PluginAction [] {new VolumeAction(getHome())}; } } ApplicationPlugin.properties name=Movable furniture volume class=com.eteks.test.VolumePlugin description=Computes the volume of the movable furniture in home version=1.0 license=GNU GPL provider=(C) Copyrights 2008 eTeks applicationMinimumVersion=1.5 javaMinimumVersion=1.5 |
|
|
Current timezone is GMT Feb 5, 2026, 3:14:13 PM |