buildingsmart-community / ifcJSON

Repository containing the specification for IFC.JSON
MIT License
133 stars 31 forks source link

Errors when testing json2ifc #10

Open mickey58github opened 3 years ago

mickey58github commented 3 years ago

I'm trying to run json2ifc with a simple json test file, to convert it to ifc. I get an error:

json2ifc.py", line 28, in <module>
    ifc_json = ifcjson.JSON2IFC(jsonFilePath)
AttributeError: module 'ifcjson' has no attribute 'JSON2IFC'

Is conversion from json to ifc supported at this point? I read "round-tripping is supported", therefore my question....

janbrouwer commented 3 years ago

For now the main focus has been on IFC SPF to ifcJSON, roundtripping should work but it's not activated by default due to an additional dependency on pandas. Can you try again while uncommenting the JSON2IFC line in: https://github.com/buildingSMART/ifcJSON/blob/master/file_converters/ifcjson/__init__.py

mickey58github commented 3 years ago

Thanks, Jan, for responding late at night in Europe: I tried your suggestion, but indeed get a pandas related error:

python json2ifc.py -i myFirstTestModel.json -o myFirstTestModelRoundTripped.ifc
Traceback (most recent call last):
  File "C:\Users\--\Documents\GitHub\ifcJSON\file_converters\json2ifc.py", line 11, in <module>
    import ifcjson
  File "C:\Users\...\Documents\GitHub\ifcJSON\file_converters\ifcjson\__init__.py", line 4, in <module>
    from ifcjson.to_ifcopenshell import JSON2IFC
  File "C:\Users\...\Documents\GitHub\ifcJSON\file_converters\ifcjson\to_ifcopenshell.py", line 2, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

Can this be resolved somehow? I'm more experienced in Node and JS, not in Python, so my questions may sound a bit strange ;-)

janbrouwer commented 3 years ago

Yes, fixing that should be easy. Just:

pip install pandas

or

conda install pandas
mickey58github commented 3 years ago

I did this from my Conda shell:

conda activate ifcjson
conda install pandas

Which tells me it installed pandas successfully...but strangely, I get the same error when executing "python json2ifc ...". This might be due to my unusual"split" setup:

Not sure how to get these 2 unified somehow....

Update: I ran an additional "pip install pandas" from c:\users...Documents\GitHub\ifcJson,, which was successful. Now I can run "python json2ifc...", but get a different error, a bit further down:

python json2ifc.py -i myFirstTestModel.json -o myFirstTestModelRoundTripped.ifc
Not a valid ifcJson file
Traceback (most recent call last):
  File "C:\Users\...\Documents\GitHub\ifcJSON\file_converters\json2ifc.py", line 29, in <module>
    ifc_model = ifc_json.ifcModel()
  File "C:\Users\...\Documents\GitHub\ifcJSON\file_converters\ifcjson\to_ifcopenshell.py", line 150, in ifcModel
    return self.model
AttributeError: 'JSON2IFC' object has no attribute 'model'

Further details:

mickey58github commented 3 years ago

@janbrouwer : Any chance to review the above problem with the backward conversion from json to ifc?

janbrouwer commented 3 years ago

I'm sorry, it's been a busy week! The round-trip currently only only works with "official" IFC schema versions that are recognized by ifcopenshell. The IFC5a version is the "forward looking" idea by the ifcJSON team, nothing official and currently with limited use. Can you give it a try with ifc2json set to version 4?