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.
Code: Select all
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();
}
}
}
}