NREL / floorspace.js

Other
66 stars 35 forks source link

Not able to draw more than 4 Story and spaces, Default selected tool is rectangle and working tool is Polygon #377

Open rwadhwa910 opened 3 years ago

rwadhwa910 commented 3 years ago

I cannot draw more than 4 stories and when I create a story after the 4th all these gets selected together and at the same time when I try to draw something using Rectangle tool , it does not work instead it uses polygon tool to draw the shape which does not complete a set meaning if I start the polygon tool and end it at the same point, it should complete my drawing but that does not happen.

OS 3.1.0 Windows 10

Screenshot (124)

Mkellyeng commented 3 years ago

tl;dr the FS file's internal ID counter broke. The file can be repaired, though it's a little time consuming

I've had this issue before, in my experience it occurs when the internal IDs become invalid for some reason

The two causes that I have found are:

Based on your screenshot, you're looking at the first issue. This can occur if you save and reopen the same file a bunch of times, making changes each time. The root cause seems to be in how the internal IDs for each object are managed.

Essentially, each object is given a unique internal ID. There's a counter that increments by 1, each time a new object is created. However when the file is opened (ie saved, closed, reopened) the counter appends 1, rather than adding 1. So 12+1=121, instead of 12+1=13. I think this is caused by some string/int funkiness

If this happens often enough you'll get more than 16 digits, everything breaks and you have the bizarre set of behaviours you're seeing now

A similar ticket that a colleague of mine raised a while ago, though I'm not sure this was ever actioned. At the time we weren't yet sure why this was happening, but looking back on it, I now believe it to be the internal ID length issue https://github.com/NREL/floorspace.js/issues/302

Mkellyeng commented 3 years ago

If you can share the osm file and the folder that it comes with, I can confirm whether you're dealing with the ID issue. The geometry is saved in "floorplan.json" you can open this up in notepad (or preferably in an online json viewer). image

If you want to repair the file, look at the IDs. They're probably super long, but all start with the same string of numbers. You can find and replace, say, the first 10 digits of the IDs, and the crazy behaviour should go away

eg: use the notepad++ find and replace tool to replace "1234567890" with "9". That'll shorten the IDs, and should still all be unique. "ID": "1234567890123456" becomes "ID": "9123456" "ID": "1234567890123457" becomes "ID": "9123457" "ID": "1234567890123458" becomes "ID": "9123458"

If you don't want to mess around in the json file, you'll probably have to redo your geometry unfortunately. If so, try to build the geometry without closing/reopening the file too many times, as the ID appending happens when the file is opened. I'm not sure if the OS merge function triggers the ID issue, but it should be safe to save even without merging the geometry (from memory, merging converts the .json into an .osm, but the .json is still saved when you save OS. So you can make all your changes in json, and just merge at the end)

Note that I haven't worked with OS 3.1.0, so my info might be a little out of date. Though I assume it's still all structured this way

Mathadon commented 3 years ago

This may be solved by setting largestId = +v; in https://github.com/NREL/floorspace.js/blob/develop/src/store/utilities/importFloorplan.js line 116

rwadhwa910 commented 3 years ago

@Mkellyeng I was able to change the floorplan by using your trick but after a file even if my ids are less than 17 digits still I am not able to add the spaces. I have attached a google link where you can find the JSON file.

rwadhwa910 commented 3 years ago

https://drive.google.com/file/d/1mMSjGEuihlnTJ-TgFSxwYK6O4aKy5W4r/view?usp=sharing

Mkellyeng commented 3 years ago

I had a go at repairing that file, I'm able to add spaces when testing on the web version (https://nrel.github.io/floorspace.js/), so I expect it'll work in OpenStudio as well

Repaired FloorSpace JSON.zip

I pulled down FS and put in @Mathadon's suggested change, which corrected the ID issue locally. I've pushed it to this repo, however I don't know how often the OpenStudio version of floorspace is updated. So the bug will likely still be present.

Essentially, be careful with how often you Edit, then Save, then Close, then Reopen, then Edit your files

Calde13 commented 1 year ago

Hello sir.

¿Could u help me to repair my JSON file? It has shown all the described problems above.

Calde13 commented 1 year ago

This may be solved by setting largestId = +v; in https://github.com/NREL/floorspace.js/blob/develop/src/store/utilities/importFloorplan.js line 116

How can I set "largestId = +v;" in OpenStudio?

rwadhwa910 commented 1 year ago

Open the floorplan.json file in the model folder in notepad and follow these steps.

image

If you want to repair the file, look at the IDs. They're probably super long, but all start with the same string of numbers. You can find and replace, say, the first 10 digits of the IDs, and the crazy behaviour should go away

eg: use the notepad++ find and replace tool to replace "1234567890" with "9". That'll shorten the IDs, and should still all be unique. "ID": "1234567890123456" becomes "ID": "9123456" "ID": "1234567890123457" becomes "ID": "9123457" "ID": "1234567890123458" becomes "ID": "9123458"

if you have issues attach the floorplan file and i can look into it.

Calde13 commented 1 year ago

Could u show a picture where I can watch where the ID's are inside the json file?

rwadhwa910 commented 1 year ago

image

here it is.