Skip to content

Instantly share code, notes, and snippets.

@feromes
Last active December 20, 2023 10:20
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feromes/b9e7935b9313e7eb7e197d267168ebdb to your computer and use it in GitHub Desktop.
Save feromes/b9e7935b9313e7eb7e197d267168ebdb to your computer and use it in GitHub Desktop.
This follow files intend to help you getting work the IFC Viewer on Windows 10. You really should consider using Linux, but when you are not convinced. Follow the steps

Instructions to getting IFC Viewer working on Jupyter NoteBook

  1. You have to install previously Anaconda and I supposed you're under Windows OS, otherwise you had already IFC Viewer working :)
  2. It's boring but will rid you from some trouble. You should create a new Environment on Anaconda
  • Open Anaconda
  • Go to Environments
  • Click on +Create
  • Choose an appropriate name, like ifc_viewer
  1. Still on Anaconda, we're gonna go deeper. Click on arrow right to the name of the environment you just created, and you should access a menu, and then choose Open Terminal
  2. You must be thrilled to see this beautiful black terminal. I always think I'm Neo in Matrix this time :) But you're here just to install 3 Python Libs that we need to make things working. And you're gonna type the following lines on terminal, hit enter and wait for the magic happens.

conda install -c conda-forge ifcopenshell

conda install -c dlr-sc pythonocc-core

conda install -c conda-forge pythreejs

  1. You should have an IFC file to see Jupyter NoteBook working, I recommend you download IFCOpenHouse
  2. Now, you have to be able to view IFC files on Jupyter Notebook, as the following file attached here in this Gist.
  3. In order to work properly you have to let the both file in the same directory.
  4. By default, when you start Jupyter Notebook on Anaconda, it uses your Home Folder. You should put all files in a folder there, including your IFC File or IFC OpenHouse.
  5. Just start Jupyter Notebook, go to the folder you save the files and open ifc_visualizer.ipynb Pay attention to the Jupyter Notebook cell 2 command file path. It has to point to the correct location and find a valid IFC file.

I hope this lines help you to get involved with programing.

from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer as Renderer
class ifc_viewer(Renderer):
def __init__(self):
Renderer.__init__(self)
self.n = 0
self.products = []
@staticmethod
def subshapes(shp):
import OCC.Core.TopoDS
it = OCC.Core.TopoDS.TopoDS_Iterator(shp)
while it.More():
yield it.Value()
it.Next()
def DisplayShape(self, product, shp, color):
for shp, sty in zip(self.subshapes(shp), color):
Renderer.DisplayShape(self, shp, shape_color=sty[0:3], render_edges=True)
self.products.append(product)
def onclick(self, item):
self.html.value = "Selected %r" % self.products[int(item.name)]
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment