Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update installation instructions #3

Open
thorade opened this issue Dec 4, 2019 · 10 comments
Open

update installation instructions #3

thorade opened this issue Dec 4, 2019 · 10 comments

Comments

@thorade
Copy link
Contributor

thorade commented Dec 4, 2019

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 thorade closed this as completed Dec 4, 2019
@thorade thorade changed the title pythonocc-core version update installation instructions Dec 5, 2019
@thorade thorade reopened this Dec 5, 2019
@thorade
Copy link
Contributor Author

thorade commented Dec 5, 2019

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

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

@aothms
Copy link

aothms commented Dec 7, 2019

Also see IfcOpenShell/IfcOpenShell#736 the package layout is changed in PythonOCC 7.4.0

@derbosper
Copy link

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

@aothms
Copy link

aothms commented Jan 17, 2020

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

@thorade
Copy link
Contributor Author

thorade commented Jan 17, 2020

Thank you Thomas for your help!

@rurubino1
Copy link

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

@thorade
Copy link
Contributor Author

thorade commented Mar 3, 2020

Thank you!

@nytschgeusen
Copy link
Member

@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

@rurubino1
Copy link

@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

@thorade
Copy link
Contributor Author

thorade commented Mar 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants