BIM2Modelica icon indicating copy to clipboard operation
BIM2Modelica copied to clipboard

update installation instructions

Open thorade opened this issue 5 years ago • 10 comments

When I install the latest version of all packages listed here: https://github.com/UdK-VPT/BIM2Modelica/blob/master/CoTeTo_Generators/IFC_MultiZoneBuildings_Modelica/Filters/IfcLib/README.md

I get an error

import OCC.gp
ModuleNotFoundError: No module named 'OCC.gp'

So maybe this has been removed in pythonocc-core or in oce? Could you show the output of conda list here, or at least the version of pythonocc-coreso I can install the same versions? Probably pythonocc-core version 0.18.1 tpaviot/pythonocc-core#517 (comment)

https://anaconda.org/search?q=pythonocc https://github.com/tpaviot/pythonocc-core#downloadinstall-binaries-for-linuxosxwindows

thorade avatar Dec 04 '19 17:12 thorade

ifcopenshell is now also available via conda: https://anaconda.org/search?q=ifcopenshell https://github.com/IfcOpenShell/IfcOpenShell#installing-ifcopenshell-with-conda https://github.com/IfcOpenShell/IfcOpenShell/issues/582#issuecomment-561726423

Once I find a version that works with the toolchain I will update the installation instructions.

thorade avatar Dec 05 '19 08:12 thorade

Also see https://github.com/IfcOpenShell/IfcOpenShell/issues/736 the package layout is changed in PythonOCC 7.4.0

aothms avatar Dec 07 '19 10:12 aothms

@rurubino1 Answering you question from this issue.

I tried to update the package, but it also updated pythonocc-core to 0.18.2 so I tried to revert but I guess something went wrong and now the environment seems broken (dependency check does not find PyQt5 although it's there and can't even update it). So, I created a new environment from scratch with: conda create --name bim2bem2020 python=3.6 conda activate bim2bem2020 conda install mako pip install -U jinja2 pip install -U lxml pip install -U PyQt5 conda install -c dlr-sc opencascade conda install pythonocc-core conda install ifcopenshell

Then applied #736 as suggested by @aothms . Now I get a different error: INFO: Starting CoTeTo.Controller from file C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\CoTeTo\Controller.py, version 1.0 INFO: IFCFile - loading C:/Users/rurubino/Documents/_RES House Modeling/BIM2BEM/CoTeTo-master/Generators/IFC_MultiZoneBuildings_Modelica/OneZone.ifc INFO: determine building model information for file: C:/Users/rurubino/Documents/_RES House Modeling/BIM2BEM/CoTeTo-master/Generators/IFC_MultiZoneBuildings_Modelica/OneZone.ifc CRITICAL: An unhandled exception occured

Traceback (most recent call last): File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\CoTeTo\GUI.py", line 269, in executeGenerator x = self.activeGenerator.execute(uriList, outputBase) File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\CoTeTo\Generator.py", line 262, in execute self.executeFilter() File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\CoTeTo\Generator.py", line 187, in executeFilter function(self.data, self.controller.systemCfg, self.cfg, self.logger) File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\Generators\IFC_MultiZoneBuildings_Modelica\Filters\Filter01.py", line 497, in filter01 dataModel = mapIFCtoBuildingDataModel(fileData['IfcData'], fileName) File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\Generators\IFC_MultiZoneBuildings_Modelica\Filters\Filter01.py", line 61, in mapIFCtoBuildingDataModel mesh = DataClasses.Mesh(toposhape) File "C:\Users\rurubino\Documents_RES House Modeling\BIM2BEM\CoTeTo-master\Generators\IFC_MultiZoneBuildings_Modelica\Filters\IfcLib\DataClasses.py", line 106, in init facing = (bt.Triangulation(face, location)).GetObject() AttributeError: 'Poly_Triangulation' object has no attribute 'GetObject'

You need to apply changes from IfcOpenShell/IfcOpenShell/issues/736, but be sure to check out the proper tag, matching your version on conda. Also, use the latest PythonOCC, not 0.18.2, you will have more problem with dependencies that it's worth.

And when it comes to PyQt5, install it with conda, not pip. Packages dealing with graphics need system graphic libraries to work and pip can't ship those, but conda can.

I can't help with the last error, maybe upgrading PythonOCC will help.

derbosper avatar Jan 17 '20 00:01 derbosper

I can't help with the last error, maybe upgrading PythonOCC will help.

AttributeError: 'Poly_Triangulation' object has no attribute 'GetObject'

There might be some more breaking changes in PythonOCC 7.4.0. In this case you might be able to get away with just removing the GetObject() call. You can create a condition operator for it, like:

get_object_if_handle = lambda x: x.GetObject() if hasattr(x, 'GetObject') else x

aothms avatar Jan 17 '20 09:01 aothms

Thank you Thomas for your help!

thorade avatar Jan 17 '20 12:01 thorade

Hello all, thanks for the comments above. Just to let you know that we now have a working toolchain, and we are customizing the building model template for our target application. The modifications we had to do to the toolchain in order to make it work are:

  1. create a conda environment with the specification in the attached txt file BIMenv.txt
  2. recompiled Ifcopenshell from latest master and replaced the package in C:\Users<UserName>.conda\envs<CondaEnvName>\Lib\site-packages
  3. modfied IfcLib and libdm files DataClasses.py, Ifc2x3Lib.py and BuildingDataModel.py for OCC changes (replace OCC.* by OCC.Core.*) FiltersDiff
  4. modified line 106 in DataClasses.py (remove .GetObject as suggested by @aothms) DataClassesDiff_getobject
  5. (tentatively?) replaced if-else structures by try-except in Ifc2x3Lib.py (around lines 246, 266, 281) Ifc2x3LibDiff_try-except

I guess it would be good if someone in the development team can take a look and validate the changes above. In particular item 5) seems like a crude workaround, we're not sure if this is the correct or cleanest way to do it. I attach our updated Filters folder for your review. Filters.zip

Hope this helps, Ruello

rurubino1 avatar Mar 03 '20 14:03 rurubino1

Thank you!

thorade avatar Mar 03 '20 17:03 thorade

@rurubino1: Thank you for your support and adaptions of the code to the current OCC version ! I just tested your code with a recompiled ifcopenshell libray and it works fine. So I included your changes into the latest submit.

I also updated the submodule of the BuildingSystems library to he latest version.

I will think about topic 5. (try: and except: instead of if: and else: ... )

Best Christoph

nytschgeusen avatar Mar 03 '20 20:03 nytschgeusen

@nytschgeusen : No problem, I really like this toolchain and think it can really be useful to facilitate building modeling in our applications. Once you understand how to use it (looking forward to some documentation!) it's also very easy to customize to generate any modelica model specific to your application. By the way I take this opportunity to ask you if you happen to have or know some contact who might have examples of IFC files for US residential type of buildings? Thanks a lot, Ruello

rurubino1 avatar Mar 04 '20 08:03 rurubino1

Regarding if-else versus try-except, this is also known as LBYL versus EAFP

LBYL: Look before you leap. -> if-else https://docs.python.org/3/glossary.html#term-lbyl EAFP: Easier to ask for forgiveness than permission. -> try-except https://docs.python.org/3/glossary.html#term-eafp

https://devblogs.microsoft.com/python/idiomatic-python-eafp-versus-lbyl/ https://stackoverflow.com/questions/11360858/what-is-the-eafp-principle-in-python

thorade avatar Mar 04 '20 09:03 thorade