Download

Online

Gallery

Blog

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



India
Joined: Jul 15, 2024
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
confused Plugin Development Issue

Hi, I am new to sweet home 3D and I was trying to create a plugin. I am facing similar issues as this thread here. https://www.sweethome3d.com/support/forum/viewthread_thread,13151

I followed this guide https://www.sweethome3d.com/pluginDeveloperGuide.jsp

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?

I am using IntelliJ IDEA COMMUNITY EDITION 2023
[Jul 15, 2024, 2:02:37 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 431
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin Development Issue

First try to install an existing plugin and verify that it works. This will help you to detect the right folder.
[Jul 16, 2024, 6:18:25 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Samanyu
Newbie



India
Joined: Jul 15, 2024
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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.
[Jul 16, 2024, 7:26:29 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: 9371
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin Development Issue

It's explained in the plug-in developer guide.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Jul 16, 2024, 8:26:18 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Samanyu
Newbie



India
Joined: Jul 15, 2024
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin Development Issue

Hi Puybaret,

I am following the guide only, I retraced the steps 10 times, but I cannot identify my mistake. Could you please help me?
[Jul 17, 2024, 8:43:55 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: 9371
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin Development Issue

It's explained in the "Deploying the plug-in" section.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Jul 17, 2024, 9:42:10 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Samanyu
Newbie



India
Joined: Jul 15, 2024
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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
[Jul 23, 2024, 8:40:37 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Samanyu
Newbie



India
Joined: Jul 15, 2024
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
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?

package com.eteks.test;

import java.awt.Component;
import java.util.Iterator;

import javax.swing.JOptionPane;

import com.eteks.sweethome3d.model.PieceOfFurniture;
import com.eteks.sweethome3d.plugin.Plugin;
import com.eteks.sweethome3d.plugin.PluginAction;

public class VolumePlugin extends Plugin {
public PluginAction[] getActions() {
return new PluginAction[]{new VolumePlugin.VolumeAction()};
}

public class VolumeAction extends PluginAction {
public VolumeAction() {
this.putPropertyValue(Property.NAME, "Compute volume");
this.putPropertyValue(Property.MENU, "Tools");
this.setEnabled(true);
}

public void execute() {
float volumeInCm3 = 0.0F;
Iterator var3 = VolumePlugin.this.getHome().getFurniture().iterator();

while(var3.hasNext()) {
PieceOfFurniture piece = (PieceOfFurniture)var3.next();
if (piece.isMovable()) {
volumeInCm3 += piece.getWidth() * piece.getDepth() * piece.getHeight();
}
}

String message = String.format("The maximum volume of the movable furniture in home is %.2f m³.", volumeInCm3 / 1000000.0F);
JOptionPane.showMessageDialog((Component)null, message);
}
}
}

[Jul 23, 2024, 8:47:04 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 431
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin Development Issue

When you create the jar you have to be sure to include the ApplicationPlugin.properties.
If you still have problems you could share the jar.
[Jul 24, 2024, 11:10:55 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
dorin
Advanced Member
Member's Avatar

Romania
Joined: Apr 24, 2014
Post Count: 588
Status: Offline
Reply to this Post  Reply with Quote 
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
[Jul 26, 2024, 10:37:43 AM] 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