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: 26
Posts: 26   Pages: 3   [ 1 2 3 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 21138 times and has 25 replies Next Thread
Byron
Newbie




Joined: Apr 16, 2011
Post Count: 11
Status: Offline
Reply to this Post  Reply with Quote 
Plugin - Creating Objects with other Properties

Dear SH3D Community,
I am a student and I am supposed to create new Objects for SweetHome3D.These Objects should be extended in terms of their properties. E.g. a field center of mass or other object specific modifiable information should be added.
(Actually the important part is to capture the joint and link configuration using unified robot description format (URDF)).

Therefore I would like to do this by writing an effective Plugin,
but I am not sure whether this is possible.

The tasks which I need are the following:

1) Reading in data from a meta-file e.g. in xml which contains
the information. (This I should be able to do without problems)
The xml will contain all information about:
joint configuration, path of the according dae-files, ...

2)Creating new Catalog-Categories and the Catalog-Object from this file and its information.

3)Being able to drag an drop this new objects to the floor plan and them being displayed in the 3D-View.
(This new object should have new property fields as Center of mass
in its property window then).

How would you advise me to proceed? Is it possible using a plugin
or not, since I might need to extend the class of PieceOfFurniture by
more property-fields.

Regards
Byron
[Apr 16, 2011, 4:50: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 
Byron
Newbie




Joined: Apr 16, 2011
Post Count: 11
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Update:
I have figured how to use my plugin to create new Catalog-Elements.

When I drag and drop a new item on my plan,
how can I control it without changing the SH3D code?
It will be added as HomePieceOfFurniture,
but I want it to be added e.g. as a selfmade class
*** extends HomePieceOfFurniture.

Also I want to modify its properties window.

How can I access the HomeController and its View
from my plugin workspace?
[Apr 18, 2011, 5:09:19 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
alied
Member
Member's Avatar

Argentina
Joined: Sep 8, 2009
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

how can I control it without changing the SH3D code?
you can add a listener to your Home object[1], then create your custom PieceOfFurniture, delete the original, and add yours (remember either remove your listener before adding your object, or check before if it's your item, or you can get into a infinite loop)

Also I want to modify its properties window.
That will be more complicated:
You can start extending com.eteks.sweethome3d.swing.HomeFurniturePanel[2], then search in com.eteks.sweethome3d.swing.PlanComponent[3] and there should be where to change(as far as I know SH3D, you will have to modify the code) to check the selected items and show your custom dialog. Anyway, Emanuel can provide more details (and if I find something usefull, I'll tell you)

Best of luck
Alied

[1]http://www.sweethome3d.com/javadoc/com/eteks/...model.CollectionListener)
[2]http://www.sweethome3d.com/javadoc/com/eteks/...g/HomeFurniturePanel.html
[3]http://www.sweethome3d.com/javadoc/com/eteks/.../swing/PlanComponent.html
[Apr 18, 2011, 6:33: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: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

A plug-in doesn't let you specify the class of pieces of furniture that should be used, and even if you create a derived version of Sweet Home 3D, it won't be so easy to perform without changing code, because furniture instantiation is done at this moment in HomeController, ImportedFurnitureWizardController and FurnitureCatalogTransferHandler. Sincerely, this is something I'm not proud of, and instantiating furniture objects in only one method that could be overridden (like i did for Wall, Room and DimensionLine classes) has been on my TODO list for a while...

As for controllers and views you don't have access to them in plug-ins too, so you should probably better create a derived version of Sweet Home 3D. Creating such a version without modifying code source is completely possible, since it's the way I do it when I create customized versions of Sweet Home 3D for projects like this one. If you want more details, you know the place where you can ask questions... wink
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Apr 18, 2011, 8:01:58 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Byron
Newbie




Joined: Apr 16, 2011
Post Count: 11
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Ok thanks for your input,
it is good to know what is possible and what is not.
I have started working on a derived version already,
I would have loved to somehow utilize the plugin feature
in order to not mess up the code of this nice programm.

I'll continue and will update, as soon as I have some nice results.
[Apr 20, 2011, 9:33:04 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
alied
Member
Member's Avatar

Argentina
Joined: Sep 8, 2009
Post Count: 40
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Still, there is something you can do without messing with the code.
in your Plugin constructor, get the Home and add a listener:

getHome().addFurnitureListener(new CollectionListener<HomePieceOfFurniture>(){
void collectionChanged(CollectionEvent<HomePieceOfFurniture> ev){
//check whether it is a ADD action
//get the newly added item (which should de a HomePieceOfFurniture)
//here, either remove your listener (in which case you should not
//use a anonymous listener like here)
//or check whether it is your class or not
//if it is your class, end(remember to add your listener if you
//previously removed it)
//otherwise, create your own object from the newly added HomePieceOfFurniture
//add it to the Home
}
}


Next, create a PluginAction which shows your properties dialog (which you might extend from com.eteks.sweethome3d.swing.HomeFurniturePanel if you are interesred in) iff the selected items(s) are of your class.

I hope this can hep you.
----------------------------------------
[Edit 1 times, last edit by alied at Apr 21, 2011, 6:51:11 PM]
[Apr 21, 2011, 6:50:16 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: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

alied's tip is good but I just have some doubts about classpath when opening homes with substituted objects, and how undo/redo will work when you substitute an object by an other one. At the minimum you should take care of the index of the added piece.
An other tip is to manage all your additional information with setVisualProperty/getVisualProperty methods available in Home class. It won't be a very clean architecture, but will work out of the box if you store there only standard class instances.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Apr 21, 2011, 7:06: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 
Byron
Newbie




Joined: Apr 16, 2011
Post Count: 11
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Thanks for these tipps,
I have worked around the topic and have added a new HomeURDFObject class in my plugin.
Unfortunately I had to change some stuff in the code, but I tried to keep it as little as possible.
Also I added a new Panel class for that which I will simply add to
the normal property panel.
I think I will finish this work soon,
if interested I will post the steps which were important.
But the thing is, that I already worked on a extended version of SH3D.
But Ill tell you! ;)
[Apr 23, 2011, 1:51:45 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: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Please share your findings with the community. smile
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Apr 23, 2011, 3:14: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 
sicodelicos2003
Newbie



Argentina
Joined: Jul 4, 2011
Post Count: 5
Status: Offline
Reply to this Post  Reply with Quote 
Re: Plugin - Creating Objects with other Properties

Please share your findings with the community. smile


Hello. My name is Nicolas, i'm from Argentina. I'm starting with SH3D. I have to design a furniture with some special properties. Can you share your results? This is for my undergraduate thesis (Mobile information systems).

PD: sorry my english, i don't speak the language well.
Thanks from now
[Jul 7, 2011, 12:34:08 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Posts: 26   Pages: 3   [ 1 2 3 | Next Page ]
[ 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 2006-2024 eTeks - All rights reserved