Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
966 lines (875 loc) · 72.4 KB
/
Copy pathindex.html
File metadata and controls
966 lines (875 loc) · 72.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>depsgraph-export — Examples — Blender Developer Tools</title>
<meta name="description" content="The depsgraph lifetime contract — evaluated_get().to_mesh() paired with to_mesh_clear() — measured against an OBJ export of the same object." />
<link rel="canonical" href="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/depsgraph-export/" />
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml" />
<meta name="theme-color" content="#1a1b1e" />
<meta name="color-scheme" content="dark" />
<meta property="og:type" content="website" />
<meta property="og:title" content="depsgraph-export — Examples — Blender Developer Tools" />
<meta property="og:description" content="The depsgraph lifetime contract — evaluated_get().to_mesh() paired with to_mesh_clear() — measured against an OBJ export of the same object." />
<meta property="og:url" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/depsgraph-export/" />
<meta property="og:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/depsgraph-export-hero.webp" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="720" />
<meta property="og:image:alt" content="A game controller's sparse control cage in orange wire and vertex beads beside the smooth subdivided cobalt controller with sticks and colored buttons, on a dark studio floor." />
<meta property="og:site_name" content="Blender Developer Tools" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="depsgraph-export — Examples — Blender Developer Tools" />
<meta name="twitter:description" content="The depsgraph lifetime contract — evaluated_get().to_mesh() paired with to_mesh_clear() — measured against an OBJ export of the same object." />
<meta name="twitter:image" content="https://tmhsdigital.github.io/Blender-Developer-Tools/gallery/assets/depsgraph-export-hero.webp" />
<meta name="twitter:image:alt" content="A game controller's sparse control cage in orange wire and vertex beads beside the smooth subdivided cobalt controller with sticks and colored buttons, on a dark studio floor." />
<style>
/* fonts are deployed by the landing build (docs/fonts/) */
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap;
src: url('../../fonts/barlow-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap;
src: url('../../fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap;
src: url('../../fonts/inter-medium.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap;
src: url('../../fonts/jetbrains-mono-regular.woff2') format('woff2'); }
/* Blender-viewport system, shared with the landing page. Dark only. */
:root {
color-scheme: dark;
--bg: #1a1b1e; --surface: #222327; --surface-2: #2a2b30; --bg2: #131417;
--border: #3a3b40; --text: #e8e9eb; --text-dim: #9698a0;
--select: #ff8c19; --ok: #6dc96d;
--radius: 4px; --radius-lg: 6px; --maxw: 1080px;
--font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
--font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
--code-k: #ff7b72; --code-s: #a5d6ff; --code-c: #9698a0; --code-n: #79c0ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text);
line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--select); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--select) 40%, transparent); }
.skip { position: absolute; left: -999px; top: 0; background: var(--select); color: #1a1b1e;
padding: 0.5rem 1rem; border-radius: var(--radius); z-index: 10; font-weight: 500; }
.skip:focus { left: 0.5rem; top: 0.5rem; }
.hud { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.04em;
color: var(--text-dim); text-transform: uppercase; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
justify-content: space-between; gap: 1rem; padding: 0 1.25rem; height: 46px;
background: color-mix(in srgb, var(--surface) 92%, transparent);
backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .back { color: var(--text-dim); font-size: 0.8125rem; font-weight: 500; }
.topbar .back:hover { color: var(--select); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 0.85rem; }
.topbar-right .ghlink { color: var(--text-dim); font-size: 0.8125rem; font-weight: 500; }
.topbar-right .ghlink:hover { color: var(--select); text-decoration: none; }
header.hero { max-width: var(--maxw); margin: 0 auto; padding: 2.75rem 1.25rem 1.25rem; }
header.hero h1 { font-family: var(--font-display); font-weight: 600; text-transform: uppercase;
font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: 0.005em; line-height: 0.98; }
header.hero p { color: var(--text-dim); max-width: 62ch; margin-top: 0.7rem; font-size: 1rem; }
/* ---- index: sticky controls (search, density toggle, tag chips) ---- */
.controls { position: sticky; top: 46px; z-index: 4;
background: color-mix(in srgb, var(--bg) 94%, transparent);
backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border); }
.controls-inner { max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1.25rem 0.6rem;
display: flex; flex-direction: column; gap: 0.5rem; }
.controls-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.searchwrap { position: relative; flex: 1 1 240px; min-width: 150px; }
.searchwrap input { width: 100%; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text); border-radius: var(--radius); padding: 0.34rem 1.9rem 0.34rem 0.7rem;
font-family: var(--font-sans); font-size: 0.85rem; line-height: 1.4; }
.searchwrap input:focus { border-color: var(--select); outline: none; }
.searchwrap input::placeholder { color: var(--text-dim); }
.searchwrap input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.q-clear { position: absolute; right: 0.2rem; top: 50%; transform: translateY(-50%);
background: none; border: none; color: var(--text-dim); font-size: 1.05rem; line-height: 1;
cursor: pointer; padding: 0.25rem 0.45rem; border-radius: 3px; }
.q-clear:hover { color: var(--select); }
.count { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em;
text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.density { display: flex; border: 1px solid var(--border); border-radius: var(--radius);
overflow: hidden; }
.density-btn { background: var(--surface-2); border: none; color: var(--text-dim); cursor: pointer;
font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.04em;
text-transform: uppercase; padding: 0.36rem 0.7rem; transition: color 0.15s, background 0.15s; }
.density-btn + .density-btn { border-left: 1px solid var(--border); }
.density-btn:hover { color: var(--select); }
.density-btn.active { background: var(--select); color: #1a1b1e; }
.tags-toggle { display: none; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text-dim); border-radius: 3px; padding: 0.3rem 0.7rem; cursor: pointer;
font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.tags-toggle:hover, .tags-toggle.has-active { color: var(--select); border-color: var(--select); }
/* Tag chips wrap by default (no-JS safe). With JS the row becomes a scroll
strip on wide viewports and collapses behind the Tags toggle on narrow
ones, so the sticky bar never eats the mobile viewport. */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
html.js .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.25rem;
scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
html.js .chips::-webkit-scrollbar { height: 5px; }
html.js .chips::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
border-radius: 3px; padding: 0.22rem 0.7rem; font-size: 0.72rem; font-weight: 400;
font-family: var(--font-mono); cursor: pointer; white-space: nowrap; flex: 0 0 auto;
transition: color 0.15s, border-color 0.15s; }
.chip:hover { color: var(--select); border-color: var(--select); }
.chip.active { color: #1a1b1e; background: var(--select); border-color: var(--select); }
@media (max-width: 719px) {
html.js .tags-toggle { display: inline-block; }
html.js .chips { display: none; }
html.js .chips.open { display: flex; flex-wrap: wrap; overflow-y: auto; max-height: 40vh; }
}
/* Compact density: hero + name + one-line teaser. The description and
WITNESSES text stay in the DOM (searchable, screen-reader reachable,
present with JS disabled when the class is never applied) but are
visually collapsed. Applied only by JS via the density-compact class. */
html.density-compact .grid { gap: 1rem; }
html.density-compact .card-body { padding: 0.65rem 0.9rem 0.7rem; }
html.density-compact .card-body h2 { font-size: 0.88rem; margin-bottom: 0.15rem; }
html.density-compact .teaches { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.density-compact .witnesses { position: absolute; width: 1px; height: 1px; margin: -1px;
padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
html.density-compact .card-link { display: none; }
.noresults { color: var(--text-dim); text-align: center; padding: 3rem 1rem; font-size: 0.95rem; }
.noresults .chip { margin-left: 0.6rem; }
.to-top { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 6; cursor: pointer;
background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
border-radius: var(--radius); padding: 0.45rem 0.75rem;
font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.04em;
text-transform: uppercase; opacity: 0; visibility: hidden;
transition: opacity 0.2s, visibility 0.2s, color 0.15s, border-color 0.15s; }
.to-top.show { opacity: 1; visibility: visible; }
.to-top:hover { color: var(--select); border-color: var(--select); }
main { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1.25rem 2rem; }
.grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
overflow: hidden; display: flex; flex-direction: column;
outline: 2px solid transparent; outline-offset: -1px;
transition: outline-color 0.12s ease, border-color 0.12s ease; }
.card:hover { border-color: var(--select); outline-color: var(--select); }
.card.hidden { display: none; }
.card-media { display: block; background: var(--bg2); line-height: 0; }
.card-media img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card-body { padding: 1.15rem 1.4rem 1.45rem; display: flex; flex-direction: column; flex: 1 1 auto; }
.card-body h2 { font-family: var(--font-mono); font-size: 1rem; font-weight: 400; margin-bottom: 0.5rem; }
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--select); text-decoration: none; }
.teaches { color: var(--text); margin-bottom: 0.7rem; font-size: 0.92rem; }
.witnesses { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.tag { display: inline-block; font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase;
letter-spacing: 0.06em; color: var(--select); border: 1px solid color-mix(in srgb, var(--select) 55%, transparent);
border-radius: 3px; padding: 0.08rem 0.5rem; margin-right: 0.4rem; vertical-align: 1px; }
.card-link { font-weight: 600; font-size: 0.95rem; margin-top: auto; }
/* ---- detail page ---- */
.detail-hero { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
background: var(--bg2); padding: 0; display: block; width: 100%; cursor: zoom-in; line-height: 0; }
.detail-hero img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.zoom-hint { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
white-space: nowrap; }
.callout { border: 1px solid color-mix(in srgb, var(--select) 45%, var(--border));
border-left: 3px solid var(--select); border-radius: var(--radius);
background: color-mix(in srgb, var(--select) 7%, var(--surface));
padding: 0.85rem 1.1rem; margin: 1.5rem 0; font-size: 0.95rem; }
.runline { display: flex; align-items: stretch; gap: 0.5rem; margin: 1.5rem 0; }
.runline pre { flex: 1 1 auto; background: var(--surface-2); border: 1px solid var(--border);
border-radius: var(--radius); padding: 0.7rem 0.9rem; overflow-x: auto;
font-family: var(--font-mono); font-size: 0.83rem; line-height: 1.5; }
.copy-btn { flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--border);
color: var(--text-dim); border-radius: var(--radius); padding: 0 0.85rem; cursor: pointer;
font-family: var(--font-sans); font-size: 0.82rem; font-weight: 500; transition: color 0.15s, border-color 0.15s; }
.copy-btn:hover { color: var(--select); border-color: var(--select); }
.detail-section { margin-top: 2.25rem; }
.detail-section > h2 { font-family: var(--font-display); font-weight: 600; text-transform: uppercase;
font-size: 1.45rem; letter-spacing: 0.005em; padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.md h1, .md h2, .md h3 { letter-spacing: -0.01em; margin: 1.4rem 0 0.6rem; line-height: 1.25; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1rem; }
.md p { margin: 0.7rem 0; }
.md ul, .md ol { margin: 0.7rem 0 0.7rem 1.4rem; }
.md li { margin: 0.3rem 0; }
.md .table-wrap { overflow-x: auto; margin: 0.9rem 0; }
.md table { border-collapse: collapse; font-size: 0.86rem; min-width: 100%; }
.md th, .md td { text-align: left; vertical-align: top; padding: 0.4rem 0.75rem 0.4rem 0;
border-bottom: 1px solid var(--border); }
.md th { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.md code { background: var(--surface-2); border: 1px solid var(--border); padding: 0.08rem 0.35rem;
border-radius: 4px; font-family: var(--font-mono); font-size: 0.84em; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
padding: 0.85rem 1rem; overflow-x: auto; margin: 0.9rem 0; }
.md pre code { background: none; border: none; padding: 0; font-size: 0.83rem; line-height: 1.55; }
.src pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
padding: 1rem 1.1rem; overflow-x: auto; font-family: var(--font-mono);
font-size: 0.82rem; line-height: 1.55; }
.src .k { color: var(--code-k); } .src .s { color: var(--code-s); }
.src .c { color: var(--code-c); font-style: italic; } .src .n { color: var(--code-n); }
.src-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
flex-wrap: wrap; margin-bottom: 0.6rem; color: var(--text-dim); font-size: 0.85rem; }
.src-meta code { font-family: var(--font-mono); font-size: 0.82rem; }
.lightbox { border: 0; margin: 0; padding: 2rem; width: 100%; height: 100%; max-width: none;
max-height: none; background: rgba(0,0,0,0.85); cursor: zoom-out; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }
.lightbox-close { position: absolute; top: 0.9rem; right: 0.9rem; background: var(--surface-2);
color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
font: 500 0.8rem var(--font-sans); padding: 0.4rem 0.75rem; cursor: pointer; }
.lightbox-close:hover { border-color: var(--select); color: var(--select); }
footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 2rem; }
footer .statusbar { max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1.25rem;
display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.04em;
text-transform: uppercase; color: var(--text-dim); }
footer .statusbar code { font-family: inherit; text-transform: none; }
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr; gap: 1.75rem; } }
@media (min-width: 560px) { html.density-compact .grid { grid-template-columns: 1fr 1fr; gap: 1rem; } }
@media (min-width: 900px) { html.density-compact .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1560px) {
html.density-compact .controls-inner,
html.density-compact main { max-width: 1400px; }
html.density-compact .grid { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
html { scroll-behavior: auto; }
.card { transition: none; }
.card:hover { transform: none; }
.to-top { transition: none; }
}
</style>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<div class="topbar">
<a class="back" href="../"><span aria-hidden="true">←</span> Examples and Showcase</a>
<div class="topbar-right">
<a class="ghlink" href="https://github.com/TMHSDigital/Blender-Developer-Tools">GitHub</a>
</div>
</div>
<header class="hero">
<h1>depsgraph-export</h1>
<p>The depsgraph lifetime contract — evaluated_get().to_mesh() paired with to_mesh_clear() — measured against an OBJ export of the same object.</p>
</header>
<main id="main">
<button class="detail-hero" id="heroZoom" type="button" aria-label="View full size: A game controller's sparse control cage in orange wire and vertex beads beside the smooth subdivided cobalt controller with sticks and colored buttons, on a dark studio floor.">
<img src="../assets/depsgraph-export-hero.webp" alt="A game controller's sparse control cage in orange wire and vertex beads beside the smooth subdivided cobalt controller with sticks and colored buttons, on a dark studio floor." width="1280" height="720" />
</button>
<p class="zoom-hint">Rendered headless by the example itself — click to zoom.</p>
<div class="callout"><span class="tag">witnesses</span> Exports ship evaluated geometry: the controller shell subdivides to exactly its Catmull-Clark closed form, and the exported vertex count equals the subsurf-applied count, strictly greater than the base mesh.</div>
<div class="runline">
<pre id="runCmd">blender --background --python examples/depsgraph-export/depsgraph_export.py --</pre>
<button class="copy-btn" id="copyRun" type="button">Copy</button>
</div>
<section class="detail-section md">
<p>A runnable example that proves <strong>modifiers actually ship in exports</strong> and demonstrates the <a href="https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/skills/depsgraph-and-evaluated-data/SKILL.md"><code>depsgraph-and-evaluated-data</code></a> lifetime contract. It builds a game controller whose shell is a sparse quad control cage (90 vertices) under a level-2 <code>SUBSURF</code> modifier, with the sticks, d-pad, face buttons and bumpers modeled as ordinary parts parented to it. It measures every mesh via <code>evaluated_get().to_mesh()</code> (each paired with <code>to_mesh_clear()</code>), exports the scene through <code>wm.obj_export</code>, and asserts:</p>
<ul><li>the evaluated shell has exactly the vertex count the Catmull-Clark closed form predicts from the cage's own topology — per level <code>V' = V + E + F</code>, <code>E' = 2E + S</code>, <code>F' = S</code> (S = face corners) — which for this cage (V=90, E=176, F=88, S=352) is <strong>1,410</strong>;</li><li>the exported OBJ vertex count equals the summed <strong>evaluated</strong> counts of every mesh (3,666), not the summed base counts (2,346).</li></ul>
<p><strong>What it witnesses:</strong> the <code>evaluated_get</code> → <code>to_mesh</code> → <code>to_mesh_clear</code> contract, and that <code>wm.obj_export</code> writes the depsgraph-evaluated geometry (so modifiers are baked into the export) rather than the unmodified base mesh.</p>
<h2>The render</h2>
<p>Left: the shell datablock as the <code>.blend</code> stores it — its 90-vertex control cage drawn as orange wire with a bead on every vertex, over faint blue facets. Right: the same object as the depsgraph evaluates it and the OBJ contains it — the smooth subdivided cobalt controller with its controls. If the export shipped the base mesh, the right-hand piece would be the blocky cage on the left.</p>
<p>Both pieces lean toward the camera on low satin display stands (render-only, added after the check and export have run).</p>
<h2>Run</h2>
<pre><code># Cheap correctness check (writes an OBJ to a temp path, asserts the counts) — the CI check:
blender --background --python depsgraph_export.py --
# Falsifier: apply_modifiers=False. Must exit non-zero (export ≠ evaluated).
blender --background --python depsgraph_export.py -- --unevaluated
# Also render a still of cage vs evaluated (EEVEE on a GPU host; cycles on GPU-less hosts):
blender --background --python depsgraph_export.py -- --output depsgraph.png
blender --background --python depsgraph_export.py -- --output depsgraph.png --engine cycles
# Write the exported OBJ to a specific path:
blender --background --python depsgraph_export.py -- --obj exported.obj</code></pre>
<h2>Exit codes</h2>
<p>Per-script sequential checks. <code>9</code> is a valid check code; there is no rule against it. <code>10</code> and <code>11</code> are the shared framing and asset-quality helpers.</p>
<div class="table-wrap"><table><thead><tr><th scope="col">Code</th><th scope="col">Meaning</th></tr></thead><tbody><tr><td>0</td><td>Success</td></tr><tr><td>1</td><td>Uncaught exception (FATAL wrapper)</td></tr><tr><td>2</td><td>argparse / usage</td></tr><tr><td>3</td><td>Evaluated shell did not apply the modifier (evaluated count not above the cage)</td></tr><tr><td>4</td><td>No OBJ written</td></tr><tr><td>5</td><td>Export vert count ≠ evaluated (<code>--unevaluated</code> lands here)</td></tr><tr><td>6</td><td><code>--output</code> produced no file</td></tr><tr><td>7</td><td>Evaluated shell count ≠ Catmull-Clark closed form</td></tr><tr><td>10</td><td>Gallery framing violation</td></tr><tr><td>11</td><td>Asset-quality floor violation (render path only)</td></tr></tbody></table></div>
<p><code>--obj</code> is a path selector, not a falsifier.</p>
<p>The <code>blender-smoke</code> workflow runs the check on Blender 5.2 LTS and 4.5 LTS (5.1 on the weekly cron, the <code>needs-5.1</code> PR label, or manual dispatch). Smoke does not pass <code>--output</code>, <code>--obj</code>, or <code>--unevaluated</code>.</p>
<p>The <code>--output</code> render path additionally measures framing against the Layer 1 band via <code>examples/gallery_framing.py</code> (exit 10) and the asset-quality floors on the shipped controller via <code>examples/gallery_asset_quality.py</code> (exit 11) before writing the still.</p>
</section>
<section class="detail-section src">
<h2>Source</h2>
<div class="src-meta">
<code>examples/depsgraph-export/depsgraph_export.py</code>
<a href="https://github.com/TMHSDigital/Blender-Developer-Tools/tree/main/examples/depsgraph-export/depsgraph_export.py">View on GitHub →</a>
</div>
<pre><span class="s">"""Depsgraph-evaluated export — a runnable example.
Witnesses the depsgraph lifetime contract AND that modifiers actually ship in
exports. Builds a game controller whose shell is a sparse quad control cage
under a SUBSURF modifier (the buttons, sticks and bumpers are plain modeled
parts parented to it), measures every mesh through
evaluated_get().to_mesh() (each paired with to_mesh_clear()), exports the
scene through wm.obj_export, and asserts:
- the shell's evaluated vertex count equals the Catmull-Clark closed form
computed from its own cage topology (V, E, F, face corners) at the
modifier's level — so the evaluated mesh is exactly the subdivided shell,
not merely "bigger";
- the exported OBJ vertex count equals the summed EVALUATED counts of every
mesh object (modifier-applied), not the summed base counts.
``--unevaluated`` exports with ``apply_modifiers=False`` and still asserts
the OBJ vertex count equals the depsgraph-evaluated meshes. That is the
falsifier (``--same-axis`` in export-preset-axis). ``--obj`` is a path
selector, not a falsifier.
By default it runs only the correctness check (no render) — the CI smoke
check. Pass --output to also render a still:
blender --background --python depsgraph_export.py -- # check only
blender --background --python depsgraph_export.py -- --unevaluated # must fail
blender --background --python depsgraph_export.py -- --output d.png # + render
"""</span>
<span class="k">import</span> bpy, bmesh, sys, os, math, argparse, tempfile
<span class="k">from</span> mathutils <span class="k">import</span> Matrix, Vector
<span class="c"># Shared Layer 1 framing + asset-quality measurement (render path only) — see</span>
<span class="c"># gallery_framing.py / gallery_asset_quality.py</span>
sys.path.insert(<span class="n">0</span>, os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir))
sys.dont_write_bytecode = <span class="k">True</span> <span class="c"># keep examples/__pycache__ out of the repo tree</span>
<span class="k">import</span> gallery_framing
<span class="k">import</span> gallery_asset_quality
SUBSURF_LEVELS = <span class="n">2</span>
<span class="c"># ---------------------------------------------------------------------------</span>
<span class="c"># Controller shell cage. A top-view quad grid (X across, Y toward the</span>
<span class="c"># bumpers) with the notch between the grips cut out, extruded through three</span>
<span class="c"># Z layers (bottom, seam, top). Every face is a quad; the solid is closed and</span>
<span class="c"># manifold, which is what the closed form below relies on (it holds for any</span>
<span class="c"># polygon mesh, but a closed quad cage keeps the count easy to audit:</span>
<span class="c"># V = 2 * grid points + boundary points).</span>
<span class="c"># ---------------------------------------------------------------------------</span>
XS = (-<span class="n">3.2</span>, -<span class="n">2.3</span>, -<span class="n">1.2</span>, <span class="n">0.0</span>, <span class="n">1.2</span>, <span class="n">2.3</span>, <span class="n">3.2</span>)
YS = (-<span class="n">2.4</span>, -<span class="n">1.3</span>, -<span class="n">0.3</span>, <span class="n">0.6</span>, <span class="n">1.3</span>)
<span class="c"># kept cells per row (row 0 = grip tips, row 3 = bumper edge)</span>
ROWS = (
(<span class="n">0</span>, <span class="n">1</span>, <span class="n">4</span>, <span class="n">5</span>),
(<span class="n">0</span>, <span class="n">1</span>, <span class="n">4</span>, <span class="n">5</span>),
(<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>, <span class="n">4</span>, <span class="n">5</span>),
(<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>, <span class="n">4</span>, <span class="n">5</span>),
)
<span class="k">def</span> _shape(i, j):
<span class="s">"""Shaped top-view position of grid point (i, j): grips splay and taper,
the notch between them arches up, the bumper edge rounds off."""</span>
x, y = XS[i], YS[j]
ax, s = abs(x), (<span class="n">1.0</span> <span class="k">if</span> x >= <span class="n">0</span> <span class="k">else</span> -<span class="n">1.0</span>)
<span class="k">if</span> j == <span class="n">0</span>: <span class="c"># grip tips: narrower, splayed outward</span>
ax = {<span class="n">3.2</span>: <span class="n">2.85</span>, <span class="n">2.3</span>: <span class="n">2.05</span>, <span class="n">1.2</span>: <span class="n">1.3</span>}.get(ax, ax)
y -= <span class="n">0.10</span> * (ax / <span class="n">3.2</span>)
ax += <span class="n">0.25</span>
<span class="k">elif</span> j == <span class="n">1</span>:
ax = {<span class="n">3.2</span>: <span class="n">3.1</span>, <span class="n">1.2</span>: <span class="n">1.2</span>}.get(ax, ax)
<span class="k">elif</span> j == <span class="n">2</span> <span class="k">and</span> ax < <span class="n">1.0</span>: <span class="c"># arch of the notch between the grips</span>
y += <span class="n">0.25</span>
<span class="k">elif</span> j == <span class="n">4</span>: <span class="c"># bumper edge: shoulders drop back, center stays</span>
y -= <span class="n">0.18</span> * (ax / <span class="n">3.2</span>) ** <span class="n">2</span>
<span class="k">return</span> s * ax, y
<span class="k">def</span> _z(x, y, layer):
<span class="s">"""Z of a cage point: domed top, grips hang below the deck."""</span>
t = max(<span class="n">0.0</span>, min(<span class="n">1.0</span>, (-<span class="n">0.3</span> - y) / <span class="n">2.1</span>)) <span class="c"># 0 on the deck, 1 at grip tips</span>
u = min(<span class="n">1.0</span>, abs(x) / <span class="n">3.2</span>)
top = <span class="n">0.62</span> + <span class="n">0.10</span> * (<span class="n">1.0</span> - u * u) - <span class="n">0.22</span> * t
bottom = -<span class="n">0.55</span> * t - <span class="n">0.05</span> * (<span class="n">1.0</span> - u)
<span class="k">if</span> layer == <span class="n">0</span>:
<span class="k">return</span> bottom
<span class="k">if</span> layer == <span class="n">1</span>:
<span class="k">return</span> bottom + <span class="n">0.55</span> * (top - bottom)
<span class="k">return</span> top
<span class="k">def</span> build_shell_cage(me):
cells = {(i, j) <span class="k">for</span> j, cols <span class="k">in</span> enumerate(ROWS) <span class="k">for</span> i <span class="k">in</span> cols}
pts = sorted({(i + di, j + dj) <span class="k">for</span> (i, j) <span class="k">in</span> cells <span class="k">for</span> di <span class="k">in</span> (<span class="n">0</span>, <span class="n">1</span>) <span class="k">for</span> dj <span class="k">in</span> (<span class="n">0</span>, <span class="n">1</span>)})
<span class="c"># boundary edges of the kept-cell region, oriented CCW (region on the left)</span>
bedges = []
<span class="k">for</span> (i, j) <span class="k">in</span> cells:
<span class="k">for</span> (a, b, nb) <span class="k">in</span> (((i, j), (i + <span class="n">1</span>, j), (i, j - <span class="n">1</span>)),
((i + <span class="n">1</span>, j), (i + <span class="n">1</span>, j + <span class="n">1</span>), (i + <span class="n">1</span>, j)),
((i + <span class="n">1</span>, j + <span class="n">1</span>), (i, j + <span class="n">1</span>), (i, j + <span class="n">1</span>)),
((i, j + <span class="n">1</span>), (i, j), (i - <span class="n">1</span>, j))):
<span class="k">if</span> nb <span class="k">not</span> <span class="k">in</span> cells:
bedges.append((a, b))
bpts = sorted({p <span class="k">for</span> e <span class="k">in</span> bedges <span class="k">for</span> p <span class="k">in</span> e})
bm = bmesh.new()
<span class="k">try</span>:
layers = {}
<span class="k">for</span> layer <span class="k">in</span> (<span class="n">0</span>, <span class="n">2</span>):
<span class="k">for</span> p <span class="k">in</span> pts:
x, y = _shape(*p)
layers[(p, layer)] = bm.verts.new((x, y, _z(x, y, layer)))
<span class="k">for</span> p <span class="k">in</span> bpts:
x, y = _shape(*p)
layers[(p, <span class="n">1</span>)] = bm.verts.new((x, y, _z(x, y, <span class="n">1</span>)))
<span class="k">for</span> (i, j) <span class="k">in</span> cells:
quad = [(i, j), (i + <span class="n">1</span>, j), (i + <span class="n">1</span>, j + <span class="n">1</span>), (i, j + <span class="n">1</span>)]
bm.faces.new([layers[(p, <span class="n">2</span>)] <span class="k">for</span> p <span class="k">in</span> quad]) <span class="c"># top, up</span>
bm.faces.new([layers[(p, <span class="n">0</span>)] <span class="k">for</span> p <span class="k">in</span> reversed(quad)]) <span class="c"># bottom, down</span>
<span class="k">for</span> (a, b) <span class="k">in</span> bedges:
<span class="k">for</span> lo, hi <span class="k">in</span> ((<span class="n">0</span>, <span class="n">1</span>), (<span class="n">1</span>, <span class="n">2</span>)):
f = bm.faces.new([layers[(a, lo)], layers[(b, lo)],
layers[(b, hi)], layers[(a, hi)]])
f.material_index = <span class="n">1</span> <span class="k">if</span> lo == <span class="n">0</span> <span class="k">else</span> <span class="n">0</span>
<span class="k">for</span> f <span class="k">in</span> bm.faces:
<span class="k">if</span> f.normal.z < -<span class="n">0.5</span>:
f.material_index = <span class="n">1</span> <span class="c"># underside is the graphite half</span>
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
bm.to_mesh(me)
<span class="k">finally</span>:
bm.free()
<span class="k">def</span> catmull_clark_vcount(V, E, F, S, levels):
<span class="s">"""Vertex count after `levels` Catmull-Clark steps, from topology alone.
One step adds a vertex per edge and per face: V' = V + E + F. Each face
of n corners splits into n quads, so F' = S (face corners), E' = 2E + S,
and every later face is a quad: S' = 4F'.
"""</span>
<span class="k">for</span> _ <span class="k">in</span> range(levels):
V, E, F, S = V + E + F, <span class="n">2</span> * E + S, S, <span class="n">4</span> * S
<span class="k">return</span> V
<span class="c"># ---------------------------------------------------------------------------</span>
<span class="c"># Controls: ordinary modeled parts (no modifiers), so their evaluated count</span>
<span class="c"># equals their base count and the export must carry them unchanged.</span>
<span class="c"># ---------------------------------------------------------------------------</span>
<span class="k">def</span> _bevel_all(bm, offset, segments=<span class="n">2</span>):
<span class="s">"""Round the rims only: the facet seams around a cylinder wall are
already shallow, and beveling them collapses slivers to zero area."""</span>
rims = [e <span class="k">for</span> e <span class="k">in</span> bm.edges <span class="k">if</span> e.calc_face_angle(<span class="n">0.0</span>) > math.radians(<span class="n">50</span>)]
bmesh.ops.bevel(bm, geom=rims, offset=offset, segments=segments,
affect=<span class="s">'EDGES'</span>, profile=<span class="n">0.5</span>, clamp_overlap=<span class="k">True</span>)
<span class="k">def</span> part_disc(me, r, h, segs=<span class="n">24</span>, bevel=<span class="n">0.03</span>, dish=<span class="n">0.0</span>):
<span class="s">"""A beveled puck standing on z=0 (button / stick cap); optional dished top."""</span>
bm = bmesh.new()
<span class="k">try</span>:
bmesh.ops.create_cone(bm, cap_ends=<span class="k">True</span>, cap_tris=<span class="k">False</span>, segments=segs,
radius1=r, radius2=r, depth=h,
matrix=Matrix.Translation((<span class="n">0</span>, <span class="n">0</span>, h / <span class="n">2</span>)))
_bevel_all(bm, bevel)
<span class="k">if</span> dish:
<span class="k">for</span> v <span class="k">in</span> bm.verts:
<span class="k">if</span> v.co.z > h - <span class="n">1e-4</span>:
d = math.hypot(v.co.x, v.co.y) / r
v.co.z -= dish * max(<span class="n">0.0</span>, <span class="n">1.0</span> - d * d)
bm.to_mesh(me)
<span class="k">finally</span>:
bm.free()
<span class="k">def</span> part_stick(me):
<span class="s">"""Thumbstick: collar ring, neck, and a dished rubber cap."""</span>
bm = bmesh.new()
<span class="k">try</span>:
<span class="k">for</span> (r1, r2, z0, z1) <span class="k">in</span> ((<span class="n">0.50</span>, <span class="n">0.46</span>, <span class="n">0.0</span>, <span class="n">0.06</span>), <span class="c"># collar</span>
(<span class="n">0.17</span>, <span class="n">0.17</span>, <span class="n">0.06</span>, <span class="n">0.26</span>), <span class="c"># neck</span>
(<span class="n">0.40</span>, <span class="n">0.40</span>, <span class="n">0.26</span>, <span class="n">0.40</span>)): <span class="c"># cap</span>
bmesh.ops.create_cone(bm, cap_ends=<span class="k">True</span>, cap_tris=<span class="k">False</span>, segments=<span class="n">28</span>,
radius1=r1, radius2=r2, depth=z1 - z0,
matrix=Matrix.Translation((<span class="n">0</span>, <span class="n">0</span>, (z0 + z1) / <span class="n">2</span>)))
_bevel_all(bm, <span class="n">0.025</span>)
<span class="k">for</span> v <span class="k">in</span> bm.verts:
<span class="k">if</span> v.co.z > <span class="n">0.40</span> - <span class="n">1e-4</span>:
d = math.hypot(v.co.x, v.co.y) / <span class="n">0.40</span>
v.co.z -= <span class="n">0.05</span> * max(<span class="n">0.0</span>, <span class="n">1.0</span> - d * d)
bm.to_mesh(me)
<span class="k">finally</span>:
bm.free()
<span class="k">def</span> part_extrusion(me, outline, h, bevel):
<span class="s">"""Extrude a closed XY outline to height h, beveled (d-pad, pills, bumpers)."""</span>
bm = bmesh.new()
<span class="k">try</span>:
vs = [bm.verts.new((x, y, <span class="n">0.0</span>)) <span class="k">for</span> (x, y) <span class="k">in</span> outline]
face = bm.faces.new(vs)
ext = bmesh.ops.extrude_face_region(bm, geom=[face])
top = [e <span class="k">for</span> e <span class="k">in</span> ext[<span class="s">"geom"</span>] <span class="k">if</span> isinstance(e, bmesh.types.BMVert)]
bmesh.ops.translate(bm, verts=top, vec=(<span class="n">0</span>, <span class="n">0</span>, h))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
_bevel_all(bm, bevel)
bm.to_mesh(me)
<span class="k">finally</span>:
bm.free()
<span class="k">def</span> _stadium(length, width, segs=<span class="n">8</span>):
r = width / <span class="n">2</span>
half = length / <span class="n">2</span> - r
pts = []
<span class="k">for</span> k <span class="k">in</span> range(segs + <span class="n">1</span>):
a = -math.pi / <span class="n">2</span> + math.pi * k / segs
pts.append((half + r * math.cos(a), r * math.sin(a)))
<span class="k">for</span> k <span class="k">in</span> range(segs + <span class="n">1</span>):
a = math.pi / <span class="n">2</span> + math.pi * k / segs
pts.append((-half + r * math.cos(a), r * math.sin(a)))
<span class="k">return</span> pts
<span class="k">def</span> _cross(arm, w):
a, b = arm, w / <span class="n">2</span>
<span class="k">return</span> [(b, -a), (b, -b), (a, -b), (a, b), (b, b), (b, a),
(-b, a), (-b, b), (-a, b), (-a, -b), (-b, -b), (-b, -a)]
<span class="k">def</span> principled(name, color, metallic, roughness, emission=<span class="n">0.0</span>):
mat = bpy.data.materials.new(name)
mat.use_nodes = <span class="k">True</span>
bsdf = mat.node_tree.nodes[<span class="s">"Principled BSDF"</span>]
bsdf.inputs[<span class="s">"Base Color"</span>].default_value = color
bsdf.inputs[<span class="s">"Metallic"</span>].default_value = metallic
bsdf.inputs[<span class="s">"Roughness"</span>].default_value = roughness
<span class="k">if</span> emission:
key = <span class="s">"Emission Color"</span> <span class="k">if</span> <span class="s">"Emission Color"</span> <span class="k">in</span> bsdf.inputs <span class="k">else</span> <span class="s">"Emission"</span>
bsdf.inputs[key].default_value = color
bsdf.inputs[<span class="s">"Emission Strength"</span>].default_value = emission
<span class="k">return</span> mat
<span class="k">def</span> _smooth(me, angle=<span class="n">35.0</span>):
<span class="s">"""Smooth shading with sharp breaks above `angle` (4.1+ mesh API)."""</span>
me.shade_smooth()
<span class="k">if</span> angle <span class="k">is</span> <span class="k">not</span> <span class="k">None</span>:
me.set_sharp_from_angle(angle=math.radians(angle))
<span class="k">def</span> build():
bpy.ops.wm.read_factory_settings(use_empty=<span class="k">True</span>)
coll = bpy.context.collection
me = bpy.data.meshes.new(<span class="s">"Gamepad.Shell"</span>)
build_shell_cage(me)
me.materials.append(principled(<span class="s">"Gamepad.Cobalt"</span>, (<span class="n">0.014</span>, <span class="n">0.105</span>, <span class="n">0.54</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.34</span>))
me.materials.append(principled(<span class="s">"Gamepad.Graphite"</span>, (<span class="n">0.030</span>, <span class="n">0.032</span>, <span class="n">0.040</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.55</span>))
_smooth(me, <span class="k">None</span>)
shell = bpy.data.objects.new(<span class="s">"Gamepad.Shell"</span>, me)
coll.objects.link(shell)
ss = shell.modifiers.new(<span class="s">"Subdivide"</span>, <span class="s">'SUBSURF'</span>)
ss.levels = SUBSURF_LEVELS
ss.render_levels = SUBSURF_LEVELS
<span class="c"># Controls sit on the shell's EVALUATED (subdivided) deck: ray-cast the</span>
<span class="c"># limit surface, not the cage, or every button floats above the plastic.</span>
dg = bpy.context.evaluated_depsgraph_get()
<span class="k">def</span> seat(ob, x, y, sink=<span class="n">0.02</span>):
hit, loc, nrm, _ = shell.ray_cast(Vector((x, y, <span class="n">5.0</span>)), Vector((<span class="n">0</span>, <span class="n">0</span>, -<span class="n">1</span>)),
depsgraph=dg)
<span class="k">if</span> <span class="k">not</span> hit:
<span class="k">raise</span> RuntimeError(<span class="s">f"</span>{ob.name}<span class="s">: no shell under (</span>{x}<span class="s">, </span>{y}<span class="s">)</span><span class="s">"</span>)
rot = nrm.to_track_quat(<span class="s">'Z'</span>, <span class="s">'Y'</span>).to_matrix().to_4x4()
ob.matrix_world = Matrix.Translation(loc - nrm * sink) @ rot
ob.parent = shell <span class="c"># shell sits at the identity, so no parent inverse</span>
rubber = principled(<span class="s">"Gamepad.Rubber"</span>, (<span class="n">0.018</span>, <span class="n">0.019</span>, <span class="n">0.022</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.78</span>)
satin = principled(<span class="s">"Gamepad.Satin"</span>, (<span class="n">0.07</span>, <span class="n">0.075</span>, <span class="n">0.085</span>, <span class="n">1.0</span>), <span class="n">0.2</span>, <span class="n">0.42</span>)
face_cols = {<span class="s">"A"</span>: (<span class="n">0.02</span>, <span class="n">0.55</span>, <span class="n">0.12</span>, <span class="n">1.0</span>), <span class="s">"B"</span>: (<span class="n">0.75</span>, <span class="n">0.03</span>, <span class="n">0.02</span>, <span class="n">1.0</span>),
<span class="s">"X"</span>: (<span class="n">0.03</span>, <span class="n">0.22</span>, <span class="n">0.85</span>, <span class="n">1.0</span>), <span class="s">"Y"</span>: (<span class="n">0.95</span>, <span class="n">0.62</span>, <span class="n">0.02</span>, <span class="n">1.0</span>)}
<span class="k">def</span> part(name, builder, mat, x, y, *args, **kw):
pme = bpy.data.meshes.new(name)
builder(pme, *args, **kw)
pme.materials.append(mat)
_smooth(pme)
ob = bpy.data.objects.new(name, pme)
coll.objects.link(ob)
seat(ob, x, y)
<span class="k">return</span> ob
part(<span class="s">"Gamepad.StickL"</span>, <span class="k">lambda</span> m: part_stick(m), rubber, -<span class="n">1.55</span>, -<span class="n">0.78</span>)
part(<span class="s">"Gamepad.StickR"</span>, <span class="k">lambda</span> m: part_stick(m), rubber, <span class="n">1.55</span>, -<span class="n">0.78</span>)
part(<span class="s">"Gamepad.DPad"</span>, part_extrusion, satin, -<span class="n">2.15</span>, <span class="n">0.25</span>,
_cross(<span class="n">0.46</span>, <span class="n">0.30</span>), <span class="n">0.12</span>, <span class="n">0.035</span>)
<span class="k">for</span> key, (dx, dy) <span class="k">in</span> {<span class="s">"A"</span>: (<span class="n">0</span>, -<span class="n">0.34</span>), <span class="s">"B"</span>: (<span class="n">0.34</span>, <span class="n">0</span>), <span class="s">"X"</span>: (-<span class="n">0.34</span>, <span class="n">0</span>),
<span class="s">"Y"</span>: (<span class="n">0</span>, <span class="n">0.34</span>)}.items():
mat = principled(<span class="s">f"</span><span class="s">Gamepad.Button</span>{key}<span class="s">"</span>, face_cols[key], <span class="n">0.0</span>, <span class="n">0.30</span>, emission=<span class="n">0.12</span>)
part(<span class="s">f"</span><span class="s">Gamepad.Button</span>{key}<span class="s">"</span>, part_disc, mat, <span class="n">2.15</span> + dx, <span class="n">0.25</span> + dy,
<span class="n">0.15</span>, <span class="n">0.12</span>, <span class="n">20</span>, <span class="n">0.035</span>)
part(<span class="s">"Gamepad.Select"</span>, part_extrusion, satin, -<span class="n">0.62</span>, <span class="n">0.62</span>, _stadium(<span class="n">0.36</span>, <span class="n">0.13</span>), <span class="n">0.06</span>, <span class="n">0.02</span>)
part(<span class="s">"Gamepad.Start"</span>, part_extrusion, satin, <span class="n">0.62</span>, <span class="n">0.62</span>, _stadium(<span class="n">0.36</span>, <span class="n">0.13</span>), <span class="n">0.06</span>, <span class="n">0.02</span>)
home = principled(<span class="s">"Gamepad.Home"</span>, (<span class="n">1.0</span>, <span class="n">0.50</span>, <span class="n">0.10</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.3</span>, emission=<span class="n">0.8</span>)
part(<span class="s">"Gamepad.Home"</span>, part_disc, home, <span class="n">0.0</span>, <span class="n">0.0</span>, <span class="n">0.16</span>, <span class="n">0.06</span>, <span class="n">28</span>, <span class="n">0.02</span>)
<span class="k">for</span> side <span class="k">in</span> (-<span class="n">1</span>, <span class="n">1</span>):
b = part(<span class="s">f"</span><span class="s">Gamepad.Bumper</span>{<span class="s">'L'</span> <span class="k">if</span> side < <span class="n">0</span> <span class="k">else</span> <span class="s">'R'</span>}<span class="s">"</span>, part_extrusion, satin,
side * <span class="n">2.2</span>, <span class="n">1.16</span>, _stadium(<span class="n">1.5</span>, <span class="n">0.34</span>), <span class="n">0.15</span>, <span class="n">0.05</span>)
b.rotation_euler.z += math.radians(-side * <span class="n">8.0</span>)
<span class="k">return</span> shell
<span class="k">def</span> mesh_objects():
<span class="k">return</span> sorted((o <span class="k">for</span> o <span class="k">in</span> bpy.context.scene.objects <span class="k">if</span> o.type == <span class="s">'MESH'</span>),
key=<span class="k">lambda</span> o: o.name)
<span class="k">def</span> check(shell, obj_path, unevaluated=<span class="k">False</span>):
base_total = <span class="n">0</span>
eval_total = <span class="n">0</span>
shell_eval = <span class="k">None</span>
<span class="c"># depsgraph lifetime contract: evaluate, read, then release with</span>
<span class="c"># to_mesh_clear — once per object, never holding two temporaries</span>
dg = bpy.context.evaluated_depsgraph_get()
<span class="k">for</span> ob <span class="k">in</span> mesh_objects():
ev = ob.evaluated_get(dg)
em = ev.to_mesh()
n = len(em.vertices)
ev.to_mesh_clear() <span class="c"># must be paired; releases the temporary mesh</span>
base_total += len(ob.data.vertices)
eval_total += n
<span class="k">if</span> ob == shell:
shell_eval = n
me = shell.data
V, E, F, S = len(me.vertices), len(me.edges), len(me.polygons), len(me.loops)
expected = catmull_clark_vcount(V, E, F, S, SUBSURF_LEVELS)
out = obj_path <span class="k">or</span> os.path.join(tempfile.gettempdir(), <span class="s">"depsgraph_export.obj"</span>)
os.makedirs(os.path.dirname(os.path.abspath(out)) <span class="k">or</span> <span class="s">"."</span>, exist_ok=<span class="k">True</span>)
<span class="c"># obj_export writes the evaluated (modifier-applied) geometry by default</span>
bpy.ops.wm.obj_export(
filepath=out,
export_selected_objects=<span class="k">False</span>,
apply_modifiers=<span class="k">not</span> unevaluated,
)
<span class="k">if</span> <span class="k">not</span> (os.path.exists(out) <span class="k">and</span> os.path.getsize(out) > <span class="n">0</span>):
print(<span class="s">"ERROR: no OBJ written"</span>, file=sys.stderr)
<span class="k">return</span> <span class="n">4</span>
exported = <span class="n">0</span>
<span class="k">with</span> open(out, encoding=<span class="s">"utf-8"</span>) <span class="k">as</span> f:
<span class="k">for</span> line <span class="k">in</span> f:
<span class="k">if</span> line.startswith(<span class="s">"v "</span>):
exported += <span class="n">1</span>
print(<span class="s">f"</span><span class="s">shell_cage V=</span>{V}<span class="s"> E=</span>{E}<span class="s"> F=</span>{F}<span class="s"> S=</span>{S}<span class="s"> levels=</span>{SUBSURF_LEVELS}<span class="s"> </span><span class="s">"</span>
<span class="s">f"</span><span class="s">shell_eval_vcount=</span>{shell_eval}<span class="s"> closed_form=</span>{expected}<span class="s">"</span>)
print(<span class="s">f"</span><span class="s">base_vcount=</span>{base_total}<span class="s"> eval_vcount=</span>{eval_total}<span class="s"> exported_vcount=</span>{exported}<span class="s">"</span>)
<span class="k">if</span> <span class="k">not</span> (shell_eval > V):
print(<span class="s">"ERROR: evaluated mesh did not apply the modifier"</span>, file=sys.stderr)
<span class="k">return</span> <span class="n">3</span>
<span class="k">if</span> shell_eval != expected:
print(<span class="s">f"</span><span class="s">ERROR: evaluated shell (</span>{shell_eval}<span class="s">) != Catmull-Clark closed form </span><span class="s">"</span>
<span class="s">f"</span><span class="s">(</span>{expected}<span class="s">)</span><span class="s">"</span>, file=sys.stderr)
<span class="k">return</span> <span class="n">7</span>
<span class="k">if</span> exported != eval_total:
print(<span class="s">f"</span><span class="s">ERROR: export (</span>{exported}<span class="s">) != evaluated (</span>{eval_total}<span class="s">); modifier did not ship</span><span class="s">"</span>,
file=sys.stderr)
<span class="k">return</span> <span class="n">5</span>
<span class="k">return</span> <span class="n">0</span>
<span class="k">def</span> eevee_engine_id():
<span class="k">return</span> <span class="s">'BLENDER_EEVEE'</span> <span class="k">if</span> bpy.app.version >= (<span class="n">5</span>, <span class="n">0</span>, <span class="n">0</span>) <span class="k">else</span> <span class="s">'BLENDER_EEVEE_NEXT'</span>
<span class="k">def</span> ghost(name, color, alpha):
<span class="s">"""Tinted see-through shell for the cage: transparent mixed with a glossy
tint, so the sparse facets read as a volume and the wires stay dominant."""</span>
mat = bpy.data.materials.new(name)
mat.use_nodes = <span class="k">True</span>
nt = mat.node_tree
bsdf = nt.nodes[<span class="s">"Principled BSDF"</span>]
bsdf.inputs[<span class="s">"Base Color"</span>].default_value = color
bsdf.inputs[<span class="s">"Roughness"</span>].default_value = <span class="n">0.3</span>
out = nt.nodes[<span class="s">"Material Output"</span>]
mix = nt.nodes.new(<span class="s">"ShaderNodeMixShader"</span>)
mix.inputs[<span class="s">"Fac"</span>].default_value = alpha
tr = nt.nodes.new(<span class="s">"ShaderNodeBsdfTransparent"</span>)
nt.links.new(tr.outputs[<span class="n">0</span>], mix.inputs[<span class="n">1</span>])
nt.links.new(bsdf.outputs[<span class="n">0</span>], mix.inputs[<span class="n">2</span>])
nt.links.new(mix.outputs[<span class="n">0</span>], out.inputs[<span class="s">"Surface"</span>])
<span class="k">if</span> hasattr(mat, <span class="s">"surface_render_method"</span>):
mat.surface_render_method = <span class="s">'BLENDED'</span>
<span class="k">return</span> mat
<span class="k">def</span> render_still(shell, path, engine):
<span class="s">"""The cage the .blend holds beside the subdivided controller the OBJ ships."""</span>
scene = bpy.context.scene
coll = scene.collection
<span class="c"># right: the checked scene itself — shell + controls, the export's content.</span>
<span class="c"># Tilted toward the camera on its grip tips, like a controller on a shelf.</span>
shell.rotation_euler = (math.radians(<span class="n">30</span>), <span class="n">0.0</span>, math.radians(-<span class="n">10</span>))
shell.location = (<span class="n">3.45</span>, -<span class="n">0.3</span>, <span class="n">0.0</span>)
bpy.context.view_layer.update()
dg = bpy.context.evaluated_depsgraph_get()
lows = []
<span class="k">for</span> ob <span class="k">in</span> mesh_objects():
ev = ob.evaluated_get(dg)
em = ev.to_mesh()
mw = ob.matrix_world
lows.append(min((mw @ v.co).z <span class="k">for</span> v <span class="k">in</span> em.vertices))
ev.to_mesh_clear()
shell.location.z = -min(lows)
bpy.context.view_layer.update()
product = mesh_objects()
<span class="c"># left: the shell's base datablock with no modifier — the sparse control</span>
<span class="c"># cage the file stores. Warm wire on every cage edge, a bead on every</span>
<span class="c"># cage vertex (the V the closed form starts from), faint cobalt facets.</span>
cage_mat = principled(<span class="s">"Cage.Wire"</span>, (<span class="n">1.0</span>, <span class="n">0.42</span>, <span class="n">0.06</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.35</span>, emission=<span class="n">0.6</span>)
xf = Matrix.Translation((-<span class="n">3.45</span>, <span class="n">0.3</span>, <span class="n">0.0</span>)) @ \
Matrix.Rotation(math.radians(<span class="n">10</span>), <span class="n">4</span>, <span class="s">'Z'</span>) @ Matrix.Rotation(math.radians(<span class="n">30</span>), <span class="n">4</span>, <span class="s">'X'</span>)
cage_me = shell.data.copy()
cage_me.name = <span class="s">"Cage.Shell"</span>
cage_me.materials.clear()
cage_me.materials.append(ghost(<span class="s">"Cage.Ghost"</span>, (<span class="n">0.02</span>, <span class="n">0.12</span>, <span class="n">0.55</span>, <span class="n">1.0</span>), <span class="n">0.30</span>))
<span class="k">for</span> p <span class="k">in</span> cage_me.polygons:
p.material_index = <span class="n">0</span>
cage_me.shade_flat()
cage_shell = bpy.data.objects.new(<span class="s">"Cage.Shell"</span>, cage_me)
wire = bpy.data.objects.new(<span class="s">"Cage.Wire"</span>, shell.data.copy())
wire.data.materials.clear()
wire.data.materials.append(cage_mat)
w = wire.modifiers.new(<span class="s">"wire"</span>, <span class="s">'WIREFRAME'</span>)
w.thickness = <span class="n">0.045</span>
w.offset = <span class="n">0.0</span>
w.use_even_offset = <span class="k">True</span>
beads_me = bpy.data.meshes.new(<span class="s">"Cage.Beads"</span>)
bm = bmesh.new()
<span class="k">try</span>:
<span class="k">for</span> v <span class="k">in</span> shell.data.vertices:
bmesh.ops.create_icosphere(bm, subdivisions=<span class="n">2</span>, radius=<span class="n">0.075</span>,
matrix=Matrix.Translation(v.co))
bm.to_mesh(beads_me)
<span class="k">finally</span>:
bm.free()
beads_me.materials.append(cage_mat)
beads_me.shade_smooth()
beads = bpy.data.objects.new(<span class="s">"Cage.Beads"</span>, beads_me)
cage = [cage_shell, wire, beads]
<span class="k">for</span> ob <span class="k">in</span> cage:
ob.matrix_world = xf
coll.objects.link(ob)
bpy.context.view_layer.update()
low = min((xf @ v.co).z <span class="k">for</span> v <span class="k">in</span> shell.data.vertices) - <span class="n">0.075</span>
<span class="k">for</span> ob <span class="k">in</span> cage:
ob.location.z -= low
bpy.context.view_layer.update()
<span class="c"># Display stands: both pieces are tilted toward the camera, so each back</span>
<span class="c"># edge rests on a low satin block instead of hanging in the air. Sized</span>
<span class="c"># from the real underside — the evaluated shell for the product, the</span>
<span class="c"># cage points for the cage. Render-only; the export already ran.</span>
stand_mat = principled(<span class="s">"Stand.Satin"</span>, (<span class="n">0.055</span>, <span class="n">0.057</span>, <span class="n">0.066</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.45</span>)
<span class="k">def</span> stand(name, mw, coords, yaw):
back = [mw @ c <span class="k">for</span> c <span class="k">in</span> coords <span class="k">if</span> c.y > <span class="n">0.55</span> <span class="k">and</span> c.z < <span class="n">0.15</span>]
top = min(p.z <span class="k">for</span> p <span class="k">in</span> back)
cx = sum(p.x <span class="k">for</span> p <span class="k">in</span> back) / len(back)
cy = sum(p.y <span class="k">for</span> p <span class="k">in</span> back) / len(back)
sme = bpy.data.meshes.new(name)
part_extrusion(sme, [(-<span class="n">2.3</span>, -<span class="n">0.42</span>), (<span class="n">2.3</span>, -<span class="n">0.42</span>), (<span class="n">2.3</span>, <span class="n">0.42</span>), (-<span class="n">2.3</span>, <span class="n">0.42</span>)],
top, <span class="n">0.05</span>)
sme.materials.append(stand_mat)
_smooth(sme)
ob = bpy.data.objects.new(name, sme)
ob.location = (cx, cy, <span class="n">0.0</span>)
ob.rotation_euler = (<span class="n">0.0</span>, <span class="n">0.0</span>, yaw)
coll.objects.link(ob)
<span class="k">return</span> ob
ev = shell.evaluated_get(dg)
em = ev.to_mesh()
shell_pts = [v.co.copy() <span class="k">for</span> v <span class="k">in</span> em.vertices]
ev.to_mesh_clear()
stands = [
stand(<span class="s">"Stand.Product"</span>, shell.matrix_world, shell_pts, math.radians(-<span class="n">10</span>)),
stand(<span class="s">"Stand.Cage"</span>, cage_shell.matrix_world,
[v.co <span class="k">for</span> v <span class="k">in</span> shell.data.vertices], math.radians(<span class="n">10</span>)),
]
floor_me = bpy.data.meshes.new(<span class="s">"Floor"</span>)
bm = bmesh.new()
<span class="k">try</span>:
bmesh.ops.create_grid(bm, x_segments=<span class="n">1</span>, y_segments=<span class="n">1</span>, size=<span class="n">60.0</span>)
bm.to_mesh(floor_me)
<span class="k">finally</span>:
bm.free()
floor_me.materials.append(principled(<span class="s">"Studio"</span>, (<span class="n">0.03</span>, <span class="n">0.032</span>, <span class="n">0.037</span>, <span class="n">1.0</span>), <span class="n">0.0</span>, <span class="n">0.7</span>))
floor = bpy.data.objects.new(<span class="s">"Floor"</span>, floor_me)
coll.objects.link(floor)
wall = bpy.data.objects.new(<span class="s">"Wall"</span>, floor_me.copy())
wall.location = (<span class="n">0.0</span>, <span class="n">8.0</span>, <span class="n">0.0</span>)
wall.rotation_euler = (math.pi / <span class="n">2</span>, <span class="n">0.0</span>, <span class="n">0.0</span>)
coll.objects.link(wall)
world = bpy.data.worlds.new(<span class="s">"World"</span>)
world.use_nodes = <span class="k">True</span>
world.node_tree.nodes[<span class="s">"Background"</span>].inputs[<span class="s">"Color"</span>].default_value = \
(<span class="n">0.02</span>, <span class="n">0.021</span>, <span class="n">0.025</span>, <span class="n">1.0</span>)
scene.world = world
<span class="k">def</span> light(name, loc, energy, size, col, rot):
ld = bpy.data.lights.new(name, <span class="s">'AREA'</span>)
ld.energy = energy; ld.size = size; ld.color = col
ob = bpy.data.objects.new(name, ld)
ob.location = loc
ob.rotation_euler = tuple(math.radians(a) <span class="k">for</span> a <span class="k">in</span> rot)
coll.objects.link(ob)
<span class="c"># warm shaped key, faint cool fill, cool rim, warm wedge on the back wall</span>
<span class="c"># (docs/VISUAL-STYLE.md)</span>
light(<span class="s">"Key"</span>, (-<span class="n">4.0</span>, -<span class="n">5.0</span>, <span class="n">6.5</span>), <span class="n">580.0</span>, <span class="n">5.0</span>, (<span class="n">1.0</span>, <span class="n">0.96</span>, <span class="n">0.9</span>), (<span class="n">42</span>, <span class="n">0</span>, -<span class="n">38</span>))
light(<span class="s">"Fill"</span>, (<span class="n">7.0</span>, -<span class="n">6.0</span>, <span class="n">4.5</span>), <span class="n">110.0</span>, <span class="n">9.0</span>, (<span class="n">0.75</span>, <span class="n">0.85</span>, <span class="n">1.0</span>), (<span class="n">40</span>, <span class="n">0</span>, <span class="n">50</span>))
light(<span class="s">"Rim"</span>, (<span class="n">1.5</span>, <span class="n">5.0</span>, <span class="n">4.5</span>), <span class="n">260.0</span>, <span class="n">4.0</span>, (<span class="n">0.6</span>, <span class="n">0.78</span>, <span class="n">1.0</span>), (-<span class="n">55</span>, <span class="n">0</span>, <span class="n">180</span>))
light(<span class="s">"Wedge"</span>, (<span class="n">0.5</span>, <span class="n">6.0</span>, <span class="n">3.0</span>), <span class="n">420.0</span>, <span class="n">6.0</span>, (<span class="n">1.0</span>, <span class="n">0.76</span>, <span class="n">0.5</span>), (-<span class="n">72</span>, <span class="n">0</span>, <span class="n">180</span>))
cam_data = bpy.data.cameras.new(<span class="s">"Cam"</span>)
cam_data.lens = <span class="n">50.0</span>
cam = bpy.data.objects.new(<span class="s">"Cam"</span>, cam_data)
cam.location = (<span class="n">0.0</span>, -<span class="n">19.0</span>, <span class="n">13.2</span>)
coll.objects.link(cam)
aim = bpy.data.objects.new(<span class="s">"Aim"</span>, <span class="k">None</span>)
aim.location = (<span class="n">0.0</span>, <span class="n">0.3</span>, <span class="n">0.55</span>)
coll.objects.link(aim)
con = cam.constraints.new(<span class="s">'TRACK_TO'</span>)
con.target = aim
con.track_axis = <span class="s">'TRACK_NEGATIVE_Z'</span>
con.up_axis = <span class="s">'UP_Y'</span>
scene.camera = cam
scene.render.engine = <span class="s">'CYCLES'</span> <span class="k">if</span> engine == <span class="s">'cycles'</span> <span class="k">else</span> eevee_engine_id()
<span class="k">if</span> engine == <span class="s">'cycles'</span>:
scene.cycles.samples = <span class="n">48</span>
<span class="k">else</span>:
<span class="k">try</span>:
scene.eevee.taa_render_samples = <span class="n">64</span>
<span class="k">except</span> AttributeError:
<span class="k">pass</span>
scene.render.resolution_x = <span class="n">1280</span>
scene.render.resolution_y = <span class="n">720</span>
scene.render.image_settings.file_format = <span class="s">'PNG'</span>
scene.render.filepath = path
<span class="c"># AgX would wash the cobalt shell and the orange cage toward pastel</span>
<span class="c"># (docs/VISUAL-STYLE.md)</span>
scene.view_settings.view_transform = <span class="s">'Standard'</span>
<span class="c"># Layer 1 framing gate (silhouette matte) — exit 10 on violation, before</span>
<span class="c"># the beauty render so a defective composition ships no artifact.</span>
fcode = gallery_framing.check_framing(
scene, cam,
hero=product + cage,
elements=product + cage + stands,
stage=[floor, wall],
)
<span class="k">if</span> fcode:
<span class="k">return</span> fcode
<span class="c"># Asset-quality floors on the shipped controller (exit 11).</span>
qcode = gallery_asset_quality.check_asset_quality(scene, cam, hero=product,
stage=[floor, wall])
<span class="k">if</span> qcode:
<span class="k">return</span> qcode
bpy.ops.render.render(write_still=<span class="k">True</span>)
<span class="k">if</span> <span class="k">not</span> (os.path.exists(path) <span class="k">and</span> os.path.getsize(path) > <span class="n">0</span>):
print(<span class="s">"ERROR: render produced no file"</span>, file=sys.stderr)
<span class="k">return</span> <span class="n">6</span>
<span class="k">return</span> <span class="n">0</span>
<span class="k">def</span> main():
argv = sys.argv[sys.argv.index(<span class="s">"--"</span>) + <span class="n">1</span>:] <span class="k">if</span> <span class="s">"--"</span> <span class="k">in</span> sys.argv <span class="k">else</span> []
p = argparse.ArgumentParser()
p.add_argument(<span class="s">"--output"</span>, default=<span class="k">None</span>, help=<span class="s">"optional: render a still PNG here"</span>)
p.add_argument(<span class="s">"--engine"</span>, default=<span class="s">"eevee"</span>, choices=(<span class="s">"eevee"</span>, <span class="s">"cycles"</span>),
help=<span class="s">"render engine for --output (cycles for GPU-less hosts)"</span>)
p.add_argument(<span class="s">"--obj"</span>, default=<span class="k">None</span>,
help=<span class="s">"optional: write the exported OBJ here (else a temp path)"</span>)
p.add_argument(<span class="s">"--unevaluated"</span>, action=<span class="s">"store_true"</span>,
help=<span class="s">"export with apply_modifiers=False (must fail)"</span>)
args = p.parse_args(argv)
shell = build()
code = check(shell, args.obj, unevaluated=args.unevaluated)
<span class="k">if</span> code:
<span class="k">return</span> code
<span class="k">if</span> args.output:
rcode = render_still(shell, os.path.abspath(args.output), args.engine)
<span class="k">if</span> rcode:
<span class="k">return</span> rcode
print(<span class="s">f"</span><span class="s">rendered still </span>{args.output}<span class="s">"</span>)
print(<span class="s">"depsgraph-export OK"</span>)
<span class="k">return</span> <span class="n">0</span>
<span class="k">if</span> __name__ == <span class="s">"__main__"</span>:
<span class="k">try</span>:
sys.exit(main())
<span class="k">except</span> Exception <span class="k">as</span> e:
<span class="k">import</span> traceback; traceback.print_exc(); print(<span class="s">f"</span><span class="s">FATAL: </span>{e}<span class="s">"</span>, file=sys.stderr); sys.exit(<span class="n">1</span>)
</pre>
</section>
</main>
<dialog class="lightbox" id="lightbox" aria-label="Full-size render">
<button class="lightbox-close" type="button" autofocus>Close</button>
<img src="../assets/depsgraph-export-hero.webp" alt="A game controller's sparse control cage in orange wire and vertex beads beside the smooth subdivided cobalt controller with sticks and colored buttons, on a dark studio floor." />
</dialog>
<footer>
<div class="statusbar">
<span>generated from <code>examples/gallery.json</code></span>
<span>CC-BY-NC-ND-4.0</span>
<span style="color: var(--ok);">exit 0</span>
</div>
</footer>
<script>
(function () {
var hero = document.getElementById('heroZoom');
var box = document.getElementById('lightbox');
if (hero && box) {
// <dialog>.showModal() traps focus, closes on Escape, and returns
// focus to the hero button on close. Any click inside closes it.
hero.addEventListener('click', function () { box.showModal(); });
box.addEventListener('click', function () { box.close(); });
}
var copy = document.getElementById('copyRun');
if (copy) {
copy.addEventListener('click', function () {
var cmd = document.getElementById('runCmd').textContent;
navigator.clipboard.writeText(cmd).then(function () {
copy.textContent = 'Copied!';
setTimeout(function () { copy.textContent = 'Copy'; }, 1500);
});
});
}
})();
</script>
</body>
</html>