and I created a JAR file and stored it into the plugins folder as per the directory shown in the guide. Note: There was no plugins folder there so I created one, copied and pasted my JAR file there. Now I tried opening my JAR file as well as sweetHome 3D directly, but I am not able to see the Tools at the top, what am I doing wrong?
India
Joined: Jul 15, 2024
Post Count: 5
Status:
Offline
Re: Plugin Development Issue
I installed one of the plugins mentioned here https://www.sweethome3d.com/plugins.jsp and it created the plugins folder. I can see the tools in the top menu but when I am copying my JAR file, I am not able to see my plugin there. I noticed that the plugin I has a .sh3p extension, do I also have to convert my JAR file to .sh3p? If yes, then can you please tell me how to do that.
India
Joined: Jul 15, 2024
Post Count: 5
Status:
Offline
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.
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); } }
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
India
Joined: Jul 15, 2024
Post Count: 5
Status:
Offline
Re: Plugin Development Issue
Update: I downloaded the jar from the example in the guide, decompiled the java class copied and pasted the same code, and exported it as the jar in the plugins folder, but it still didn't work. Could you please help me identify the issue?
String message = String.format("The maximum volume of the movable furniture in home is %.2f m³.", volumeInCm3 / 1000000.0F); JOptionPane.showMessageDialog((Component)null, message); } } }
Romania
Joined: Apr 24, 2014
Post Count: 588
Status:
Offline
Re: Plugin Development Issue
1. You don't need to de-compile the java class file. In the "Plugin developer's guide", at the end of "Creating the plug-in class" you have a sentences
The VolumePlugin plug-in class is now programmed, ...
with a link to the java file. You will see the differences between your and the original. 2. Continue carefully with the rest of the tutorial especially with the export part where I suggest to check the Export java source files and resources. Here you can change the extension from jar to sh3p but it is not mandatory. The plugin should work even with jar extension. Don't forget to Export the plugin BEFORE every test to see the effects of your modifications. 3. To verify what you've done, start SH3D from a terminal. If something's wrong you will see some messages like The plugin [name_of_plugin] can't be loaded and the reason why. 4. Don't expect to succeed from the first attempt. After you manage to pass this we could continue to help you.
PS. I set the eclipse workspace to use the jre1.8 provided by the SH3D.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law (Greer's Third Law) When all else fails, read the instructions.Murphy's Law