6
6
import traceback
7
7
8
8
from json import dumps
9
- from pathlib import Path
10
- from uuid import uuid1 as uuid
11
- from textwrap import indent
12
9
13
10
from cadquery import exporters , Assembly , Compound , Color , Sketch
14
11
from cadquery import cqgi
15
12
from 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
20
14
from docutils .parsers .rst import directives , Directive
21
15
22
16
template = """
30
24
</div>
31
25
32
26
"""
33
- template_content_indent = " "
34
27
35
28
rendering_code = """
36
29
const RENDERERS = {};
@@ -216,10 +209,8 @@ class cq_directive(Directive):
216
209
217
210
has_content = True
218
211
required_arguments = 0
219
- optional_arguments = 2
212
+ optional_arguments = 0
220
213
option_spec = {
221
- "height" : directives .length_or_unitless ,
222
- "width" : directives .length_or_percentage_or_unitless ,
223
214
"align" : directives .unchanged ,
224
215
}
225
216
@@ -278,7 +269,7 @@ class cq_directive_vtk(Directive):
278
269
279
270
has_content = True
280
271
required_arguments = 0
281
- optional_arguments = 2
272
+ optional_arguments = 0
282
273
option_spec = {
283
274
"height" : directives .length_or_unitless ,
284
275
"width" : directives .length_or_percentage_or_unitless ,
@@ -291,9 +282,6 @@ def run(self):
291
282
options = self .options
292
283
content = self .content
293
284
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"
297
285
298
286
# only consider inline snippets
299
287
plot_code = "\n " .join (content )
@@ -321,21 +309,14 @@ def run(self):
321
309
traceback .print_exc ()
322
310
assy = Assembly (Compound .makeText ("CQGI error" , 10 , 5 ))
323
311
324
- # save vtkjs to static
325
- fname = Path (str (uuid ()))
326
- exporters .assembly .exportVTKJS (assy , out_path / fname )
327
- fname = str (fname ) + ".zip"
328
-
329
312
# add the output
330
313
lines = []
331
314
332
315
data = dumps (toJSON (assy ))
333
316
334
317
lines .extend (
335
318
template_vtk .format (
336
- code = indent (TEMPLATE_RENDER .format (), " " ),
337
319
data = data ,
338
- ratio = "null" ,
339
320
element = "document.currentScript.parentNode" ,
340
321
txt_align = options .get ("align" , "left" ),
341
322
width = options .get ("width" , "100%" ),
0 commit comments