Import room from .json

This topic has been viewed 5821 times and has 4 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
ilaria_123
Posts: 4
Joined: Wed Sep 26, 2018 11:48 am

Import room from .json

Post by ilaria_123 »

Hello,

I am new to the whole MVC paradigm and it's been a while since I've used Java. I am trying to write a plug-in where I can read a set of vertices from a .json file and draw a room with those vertices in SH3D (ideally I'd like to draw it in 2D and in 3D). It should be something extremely easy to do, so I've implemented the whole thing (I used the VolumePlugin example and I changed what happens in the execute() method) and it works up to the point where I try to actually add a wall (or a room) to the home. In fact, what happens is that the wall/room are simply not showed on the screen; the home stays empty. So I stripped the method out of everything else and simply added a couple of lines where I just add a wall to the home, and still I can't manage to see the new wall on the screen. This is the code I'm using:

Code: Select all

Wall new_wall = new Wall(0.0, 0.0, 3.0, 0.0, 0.01, 2.5);
getHome().addWall(new_wall);
I read in the plug-in guide that because of the way the Plugin class has been implemented, all changes should be immediately reflected on the screen; however, now I'm thinking I'm missing something. Should I use HomeController or View or something else and refresh/redraw? I'm sorry if this is a dumb question but I spent the whole afternoon yesterday trying to figure it out and couldn't. Any help would be appreciated.

Thanks,
Ilaria
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Import room from .json

Post by Puybaret »

This should work but with the values you gave it will make a tiny wall, because the unit used in Sweet Home 3D is the centimeter.
Emmanuel Puybaret, Sweet Home 3D creator
ilaria_123
Posts: 4
Joined: Wed Sep 26, 2018 11:48 am

Re: Import room from .json

Post by ilaria_123 »

It does indeed! I figured it out right after posting the thread, but for some reasons I couldn't see what I posted and couldn't delete it. Thanks for your answer anyway!
okh
Posts: 1545
Joined: Sun May 12, 2013 9:43 pm

Re: Import room from .json

Post by okh »

Intrigued. Is this a private plugin or something you plan on sharing? It sounds as if it is a plugin that would be interesting to know more about. Good luck. ok
ilaria_123
Posts: 4
Joined: Wed Sep 26, 2018 11:48 am

Re: Import room from .json

Post by ilaria_123 »

I am developing it for myself, but if someone is interested I can certainly share it :)
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest