[IfcOpenShell] Cityjson to IFC
Can someon explain of make a screencast how Cityjson files can be converted to IFC using all of these codes?
Would be helpful for many i think.
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifccityjson
Can someon explain of make a screencast how Cityjson files can be converted to IFC using all of these codes?
Would be helpful for many i think.
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifccityjson
Comments
Maybe we should ship it with the BlenderBIM Add-on and build a small UI for it, to make it more accessible to more users? Ping @LaurensJN ?
@magicalcloud_75 I could make an extended install guide on the OSArch wiki.
@Moult might be a good idea. Also because it is dependent on the ifcopenshell.api that currently is not shipped with the python distributions in http://ifcopenshell.org/python but are with BlenderBIM. However it also has a cjio dependency. You think that's a problem?
@magicalcloud_75 I forgot to make the tutorial, sorry about that. Here you can find it: https://wiki.osarch.org/index.php?title=Ifccityjson.
@Moult I'm still up for making a small CityJSON importer UI in BlenderBIM. How can I get it to ship with it so I could make the UI? Also, is the cjio dependency a problem in that case?
Good job Laurens. We have a FME running for us that does these kinds of jobs quite well. Not much of a programmer but would love to be able to use a FOSS solution to make IFC cityjson available for my own activities.
I followed the steps in the tutorial, maybe I am doing something wrong, it still can't find the ifcopenshell.api module. I am on Windows 10 and using Python 3.9.
What I did:
Went to my system installed python and installed cjio using

pip install cjio
. It worked, I now have cjio.exe in my scripts folderDownloaded the latest BlenderBIM add-on, extracted it and placed the ifcopenshell module in my local Python installation

Git cloned IfcOpenShell to my local machine
C:\Code\IfcOpenShell\src\ifccityjson
Went to the ifccityjsonfolder

Tried to run the script through powershell
I feel I am missing something in step 2. I cant't find any file or folder called .api. Still missing the ifcopenshell.api. What am I doing wrong?
Great that you tried to follow it @Coen! And I think you are entirely correct that something is missing in step 2. If I download the BlenderBIM add-on and navigate to blenderbim/libs/site/packages/ifcopenshell, the api folder is there, while in your folder it is missing...

Did you download the latest add-on from https://blenderbim.org/download.html? I'm not sure why your directory looks different otherwise..
@LaurensJN
Your tutorial is correct, the problem was me. I already had an ifcopenshell folder there before I even installed BlenderBIM, somehow it didn't copy paste the api folder.
Unto to next challenge,. :-). I typed in this command in Command Prompt:
python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
Gives the following output:
I also tried to copy paste what was in the tutorial:
"C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" n -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
Gives the following output, I think a dash is needed before the first n? Might be a small mistake in the tutorial?
ifccityjson.py: error: unrecognized arguments: n
So I placed a dash but now got this:
C:\Code\IfcOpenShell\src\ifccityjson>python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -n -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
ifccityjson.py: error: argument -n/--name: expected one argument
Let me start with the second question: the first 'n' should not be there at all. There only is one argument '-n' or '--name' (the attribute that has the name, in case of 3DBAG 'identificatie' . So if you would type
C:\Code\IfcOpenShell\src\ifccityjson>python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
it should work.The first question is a bit more difficult. That is probably a bug in in the converter. I think it has to do with the identifier being a float tuple instead of an int tuple. I will try to fix that.
Thanks for testing it out! It is always better if somebody else finds some bugs that you couldn't find yourself :)
Thanks for the answer, I am getting this error now
I typed in the command prompt:
C:\Code\IfcOpenShell\src\ifccityjson>python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
It returns this
I found the bug: CJIO had an update that broke some code. I posted an issue there and will update if I got an answer
It should be fixed now (see commit). You can download ifcopenshell again, or (might be easier), go to src/ifccityjson/ifccityjson.py and change line 39:
city_model = cityjson.load(args.input)
tocity_model = cityjson.load(args.input, transform=False)
Sorry for the late reply @LaurensJN . Indeed it would be awesome to ship it with the BlenderBIM Add-on. The
cjio
dependency can be added to https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/Makefile - you can see other examples of other Python libs already bundled there.You can also see some example code for other importers such as for P6 / MSProject in the
sequence
module. I think it might be appropriate to create a new module for cityjson. Perhaps a module namedgis
? Just in case you foresee future development around GIS features. Once you've created a new module here is some existing code you can use as an example: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/blenderbim/bim/module/sequence/init.py#L127-L128 and L141 and L151. And the corresponding operator code: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/blenderbim/bim/module/sequence/operator.py#L1079-L1098Thanks, I changed line 39 like you said, ran the command again.
python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie
Now the console returns this:
@Moult Thanks for the pointers, I'll be able to start there.
@Coen I can't reproduce your error. Care to give me your file? You can send it to l.oostwegel (at) gmail.com
.json file format is not allowed. I changed the file extension to .txt to attach to this post.
I downloaded this file from the 3DBAG Viewer.
Thanks. My best guess is that this has again to do with the updated CJIO library, this time this issue. The metadata in the file is not properly updated, therefore it does not recognise the multiple LoDs in the file. We'll have to wait for their response to get it working again I'm afraid. Will keep you updated!
Make a 'City IFC for Dummies' video afterwards :)
@Coen issue is now solved inside ifccityjson until there is an update of CJIO where that bug is fixed. I came across another bug, which has to do with generation of interior holes in faces using IFC that I could unfortunately not solve (yet). I will make a post about that on the forum and hopefully somebody can help me :) Anyway, you can download the new code on github and your 3D BAG should have no errors anymore! The command changed ever-so-slightly, it is now best to use:
python ifccityjson.py -i "C:\Code\IfcOpenShell\src\ifccityjson\3dbag_v210908_fd2cee53_5624.json" -o C:\Code\IfcOpenShell\src\ifccityjson\3DBAG.ifc -n identificatie --lod 1.3
(or whichever lod you'd like to extract.).@magicalcloud_75 I will put some effort in merging ifccityjson inside BlenderBIM, which will make everything a lot more intuitive for a non-programmer, after that I promise to make a video!
Absolutely fantastic!
In BimCollabZoom

And in BIMVision
Can .osm files also be converted to .ifc with this tool?
@magicalcloud_75 as promised, here's how to convert your CityJSON file to IFC using the latest (non-stable) BlenderBIM. You can download for example today's version at https://github.com/IfcOpenShell/IfcOpenShell/releases/tag/blenderbim-211117

@Coen I'm afraid this will be something for the future :) Would be handy though...
After importing you could get an error, but this does not fail loading the IFC file. I should fix that soon though...
That is really amazing, would be cool to see this for the whole of Europe instead of the Netherlands. :-)
Slightly related, can you also merge the different IFC tiles in Blender?
I guess you could achieve that in two ways: (1) do process above twice with a different .json file (IFC file gets saved where you specified in 'IFC Output') and use IfcPatch to merge IFCs (see https://community.osarch.org/discussion/447/import-and-merge-ifc).
(2) merge the cityjson files using CJIO python library (using: pip install cjio). It's a CLI and you can find here https://github.com/cityjson/cjio how the merge function works. After merging multiple tiles, you can just import the big cityjson file as IFC in Blender. Hope that helps?
This makes dutch NL 3DBAG data so much more usable! I think kadaster more or less forget to serve BIM. One thing catches my attention. It seems that the geo location is not stored in IFC. That can't be the case.. can it?? I am certainly not a ifc file spec specialist but this kind of crucial information should be stored IN ifc.
Tile 4278

@LaurensJN [EDIT]

RD notations in NL always contain 2x6 digits [m] in X & Y
Epsg7415 IFC georeferencing, Shouldn't that be epsg:28992 ?
epsg:28992 is for Amersfoort / RD New.
epsg:7415 is a compound coordinate system with Amersfoort / RD New + NAP height.
See https://epsg.io/7415
I'm not exactly sure what you mean. It has the northings/eastings/OrthogonalHeight of the project center and an EPSG, do you need more?
This is so convenient, just a matter of clicking two or three buttons. What does the Identifier do by the way?
If you want the building to have a specified attribute as building/entity name instead of its CityJSON identifier, you could use that instead. If you take a look at the CityJSON_attributes pset under 'Object properties' --> 'IFC Object Property Sets', you could choose any of these properties. In the previous version of 3D BAG, the object ID was not the same as the BAG ID, so you would put 'identificatie' in the 'Identifier' to get the actual BAG ID. I didn't really test it thoroughly though, because the new 3D BAG identifier is the BAG ID anyway. Another use case would be for example if the building address is specified in the CityJSON file, you could use that instead of the BAG ID. This is right now not the case for the 3D BAG dataset but might be useful for similar datasets in other countries?