[IfcOpenShell] Cityjson to IFC

2»

Comments

  • edited November 2021

    In Revit the ifcRoof become 'walls' after Blender conversion to IFC
    In BricsCAD BIM no data result after importing.


  • If you are talking about the green selected spaces, this is classified as 'wall' in the CityJSON file, therefore is a wall in the IFC file. The 3D BAG is an automatically generated dataset based on LiDAR and 2D BAG data (thus vertical spaces are always walls, regardless where they are), so if you have any problems with wrong classifications you should ask those guys :)

  • Slightly related,

    Managed with the Blender-osm add-on and BlenderBIM add-on to export the city centre of Moscow to IFC.

    vpajicAcemagicalcloud_75GorgiousMarcus
  • @LaurensJN said:
    If you are talking about the green selected spaces, this is classified as 'wall' in the CityJSON file, therefore is a wall in the IFC file. The 3D BAG is an automatically generated dataset based on LiDAR and 2D BAG data (thus vertical spaces are always walls, regardless where they are), so if you have any problems with wrong classifications you should ask those guys :)

    I mean. "ifcroofs" are not shown. With the same data i can make ifc with FZKviewer that does show them after import. I'm not so into ifc what to ask them :) but i think this has something to do with how Blender writes down ifcroof... regards Hans

  • In Blender 3.1.0 with BlenderBIM version 0.0.220327 I get the following error after clicking Convert CityJSON to IFC:

    location: <unknown location>:-1
    Error: Python: Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 132, in create_new_file
        self.city_model.update_metadata()
    AttributeError: 'CityJSON' object has no attribute 'update_metadata'. Did you mean: 'get_metadata'?
    
    location: <unknown location>:-1
    
    

    Should I make an IfcProject first? Do I have all the settings correct? Am I missing a step?

  • Is IfcCityJson still being maintained? I get the following message when I try to convert CityJson to IFC:

    I'm on the latest stable release of BlenderBIM with Blender 3.4.1

      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    Error: Python: Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    
    

    Which parameters should I provide?

  • I have the feeling this is not maintained anymore? Is there anything I can do to contribute?, this tool is so extremely useful.

  • Hi Coen, I am not maintaining this anymore no, sorry.
    I changed jobs & my focus is not on BIM anymore unfortunately. The error you get seems like an IfcOpenShell error? Probably because the version that IfcOpenShell that was used before had some other way of handling the context parameters. If you would like to we can do some debug session sometime & see if we could fix it? I think I can refresh my memory about CityJSON and if you know how to handle newer versions of IfcOpenShell, I'm sure we're going to get somewhere!

    Coen
  • @LaurensJN said:
    Hi Coen, I am not maintaining this anymore no, sorry.

    That's unfortunate :-(

    I changed jobs & my focus is not on BIM anymore unfortunately. The error you get seems like an IfcOpenShell error? Probably because the version that IfcOpenShell that was used before had some other way of handling the context parameters. If you would like to we can do some debug session sometime & see if we could fix it? I think I can refresh my memory about CityJSON and if you know how to handle newer versions of IfcOpenShell, I'm sure we're going to get somewhere!

    Would be amazing, let's get in touch on some other private means of communication :-). I need to dive into IFC json a bit before I can ask you specific questions.

    LaurensJN
  • I tried diving into it, but I have no idea what I'm doing, I gives this message:

    Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    Error: Python: Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    
    

    So I went to take a look at file blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py on line 128:

            self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
                                                                   **{"context": "Model"})
    

    Took a look in the documentation:
    https://blenderbim.org/docs-python/autoapi/ifcopenshell/api/context/add_context/index.html
    Asked chatGPT:

    Literally no idea what I should do to make IfcCityJson work

  • edited February 2023

    The **{"context": "Model"} should now be **{"context_type": "Model"}. I think, if I look at https://blenderbim.org/docs-python/autoapi/ifcopenshell/api/context/add_context/index.html

    But the **{} Are a bit redundant, you could also use: ifcopenshell.api.run("context.add_context", self.IFC_model, context_type="Model")

    Coen
  • @LaurensJN
    @pstrokap
    I this file on line 128
    C:\Users\cclaus\AppData\Roaming\BlenderFoundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py
    I replaced
    #self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model **{"context": "Model"})
    with
    self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model, context_type="Model")
    Saved the script, started Blender again. Tried to convert cityJson to IFC again:

    Now I have another error which says:

    Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 88, in convert
        self.create_metadata()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 115, in create_metadata
        epsg = self.city_model.get_epsg()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\cjio\cityjson.py", line 442, in get_epsg
        raise ValueError(f"Invalid CRS string '{s}'. CRS needs to be formatted according to the OGC Name Type Specification: 'http://www.opengis.net/def/crs/{{authority}}/{{version}}/{{code}}'")
    ValueError: Invalid CRS string 'urn:ogc:def:crs:EPSG::7415'. CRS needs to be formatted according to the OGC Name Type Specification: 'http://www.opengis.net/def/crs/{authority}/{version}/{code}'
    Error: Python: Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 88, in convert
        self.create_metadata()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 115, in create_metadata
        epsg = self.city_model.get_epsg()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\cjio\cityjson.py", line 442, in get_epsg
        raise ValueError(f"Invalid CRS string '{s}'. CRS needs to be formatted according to the OGC Name Type Specification: 'http://www.opengis.net/def/crs/{{authority}}/{{version}}/{{code}}'")
    ValueError: Invalid CRS string 'urn:ogc:def:crs:EPSG::7415'. CRS needs to be formatted according to the OGC Name Type Specification: 'http://www.opengis.net/def/crs/{authority}/{version}/{code}'
    

    I don't know how to fix this error:
    raise ValueError(f"Invalid CRS string '{s}'. CRS needs to be formatted according to the OGC Name Type Specification: 'http://www.opengis.net/def/crs/{{authority}}/{{version}}/{{code}}'")

  • It might be because of this line here in CJIO, that was added last year: cjio/cityjson.py#L441. I think the CityJSON file might be invalid according to this version of CJIO (the CityJSON parser).

    So, your Coordinate Reference System (CRS) is defined as urn:ogc:def:crs:EPSG::7415. But it should be defined using the opengis URL. I think this is the correct one: https://www.opengis.net/def/crs/EPSG/0/7415. If you replace this in your CityJSON file, what happens?

  • After upgrading the cjio module stille the same error :-(

  • I don't think upgrading helps. I think you have to change the line where the CRS is defined.

    Could I ask you where you got the CityJSON from? We should post an issue, that it should be possible to use the URN:OGC format too

  • Also, if your file is 3D BAG, make sure to update them to V1.1 (see https://github.com/cityjson/cjio/issues/155)

    Coen
  • Could I ask you where you got the CityJSON from? We should post an issue, that it should be possible to use the URN:OGC format too

    The file you mean?

    Downloaded them from here:
    https://3dbag.nl/en/download?tid=2932

  • @LaurensJN said:
    Also, if your file is 3D BAG, make sure to update them to V1.1 (see https://github.com/cityjson/cjio/issues/155)

    I don't really understand how to upgrade a json file, I have installed cjio on my local python installation, but absolute lost on how to use the module.

  • If you have cjio installed (with pip install cjio), you can just run: cjio 3dbag_v210908_fd2cee53_2932.json upgrade save 3dbag_new.json on the command line, the new file will be 3dbag_new.json. As you might have seen in the issue, they deprecated the urn:... format of defining a CRS, but I don't know the reason for that. Upgrading the file would change the CRS to the correct definition

  • @LaurensJN

    How to use cjio in the terminal? Maybe I'm making some beginner rookie mistake?

  • You're on the right track, but making a slight mistake: instead of running cjio on the command line, you start python on the command line and run cjio with python. Instead, just run cjio --help on the command line. This will only work if you have cjio installed in your global python packages.

    When working with python, it is always good to have a virtual environment. This is a separate python environment, where you have your local python packages stored (the reason is that many packages depend on specific versions of other packages and if you have two of them installed that demand a different version, one of them will not work). Generally for each new project, you can make a new venv. What I suggest to you is:

    (1) create a python3 venv using venv (this is in the standard python packages) on the command line, in the same directory as the CityJSON file:
    python3 -m venv venv

    (2) now a virtual environment called venv is created. You first need to activate it:
    venv\bin\activate (windows) or . venv/bin/activate (linux)

    (3) Now your virtual env is created and activated, you can install cjio:
    pip install cjio

    (4) Run cjio on the command line:
    cjio --help or cjio 3dbag_v210908_fd2cee53_2932.json upgrade save 3dbag_new.json

    I hope this helps


  • Manage to upgrade the json file, now I have this error:

    File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    Error: Python: Traceback (most recent call last):
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 87, in convert
        self.create_new_file()
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 128, in create_new_file
        self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model,
      File "C:\Users\coen_\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
        result = usecase_class(ifc_file, **settings).execute()
    TypeError: Usecase.__init__() got an unexpected keyword argument 'context'
    
    
  • This is good! That means the cityjson file was able to parse. Have you looked at this comment from before? As I said, I have not been able to maintain the repo and any changes in the ifcopenshell module can break the functioning of this module unfortunately. Have you looked at this comment from before:

    @LaurensJN said:
    The **{"context": "Model"} should now be **{"context_type": "Model"}. I think, if I look at https://blenderbim.org/docs-python/autoapi/ifcopenshell/api/context/add_context/index.html

    But the **{} Are a bit redundant, you could also use: ifcopenshell.api.run("context.add_context", self.IFC_model, context_type="Model")

  • @LaurensJN
    Thanks for you answer I fixed that error too, now I get this one:

    Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 88, in convert
        self.create_metadata()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 119, in create_metadata
        self.properties["local_translation"]["TargetCRS"] = self.IFC_model.create_entity("IfcProjectedCrs", Name=f"epsg:{epsg}")
    TypeError: 'NoneType' object does not support item assignment
    Error: Python: Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\bim\module\gis\operator.py", line 44, in execute
        converter.convert(city_model)
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 88, in convert
        self.create_metadata()
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifccityjson\cityjson2ifc\cityjson2ifc.py", line 119, in create_metadata
        self.properties["local_translation"]["TargetCRS"] = self.IFC_model.create_entity("IfcProjectedCrs", Name=f"epsg:{epsg}")
    TypeError: 'NoneType' object does not support item assignment
    
  • Is CityJson actively being developed?

    Getting this error

    Traceback (most recent call last):
      File "C:\Users\cclaus\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\blenderbim\bim\module\gis\operator.py", line 30, in execute
        from ifccityjson.cityjson2ifc.cityjson2ifc import Cityjson2ifc
    ModuleNotFoundError: No module named 'ifccityjson.cityjson2ifc'
    Error: Python: Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
      File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    ModuleNotFoundError: No module named 'ifccityjson.cityjson2ifc'
    

    Or should I use the tool differently? If not, I think I should make a Github issue?

Sign In or Register to comment.