66import traceback
77
88from json import dumps
9- from pathlib import Path
10- from uuid import uuid1 as uuid
11- from textwrap import indent
129
1310from cadquery import exporters , Assembly , Compound , Color , Sketch
1411from cadquery import cqgi
1512from cadquery .occ_impl .assembly import toJSON
16- from cadquery .occ_impl .jupyter_tools import (
17- TEMPLATE_RENDER ,
18- DEFAULT_COLOR ,
19- )
13+ from cadquery .occ_impl .jupyter_tools import DEFAULT_COLOR
2014from docutils .parsers .rst import directives , Directive
2115
2216template = """
3024 </div>
3125
3226"""
33- template_content_indent = " "
3427
3528rendering_code = """
3629const RENDERERS = {};
@@ -216,10 +209,8 @@ class cq_directive(Directive):
216209
217210 has_content = True
218211 required_arguments = 0
219- optional_arguments = 2
212+ optional_arguments = 0
220213 option_spec = {
221- "height" : directives .length_or_unitless ,
222- "width" : directives .length_or_percentage_or_unitless ,
223214 "align" : directives .unchanged ,
224215 }
225216
@@ -278,7 +269,7 @@ class cq_directive_vtk(Directive):
278269
279270 has_content = True
280271 required_arguments = 0
281- optional_arguments = 2
272+ optional_arguments = 0
282273 option_spec = {
283274 "height" : directives .length_or_unitless ,
284275 "width" : directives .length_or_percentage_or_unitless ,
@@ -291,9 +282,6 @@ def run(self):
291282 options = self .options
292283 content = self .content
293284 state_machine = self .state_machine
294- env = self .state .document .settings .env
295- build_path = Path (env .app .builder .outdir )
296- out_path = build_path / "_static"
297285
298286 # only consider inline snippets
299287 plot_code = "\n " .join (content )
@@ -321,21 +309,14 @@ def run(self):
321309 traceback .print_exc ()
322310 assy = Assembly (Compound .makeText ("CQGI error" , 10 , 5 ))
323311
324- # save vtkjs to static
325- fname = Path (str (uuid ()))
326- exporters .assembly .exportVTKJS (assy , out_path / fname )
327- fname = str (fname ) + ".zip"
328-
329312 # add the output
330313 lines = []
331314
332315 data = dumps (toJSON (assy ))
333316
334317 lines .extend (
335318 template_vtk .format (
336- code = indent (TEMPLATE_RENDER .format (), " " ),
337319 data = data ,
338- ratio = "null" ,
339320 element = "document.currentScript.parentNode" ,
340321 txt_align = options .get ("align" , "left" ),
341322 width = options .get ("width" , "100%" ),
0 commit comments