Plugins don't save a file on disc

This topic has been viewed 5677 times and has 1 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
kupiecu
Posts: 3
Joined: Fri Nov 29, 2013 1:25 pm
Country: Warsaw, Poland, Polska

Plugins don't save a file on disc

Post by kupiecu »

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.


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();
     }
   }
  }
}
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Plugins don't save a file on disc

Post by Puybaret »

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
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest