{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import ifcopenshell\n", "import ifcopenshell.geom\n", "\n", "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, format_color\n", "my_renderer = JupyterRenderer(size=(700, 700))\n", "\n", "# Specify to return pythonOCC shapes from ifcopenshell.geom.create_shape()\n", "settings = ifcopenshell.geom.settings()\n", "settings.set(settings.USE_PYTHON_OPENCASCADE, True)\n", "\n", "# Initialize a graphical display window\n", "#occ_display = ifcopenshell.geom.utils.initialize_display()\n", "\n", "# Open the IFC file using IfcOpenShell\n", "ifc_file = ifcopenshell.open(\"Ifcopenhouse.ifc\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "INFO:OCC.Display.backend:backend loaded: qt-pyqt5\n", "INFO:OCC.Display.SimpleGui:GUI backend set to: qt-pyqt5\n" ] } ], "source": [ "# Uso de janela alternativa para exibição do modelo\n", "from OCC.Display.SimpleGui import init_display\n", "display, start_display, add_menu, add_function_to_menu = init_display()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.09999999999999998\n", "0.09999999999999998\n", "0.09999999999999998\n", "0.09999999999999998\n", "0.09999999999999998\n" ] } ], "source": [ "i=0\n", "# Display the geometrical contents of the file using Python OpenCascade\n", "products = ifc_file.by_type(\"IfcProduct\")\n", "for product in products:\n", " if product.is_a(\"IfcOpeningElement\"): continue\n", " if product.Representation:\n", " shape = ifcopenshell.geom.create_shape(settings, product)\n", " r,g,b,alpha = shape.styles[0] # the shape color\n", " color = format_color(int(abs(r)*255), int(abs(g)*255), int(abs(b)*255))\n", " \n", " if product.is_a(\"IfcPlate\"):\n", " my_renderer.DisplayShape(shape.geometry, shape_color = color, transparency=True, opacity=alpha)\n", " print(alpha)\n", " else:\n", " my_renderer.DisplayShape(shape.geometry, shape_color = color, transparency=False) \n", " \n", " # Uso de janela alternativa para exibição do modelo\n", " display.DisplayShape(shape.geometry)\n", " \n", " #display_shape = ifcopenshell.geom.utils.display_shape(shape)\n", " i=i+1\n", " #if product.is_a(\"IfcPlate\"):\n", " # Plates are the transparent parts of the window assembly\n", " # in the IfcOpenHouse model\n", " #ifcopenshell.geom.utils.set_shape_transparency(display_shape, 0.8) " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Uso de janela alternativa para exibição do modelo\n", "display.FitAll()\n", "#display.display_graduated_trihedron()\n", "start_display()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "91cb1159d6314a49ab1f2a64c0c3c60b", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(VBox(children=(HBox(children=(Checkbox(value=True, description='Axes', layout=Layout(height='au…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "my_renderer.Display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }