Import/Export IFC - IfcOpenShell kompilieren

From FreeCAD Documentation
Revision as of 22:23, 8 June 2020 by Maker (talk | contribs) (Created page with "3. Sobald es beendet ist (ich kann mich jetzt nicht mehr erinnern, aber es wird etwas wie "Built IfcOpenShell..." ausgegeben und es kehrt zu deiner Eingabeaufforderung zurück...")
Tutorium
Thema
Arch Arbeitsbereich
Niveau
Fortgeschritten
Zeit zum Abschluss
120 Minuten
Autoren
Pablo Gil
FreeCAD-Version
Beispieldateien
Siehe auch
None

Einführung

Es war eine so harte Nachforschung darüber, wie man eine Arbeitskopie von IfcOpenShell python unter OSX/macOS erhält, um IFC Dateien zu importieren/exportieren, dass ich dieses Tutorial weitergebe, falls es mehr Leuten hilft. Mein System ist OSX 10.11.6, 64bits mit Python 2.7.11, es könnte für dich funktionieren, wenn du auch OSX hast, da sie oft 64bit sind, aber von meinem abweichen können. Die Prozedur könnte sehr ähnlich sein, wenn du Linux oder Windows verwendest, aber es gibt wahrscheinlich einige Unterschiede.

Schritte

1. Lade das vollständige GitHub Projekt unter https://github.com/IfcOpenShell/IfcOpenShell herunter oder klone es (es wird immer die neueste Version sein)

git Klon https://github.com/IfcOpenShell/IfcOpenShell

2. Gehe von einem Terminal aus zum Ordner /nix/ und starte das Skript. In OSX wird es ausgeführt mit:

cd nix/
./build-all.sh

Es wird zwischen 30 und 120 Minuten dauern, um alles zusammenzustellen. Es ist nicht der intelligentere Weg IfcOpenShell zu kompilieren, aber dieses einfache Skript wird alle Abhängigkeiten, Python Versionen usw. kompilieren.

3. Sobald es beendet ist (ich kann mich jetzt nicht mehr erinnern, aber es wird etwas wie "Built IfcOpenShell..." ausgegeben und es kehrt zu deiner Eingabeaufforderung zurück), du wirst einen neuen Ordner /IfcOpenShell/build/ voller Dateien und Ordner haben. Meiner persönlichen Erfahrung nach wurde das nix "build-all.sh" Skript vor zwei Wochen nicht erfolgreich beendet, aber nachdem ich es gestern mit den neuesten Updates ausprobiert habe, hat es gut funktioniert, so dass ich vermute, du könntest etwas Ähnliches erleben, falls die Entwicklung weiter geht... Jetzt hast du also alles, was du brauchst, aber du mußt noch etwas Handarbeit leisten, um es zum Laufen zu bringen:

4. Open FreeCAD and open the Python console and Report view. Then write into the Python console the following:

import sys
print sys.path

You will get a looooong line with all the paths that FreeCAD reads. You may be able to install IfcOpenShell in any of them but I suggest you to place it inside one where you find a /site-packages/ after a /Python/ or /python-something/. In my case it was /Library/Python/2.7/site-packages. (Note: you will find paths inside your app directory but I suggest you to not use them because then IfcOpenShell will only be available for this app)

5. Once located where you want/have to install it, go there with your file browser (Finder in OSX). That is, go inside /site-packages/ folder

cd site-packages/

6. Open a new file browser window and navigate to your downloaded GitHub project: /IfcOpenShell/src/ifcopenshell-python/ and copy the full /ifcopenshell/ folder

7. Paste it inside /site-packages/ folder. Now you should have something like:

/site-packages/ifcopenshell/__init__.py
/site-packages/ifcopenshell/entity_instance.py
/site-packages/ifcopenshell/file.py
/site-packages/ifcopenshell/geom/app.py
/site-packages/ifcopenshell/geom/main.py
/site-packages/ifcopenshell/geom/occ_utils.py
/site-packages/ifcopenshell/geom/__init__.py
/site-packages/ifcopenshell/guid.py

8. Now we have to pick to files inside the /build/ folder, they are:

_ifcopenshell_wrapper.so
ifcopenshell_wrapper.py

but as we have compiled everything you will have to pick the one that matches with your FreeCAD Python version. Check it easily reading the first line inside your FreeCAD Python console view. In my case it was Python 2.7.11.

9. Now go let's copy the files inside the place it corresponds to your Python version. In my case it was:

/IfcOpenShell/build/Darwin/x86_64/build/ifcopenshell/[b]python-2.7[/b].10/ifcwrap/

10. Paste them inside /site-packages/ifcopenshell/

11. Check everything is in place:

/site-packages/ifcopenshell/__init__.py                  (1)
/site-packages/ifcopenshell/entity_instance.py           (1)
/site-packages/ifcopenshell/_ifcopenshell_wrapper.so     (2)
/site-packages/ifcopenshell/file.py                      (1)
/site-packages/ifcopenshell/geom/__init__.py             (1)
/site-packages/ifcopenshell/geom/app.py                  (1)
/site-packages/ifcopenshell/geom/main.py                 (1)
/site-packages/ifcopenshell/geom/occ_utils.py            (1)
/site-packages/ifcopenshell/guid.py                      (1)
/site-packages/ifcopenshell/ifcopenshell_wrapper.py      (2)

(1) from GitHub project
(2) from /build/ folder


12. Close and reopen FreeCAD

Testing

Now that it is installed, let's check if everything works as expected:

12.1 in the Python console write:

import ifcopenshell
from ifcopenshell import geom

if it doesn't throw any error it means it may be correctly installed

12.2 Go to Yorik's FreeCAD manual, navigate to the lower part of the page and download the following files to test:

house.FCStd
house.ifc

12.3 Open house.FCStd, select the root "Building" object and export it (File → Export) setting the File type to "Industry Foundation Classes (*.ifc)". Press Save and if it works and it doesn't throw an error in the Report view then it's working.

12.4 Final test, import house.ifc into a new file so open a new file and import that file... it will take a while.

13. Viel Spaß an BIM mit FreeCAD!

Abschließende Gedanken

Meine Meinung ist, dass FreeCAD selbst vorkompilierte Versionen von IfcOpenShell mit der Distribution gebündelt haben sollte, weil es eine totale Qual ist, es selbst zu bauen, und der durchschnittliche Benutzer wird es nicht tun (er weiß nicht, wie man GitHub kompiliert, verwaltet usw.), aber na ja, vielleicht in der Zukunft.

Ich hoffe, es hilft Euch.

Tschüss

Verweise