pythonocc-demos icon indicating copy to clipboard operation
pythonocc-demos copied to clipboard

SVG rendering functions missing in display_as_svg notebook

Open artonson opened this issue 5 years ago • 2 comments

Hello,

We have discovered in a freshly installed pythonocc-core (7.4.0rc1) on conda that the two functions required by the display_as_svg jupyter notebook example are not present in the library:

import os

from OCC.Core.gp import gp_Dir
from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer
from OCC.Extend.DataExchange import read_step_file, export_shape_to_svg

results in

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-9-13466bb7a556> in <module>
      3 from OCC.Core.gp import gp_Dir
      4 from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer
----> 5 from OCC.Extend.DataExchange import read_step_file, export_shape_to_svg

ImportError: cannot import name 'export_shape_to_svg' from 'OCC.Extend.DataExchange' (/home/artonson/miniconda3/envs/occ/lib/python3.7/site-packages/OCC/Extend/DataExchange.py)

and

my_renderer.DisplayShapeAsSVG(robot_shp, direction=gp_Dir(1, 1, 0.1),
                              export_hidden_edges=False,
                              line_width=1.5)

yields

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-515d1b0f4da5> in <module>
----> 1 my_renderer.DisplayShapeAsSVG(robot_shp, direction=gp_Dir(1, 1, 0.1),
      2                               export_hidden_edges=False,
      3                               line_width=1.5)

AttributeError: 'JupyterRenderer' object has no attribute 'DisplayShapeAsSVG'

Platform: Linux 16.04 conda 4.6.14

Can you comment on where things could have gone wrong?

Kind regards, Alexey

artonson avatar Jan 24 '20 17:01 artonson

The svg export example was added a few days ago to the example suite. The related code in the pythonocc baseline was committed as the same time, in the branch known as https://github.com/tpaviot/pythonocc-core/tree/review/jupyter-fixes This branch is still under development and has not been merged yet into master, it requires some more tests. It will be available in the next rc2 release.

So far, if you want to test this feature, you can compile the branch by your own or test online at https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/review/jup-fixes and run the display_as_svg notebook. The results should look like

svg_capture

This might interest @Dar5han7 as well.

tpaviot avatar Jan 24 '20 17:01 tpaviot

Thank you! Will try that branch, then.

Does the package build system work in that branch, or is there a working docker?

artonson avatar Jan 25 '20 15:01 artonson