OSArch Community

[IfcOpenShell] Cityjson to IFC

  1. L

    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

  2. C

    @LaurensJN

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

  3. C
  4. L

    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

  5. C

    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'
    
    
  6. L

    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")

  7. C

    @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
    
  8. C

    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?

  1. Page 1
  2. 2
  3. 3

Login or Register to reply.