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: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 5465 times and has 4 replies Next Thread
kerfmas4
Newbie




Joined: Aug 26, 2011
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Background Image from command line

Hello all.
I would like to know if there is any way of execute a command to set the background image. Or command line.
I normally work with c# and before starting learning java, wanted to know if its possible to connect some simple functions like preferences,background image with c#.
Or if its possible to do programming a plugin.
The views preferences are easy to solve due to we can save a sh3d file and load through an external program renaming it.
So, what do you think will be more easy for me.

For the future I would like to integrate a little window sh3d viewer with move, zoom, just this. A form control would be perfect.
Thanks.
[Aug 26, 2011, 2:51: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 
kerfmas4
Newbie




Joined: Aug 26, 2011
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Re: Background Image from command line

OK. Finally I've decided to learn more about java. Now I can set a predefined Jpg as backgroundimage from the menu bar.
My new question is: How could I autoload this plugin function when the application starts without clicking on the menu item?
Thanks in advance.
[Aug 31, 2011, 1:36: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 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Background Image from command line

Welcome to Sweet Home 3D developer world. smile

How could I autoload this plugin function when the application starts without clicking on the menu item?
If you want to program this only from the plugin you already created, you could set the background image of the current home in the getActions method you programmed. I guess this is not very clean, but it seems like a init method is missing in the Plugin class.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Aug 31, 2011, 7:35:11 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
kerfmas4
Newbie




Joined: Aug 26, 2011
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Re: Background Image from command line

First of all, thanks a lot for your help. Now the code result that worked.

package com.eteks.test;

import java.net.URL;
import java.net.MalformedURLException;
import com.eteks.sweethome3d.plugin.Plugin;
import com.eteks.sweethome3d.plugin.PluginAction;
import com.eteks.sweethome3d.model.BackgroundImage;
import com.eteks.sweethome3d.model.Content;
import com.eteks.sweethome3d.tools.URLContent;

public class SetBackgroundPlugin extends Plugin {
public BackgroundImage ImagenFondo() throws MalformedURLException {
URL u = new URL( "file:/c:/4683.jpg");
Content content = new URLContent(u);
return new BackgroundImage(content, 2500, 0, 0, 700, 700, 0, 0);
}

public class SetBackgroundAction extends PluginAction {
public SetBackgroundAction() {
putPropertyValue(Property.NAME, "Compute volume");
putPropertyValue(Property.MENU, "Tools");
// Enables the action by default
setEnabled(true);
}

@Override public void execute() {
}
}

@Override
public PluginAction[] getActions() {
try {
getHome().setBackgroundImage(ImagenFondo());
} catch (MalformedURLException e) {
e.printStackTrace();
}
return new PluginAction [] {new SetBackgroundAction()};
}
}


Thanks again.

[Note from moderator: fixed code format]
----------------------------------------
[Edit 2 times, last edit by Puybaret at Aug 31, 2011, 9:37:32 PM]
[Aug 31, 2011, 9:19:47 PM] 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: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Background Image from command line

Great you succeeded!
I fixed the code format otherwise it was unreadable.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Aug 31, 2011, 9:39:32 PM] 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