Print at Dec 20, 2025, 5:24:34 AM View all posts in this thread on one page
Posted by kupiecu at Nov 29, 2013, 1:35:28 PM
Plugins don't save a file on disc
sorry, my english level is low.'

I write plugin. It write walls, rooms and furniture to OBJ file. It's work but only when I debbuging this plugin. When I run it normally the plugin don't save file on my disc. ( when debug the file is saving ).
I have no idea, any sugesstions? Mayby samethink like permissons or samethin in manifest file? I don't now. Please help.



import java.io.IOException;
import com.eteks.sweethome3d.j3d.HomePieceOfFurniture3D;
import com.eteks.sweethome3d.j3d.OBJWriter;
import com.eteks.sweethome3d.j3d.Room3D;
import com.eteks.sweethome3d.j3d.Wall3D;
import com.eteks.sweethome3d.model.Home;
import com.eteks.sweethome3d.model.Room;
import com.eteks.sweethome3d.model.Wall;
import com.eteks.sweethome3d.plugin.Plugin;
import com.eteks.sweethome3d.plugin.PluginAction;
import javax.swing.JOptionPane;

public class Wtyczka extends Plugin {

@Override
public PluginAction[] getActions() {

return new PluginAction[] { new VolumeAction() };
}

public class VolumeAction extends PluginAction {



public VolumeAction() {
putPropertyValue(Property.NAME, "Upload project on your android device");
putPropertyValue(Property.MENU, "ToucHHome");
// Enables the action by default
setEnabled(true);
}

public void execute() {

OBJWriterTest ogien = new OBJWriterTest(); // obuekt stworzyc
try {
ogien.testOBJWriter();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



}



public class OBJWriterTest {


public void testOBJWriter() throws IOException {
Home home = getHome();
// 1. Open the OBJ file "Test.obj"
OBJWriter writer = new OBJWriter("dragsy.obj", "Test", -1);
// assertTrue("trots.obj not created", new File("trots.obj").exists());

//write walls
int i =0;
for (Wall wall : home.getWalls()) {
// Create a not alive new wall to be able to explore its coordinates without setting capabilities
Wall3D wallNode = new Wall3D(wall, home, true, true);
writer.writeNode(wallNode, "wall_" + ++i);
}
// Write 3D rooms
i = 0;
for (Room room : home.getRooms()) {
Room3D roomNode = new Room3D(room, home, false, true, true);
writer.writeNode(roomNode, "room_" + ++i);
}

//Write 3D furniture
for (HomePieceOfFurniture piece : home.getFurniture()) {
// if (piece.isVisible() && objFile.equals("." + File.separator + "My_Home" + File.separator + piece.getName() + ".obj")) {
if (piece.isVisible()){
// Create a not alive new piece to be able to explore its coordinates without setting capabilities
// I set as home = null
HomePieceOfFurniture3D pieceNode = new HomePieceOfFurniture3D(piece, home, true, true);
writer.writeNode(pieceNode);
}
}

// 3. Close file
writer.close();
}
}
}
}


Posted by Puybaret at Nov 29, 2013, 2:47:38 PM
Re: Plugins don't save a file on disc
Writing files in a plug-in doesn't work if you run Sweet Home 3D under Java Web Start.
If this doesn't apply to your case, you should try to save the file dragsy.obj in a directory where you're sure you have the rights to write.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator