#!/usr/bin/env python
# coding: utf-8
# In[1]:
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
from OCC.Display.WebGl.x3dom_renderer import X3DExporter
# In[2]:
help(X3DExporter)
# In[3]:
shp = read_step_file(os.path.join('..','assets', 'step', 'VentilatorAP203.step'))
# In[4]:
x3dexp = X3DExporter(shp, None, None, True, (1,1,0), (0,0,0), 0, 0, (0,0,0), 2, 1)
# In[5]:
x3dexp.compute()
# In[6]:
len(x3dexp._triangle_sets)
# In[7]:
x3d=x3dexp.to_x3dfile_string(0)
# In[8]:
print(x3d)
# In[9]:
from OCC.Core.VrmlAPI import VrmlAPI_Writer
# In[10]:
help(VrmlAPI_Writer)
# In[11]:
myWriter = VrmlAPI_Writer()
# In[12]:
myWriter.Write(shp,'Vent.wrl')
# In[13]:
from subprocess import *
# In[15]:
run(['chmod','a+x','../bin/tovrmlx3d'])
# In[16]:
out=run(['../bin/tovrmlx3d','--encoding','xml','Vent.wrl'], stdout=PIPE)
# In[17]:
print(out.stdout.decode('UTF-8'))
# In[18]:
x3domHTML = '''
'''
# In[19]:
import xml.etree.ElementTree as ET
# In[20]:
from IPython.display import HTML
# In[21]:
x3domXML = ET.tostring(ET.XML(out.stdout), encoding="unicode", short_empty_elements=False)
# In[22]:
x3domXML
# In[23]:
HTML(x3domHTML + x3domXML)
# In[24]:
x3dXML = ET.tostring(ET.XML(x3d), encoding="unicode", short_empty_elements=False)
# In[25]:
HTML(x3domHTML + x3dXML)
# In[ ]: