Blender V4.5
io_alembic.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#ifdef WITH_ALEMBIC
10
11/* needed for directory lookup */
12# ifndef WIN32
13# include <dirent.h>
14# else
15# include "BLI_winstuff.h"
16# endif
17
18# include <cerrno>
19# include <cstring>
20
21# include "DNA_modifier_types.h"
22# include "DNA_object_types.h"
23# include "DNA_scene_types.h"
24# include "DNA_space_types.h"
25
26# include "BKE_context.hh"
27# include "BKE_file_handler.hh"
28# include "BKE_main.hh"
29# include "BKE_report.hh"
30
31# include "BLI_path_utils.hh"
32# include "BLI_string.h"
33# include "BLI_utildefines.h"
34# include "BLI_vector.hh"
35
36# include "BLT_translation.hh"
37
38# include "RNA_access.hh"
39# include "RNA_define.hh"
40# include "RNA_enum_types.hh"
41
42# include "ED_fileselect.hh"
43# include "ED_object.hh"
44
45# include "UI_interface.hh"
46# include "UI_resources.hh"
47
48# include "WM_api.hh"
49# include "WM_types.hh"
50
51# include "DEG_depsgraph.hh"
52
53# include "io_alembic.hh"
54# include "io_utils.hh"
55
56# include "ABC_alembic.h"
57
58const EnumPropertyItem rna_enum_abc_export_evaluation_mode_items[] = {
60 "RENDER",
61 0,
62 "Render",
63 "Use Render settings for object visibility, modifier settings, etc"},
65 "VIEWPORT",
66 0,
67 "Viewport",
68 "Use Viewport settings for object visibility, modifier settings, etc"},
69 {0, nullptr, 0, nullptr, nullptr},
70};
71
72static wmOperatorStatus wm_alembic_export_invoke(bContext *C,
73 wmOperator *op,
74 const wmEvent * /*event*/)
75{
76 if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) {
77 RNA_boolean_set(op->ptr, "as_background_job", true);
78 }
79
80 RNA_boolean_set(op->ptr, "init_scene_frame_range", true);
81
83
85
87}
88
89static wmOperatorStatus wm_alembic_export_exec(bContext *C, wmOperator *op)
90{
91 if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
92 BKE_report(op->reports, RPT_ERROR, "No filepath given");
93 return OPERATOR_CANCELLED;
94 }
95
96 char filepath[FILE_MAX];
97 RNA_string_get(op->ptr, "filepath", filepath);
98
100 params.frame_start = RNA_int_get(op->ptr, "start");
101 params.frame_end = RNA_int_get(op->ptr, "end");
102
103 params.frame_samples_xform = RNA_int_get(op->ptr, "xsamples");
104 params.frame_samples_shape = RNA_int_get(op->ptr, "gsamples");
105
106 params.shutter_open = RNA_float_get(op->ptr, "sh_open");
107 params.shutter_close = RNA_float_get(op->ptr, "sh_close");
108
109 params.selected_only = RNA_boolean_get(op->ptr, "selected");
110 params.uvs = RNA_boolean_get(op->ptr, "uvs");
111 params.normals = RNA_boolean_get(op->ptr, "normals");
112 params.vcolors = RNA_boolean_get(op->ptr, "vcolors");
113 params.orcos = RNA_boolean_get(op->ptr, "orcos");
114 params.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv");
115 params.curves_as_mesh = RNA_boolean_get(op->ptr, "curves_as_mesh");
116 params.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten");
117 params.visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only");
118 params.face_sets = RNA_boolean_get(op->ptr, "face_sets");
119 params.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema");
120 params.export_hair = RNA_boolean_get(op->ptr, "export_hair");
121 params.export_particles = RNA_boolean_get(op->ptr, "export_particles");
122 params.export_custom_properties = RNA_boolean_get(op->ptr, "export_custom_properties");
123 params.use_instancing = RNA_boolean_get(op->ptr, "use_instancing");
124 params.packuv = RNA_boolean_get(op->ptr, "packuv");
125 params.triangulate = RNA_boolean_get(op->ptr, "triangulate");
126 params.quad_method = RNA_enum_get(op->ptr, "quad_method");
127 params.ngon_method = RNA_enum_get(op->ptr, "ngon_method");
128 params.evaluation_mode = eEvaluationMode(RNA_enum_get(op->ptr, "evaluation_mode"));
129
130 params.global_scale = RNA_float_get(op->ptr, "global_scale");
131
132 RNA_string_get(op->ptr, "collection", params.collection);
133
134 /* Take some defaults from the scene, if not specified explicitly. */
135 Scene *scene = CTX_data_scene(C);
136 if (params.frame_start == INT_MIN) {
137 params.frame_start = scene->r.sfra;
138 }
139 if (params.frame_end == INT_MIN) {
140 params.frame_end = scene->r.efra;
141 }
142
143 const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
144 bool ok = ABC_export(scene, C, filepath, &params, as_background_job);
145
146 return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
147}
148
149static void ui_alembic_export_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
150{
151 uiLayoutSetPropSep(layout, true);
152 uiLayoutSetPropDecorate(layout, false);
153
154 if (uiLayout *panel = layout->panel(C, "ABC_export_general", false, IFACE_("General"))) {
155 uiLayout *col = &panel->column(false);
156 col->prop(ptr, "global_scale", UI_ITEM_NONE, std::nullopt, ICON_NONE);
157
158 col = &panel->column(false);
159 if (CTX_wm_space_file(C)) {
160 uiLayout *sub = &col->column(true, IFACE_("Include"));
161 sub->prop(ptr, "selected", UI_ITEM_NONE, IFACE_("Selection Only"), ICON_NONE);
162 sub->prop(ptr, "visible_objects_only", UI_ITEM_NONE, IFACE_("Visible Only"), ICON_NONE);
163 }
164 }
165
166 /* Scene Options */
167 if (uiLayout *panel = layout->panel(C, "ABC_export_scene", false, IFACE_("Scene"))) {
168 uiLayout *col = &panel->column(false);
169
170 uiLayout *sub = &col->column(true);
171 sub->prop(ptr, "start", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
172 sub->prop(ptr, "end", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);
173
174 sub = &col->column(true);
175 sub->prop(ptr, "xsamples", UI_ITEM_NONE, IFACE_("Samples Transform"), ICON_NONE);
176 sub->prop(ptr, "gsamples", UI_ITEM_NONE, IFACE_("Geometry"), ICON_NONE);
177
178 sub = &col->column(true);
179 sub->prop(ptr, "sh_open", UI_ITEM_R_SLIDER, std::nullopt, ICON_NONE);
180 sub->prop(ptr,
181 "sh_close",
184 ICON_NONE);
185
186 col->separator();
187
188 col->prop(ptr, "use_instancing", UI_ITEM_NONE, IFACE_("Use Instancing"), ICON_NONE);
189 col->prop(
190 ptr, "export_custom_properties", UI_ITEM_NONE, IFACE_("Custom Properties"), ICON_NONE);
191 col->prop(ptr, "flatten", UI_ITEM_NONE, std::nullopt, ICON_NONE);
192
193 col = &panel->column(true);
194 col->prop(ptr, "evaluation_mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
195 }
196
197 /* Object Data */
198 if (uiLayout *panel = layout->panel(C, "ABC_export_geometry", false, IFACE_("Geometry"))) {
199 uiLayout *col = &panel->column(true);
200 col->prop(ptr, "uvs", UI_ITEM_NONE, std::nullopt, ICON_NONE);
201
202 uiLayout *row = &col->row(false);
204 row->prop(ptr, "packuv", UI_ITEM_NONE, std::nullopt, ICON_NONE);
205
206 col->prop(ptr, "normals", UI_ITEM_NONE, std::nullopt, ICON_NONE);
207 col->prop(ptr, "vcolors", UI_ITEM_NONE, std::nullopt, ICON_NONE);
208 col->prop(ptr, "orcos", UI_ITEM_NONE, std::nullopt, ICON_NONE);
209 col->prop(ptr, "face_sets", UI_ITEM_NONE, std::nullopt, ICON_NONE);
210 col->prop(ptr, "curves_as_mesh", UI_ITEM_NONE, std::nullopt, ICON_NONE);
211
212 col->separator();
213
214 uiLayout *sub = &col->column(true, IFACE_("Subdivision"));
215 sub->prop(ptr, "apply_subdiv", UI_ITEM_NONE, IFACE_("Apply"), ICON_NONE);
216 sub->prop(ptr, "subdiv_schema", UI_ITEM_NONE, IFACE_("Use Schema"), ICON_NONE);
217
218 col = &panel->column(false);
219 col->prop(ptr, "triangulate", UI_ITEM_NONE, std::nullopt, ICON_NONE);
220 sub = &col->column(false);
221 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "triangulate"));
222 sub->prop(ptr, "quad_method", UI_ITEM_NONE, IFACE_("Method Quads"), ICON_NONE);
223 sub->prop(ptr, "ngon_method", UI_ITEM_NONE, IFACE_("Polygons"), ICON_NONE);
224 }
225
226 /* Particle Data */
227 if (uiLayout *panel = layout->panel(
228 C, "ABC_export_particles", false, IFACE_("Particle Systems")))
229 {
230 uiLayout *col = &panel->column(true);
231 col->prop(ptr, "export_hair", UI_ITEM_NONE, std::nullopt, ICON_NONE);
232 col->prop(ptr, "export_particles", UI_ITEM_NONE, std::nullopt, ICON_NONE);
233 }
234}
235
236static void wm_alembic_export_draw(bContext *C, wmOperator *op)
237{
238 /* Conveniently set start and end frame to match the scene's frame range. */
239 Scene *scene = CTX_data_scene(C);
240
241 if (scene != nullptr && RNA_boolean_get(op->ptr, "init_scene_frame_range")) {
242 RNA_int_set(op->ptr, "start", scene->r.sfra);
243 RNA_int_set(op->ptr, "end", scene->r.efra);
244
245 RNA_boolean_set(op->ptr, "init_scene_frame_range", false);
246 }
247
248 ui_alembic_export_settings(C, op->layout, op->ptr);
249}
250
251static bool wm_alembic_export_check(bContext * /*C*/, wmOperator *op)
252{
253 char filepath[FILE_MAX];
254 RNA_string_get(op->ptr, "filepath", filepath);
255
256 if (!BLI_path_extension_check(filepath, ".abc")) {
257 BLI_path_extension_ensure(filepath, FILE_MAX, ".abc");
258 RNA_string_set(op->ptr, "filepath", filepath);
259 return true;
260 }
261
262 return false;
263}
264
266{
267 ot->name = "Export Alembic";
268 ot->description = "Export current scene in an Alembic archive";
269 ot->idname = "WM_OT_alembic_export";
270
271 ot->invoke = wm_alembic_export_invoke;
272 ot->exec = wm_alembic_export_exec;
274 ot->ui = wm_alembic_export_draw;
275 ot->check = wm_alembic_export_check;
276 ot->flag = OPTYPE_PRESET;
277
281 FILE_SAVE,
285
286 PropertyRNA *prop = RNA_def_string(ot->srna, "filter_glob", "*.abc", 0, "", "");
288
289 RNA_def_int(ot->srna,
290 "start",
291 INT_MIN,
292 INT_MIN,
293 INT_MAX,
294 "Start Frame",
295 "Start frame of the export, use the default value to "
296 "take the start frame of the current scene",
297 INT_MIN,
298 INT_MAX);
299
300 RNA_def_int(ot->srna,
301 "end",
302 INT_MIN,
303 INT_MIN,
304 INT_MAX,
305 "End Frame",
306 "End frame of the export, use the default value to "
307 "take the end frame of the current scene",
308 INT_MIN,
309 INT_MAX);
310
311 RNA_def_int(ot->srna,
312 "xsamples",
313 1,
314 1,
315 128,
316 "Transform Samples",
317 "Number of times per frame transformations are sampled",
318 1,
319 128);
320
321 RNA_def_int(ot->srna,
322 "gsamples",
323 1,
324 1,
325 128,
326 "Geometry Samples",
327 "Number of times per frame object data are sampled",
328 1,
329 128);
330
331 RNA_def_float(ot->srna,
332 "sh_open",
333 0.0f,
334 -1.0f,
335 1.0f,
336 "Shutter Open",
337 "Time at which the shutter is open",
338 -1.0f,
339 1.0f);
340
341 RNA_def_float(ot->srna,
342 "sh_close",
343 1.0f,
344 -1.0f,
345 1.0f,
346 "Shutter Close",
347 "Time at which the shutter is closed",
348 -1.0f,
349 1.0f);
350
352 ot->srna, "selected", false, "Selected Objects Only", "Export only selected objects");
353
354 RNA_def_boolean(ot->srna,
355 "visible_objects_only",
356 false,
357 "Visible Objects Only",
358 "Export only objects that are visible");
359
360 RNA_def_boolean(ot->srna,
361 "flatten",
362 false,
363 "Flatten Hierarchy",
364 "Do not preserve objects' parent/children relationship");
365
366 prop = RNA_def_string(ot->srna, "collection", nullptr, MAX_IDPROP_NAME, "Collection", nullptr);
368
369 RNA_def_boolean(ot->srna, "uvs", true, "UV Coordinates", "Export UV coordinates");
370
371 RNA_def_boolean(ot->srna, "packuv", true, "Merge UVs", "");
372
373 RNA_def_boolean(ot->srna, "normals", true, "Normals", "Export normals");
374
375 RNA_def_boolean(ot->srna, "vcolors", false, "Color Attributes", "Export color attributes");
376
377 RNA_def_boolean(ot->srna,
378 "orcos",
379 true,
380 "Generated Coordinates",
381 "Export undeformed mesh vertex coordinates");
382
384 ot->srna, "face_sets", false, "Face Sets", "Export per face shading group assignments");
385
386 RNA_def_boolean(ot->srna,
387 "subdiv_schema",
388 false,
389 "Use Subdivision Schema",
390 "Export meshes using Alembic's subdivision schema");
391
392 RNA_def_boolean(ot->srna,
393 "apply_subdiv",
394 false,
395 "Apply Subdivision Surface",
396 "Export subdivision surfaces as meshes");
397
398 RNA_def_boolean(ot->srna,
399 "curves_as_mesh",
400 false,
401 "Curves as Mesh",
402 "Export curves and NURBS surfaces as meshes");
403
404 RNA_def_boolean(ot->srna,
405 "use_instancing",
406 true,
407 "Use Instancing",
408 "Export data of duplicated objects as Alembic instances; speeds up the export "
409 "and can be disabled for compatibility with other software");
410
412 ot->srna,
413 "global_scale",
414 1.0f,
415 0.0001f,
416 1000.0f,
417 "Scale",
418 "Value by which to enlarge or shrink the objects with respect to the world's origin",
419 0.0001f,
420 1000.0f);
421
422 RNA_def_boolean(ot->srna,
423 "triangulate",
424 false,
425 "Triangulate",
426 "Export polygons (quads and n-gons) as triangles");
427
428 RNA_def_enum(ot->srna,
429 "quad_method",
432 "Quad Method",
433 "Method for splitting the quads into triangles");
434
435 RNA_def_enum(ot->srna,
436 "ngon_method",
439 "N-gon Method",
440 "Method for splitting the n-gons into triangles");
441
442 RNA_def_boolean(ot->srna,
443 "export_hair",
444 true,
445 "Export Hair",
446 "Exports hair particle systems as animated curves");
448 ot->srna, "export_particles", true, "Export Particles", "Exports non-hair particle systems");
449
450 RNA_def_boolean(ot->srna,
451 "export_custom_properties",
452 true,
453 "Export Custom Properties",
454 "Export custom properties to Alembic .userProperties");
455
457 ot->srna,
458 "as_background_job",
459 false,
460 "Run as Background Job",
461 "Enable this to run the import in the background, disable to block Blender while importing. "
462 "This option is deprecated; EXECUTE this operator to run in the foreground, and INVOKE it "
463 "to run as a background job");
464
465 RNA_def_enum(ot->srna,
466 "evaluation_mode",
467 rna_enum_abc_export_evaluation_mode_items,
469 "Settings",
470 "Determines visibility of objects, modifier settings, and other areas where there "
471 "are different settings for viewport and rendering");
472
473 /* This dummy prop is used to check whether we need to init the start and
474 * end frame values to that of the scene's, otherwise they are reset at
475 * every change, draw update. */
476 RNA_def_boolean(ot->srna, "init_scene_frame_range", true, "", "");
477}
478
479/* ************************************************************************** */
480
481/* TODO(kevin): check on de-duplicating all this with code in `image_ops.cc` */
482
483struct CacheFrame {
484 CacheFrame *next, *prev;
485 int framenr;
486};
487
488static int get_sequence_len(const char *filepath, int *ofs)
489{
490 int frame;
491 int numdigit;
492
493 if (!BLI_path_frame_get(filepath, &frame, &numdigit)) {
494 return 1;
495 }
496
497 char dirpath[FILE_MAX];
498 BLI_path_split_dir_part(filepath, dirpath, FILE_MAX);
499
500 if (dirpath[0] == '\0') {
501 /* The `filepath` had no directory component, so just use the blend files directory. */
503 }
504 else {
506 }
507
508 DIR *dir = opendir(dirpath);
509 if (dir == nullptr) {
510 fprintf(stderr,
511 "Error opening directory '%s': %s\n",
512 dirpath,
513 errno ? strerror(errno) : "unknown error");
514 return -1;
515 }
516
517 const char *ext = ".abc";
518 const char *basename = BLI_path_basename(filepath);
519 const int len = strlen(basename) - (numdigit + strlen(ext));
520
522
523 dirent *fname;
524 while ((fname = readdir(dir)) != nullptr) {
525 /* do we have the right extension? */
526 if (!strstr(fname->d_name, ext)) {
527 continue;
528 }
529
530 if (!STREQLEN(basename, fname->d_name, len)) {
531 continue;
532 }
533
534 CacheFrame cache_frame{};
535
536 BLI_path_frame_get(fname->d_name, &cache_frame.framenr, &numdigit);
537
538 frames.append(cache_frame);
539 }
540
541 closedir(dir);
542
543 std::sort(frames.begin(), frames.end(), [](const CacheFrame &a, const CacheFrame &b) {
544 return a.framenr < b.framenr;
545 });
546
547 if (frames.is_empty()) {
548 return -1;
549 }
550
551 int frame_curr = frames.first().framenr;
552 (*ofs) = frame_curr;
553
554 for (CacheFrame &cache_frame : frames) {
555 if (cache_frame.framenr != frame_curr) {
556 break;
557 }
558 frame_curr++;
559 }
560
561 return frame_curr - (*ofs);
562}
563
564/* ************************************************************************** */
565
566static void ui_alembic_import_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
567{
568 uiLayoutSetPropSep(layout, true);
569 uiLayoutSetPropDecorate(layout, false);
570
571 if (uiLayout *panel = layout->panel(C, "ABC_import_general", false, IFACE_("General"))) {
572 uiLayout *col = &panel->column(false);
573 col->prop(ptr, "scale", UI_ITEM_NONE, std::nullopt, ICON_NONE);
574 }
575
576 if (uiLayout *panel = layout->panel(C, "ABC_import_options", false, IFACE_("Options"))) {
577 uiLayout *col = &panel->column(false);
578 col->prop(ptr, "relative_path", UI_ITEM_NONE, std::nullopt, ICON_NONE);
579 col->prop(ptr, "set_frame_range", UI_ITEM_NONE, std::nullopt, ICON_NONE);
580 col->prop(ptr, "is_sequence", UI_ITEM_NONE, std::nullopt, ICON_NONE);
581 col->prop(ptr, "validate_meshes", UI_ITEM_NONE, std::nullopt, ICON_NONE);
582 col->prop(ptr, "always_add_cache_reader", UI_ITEM_NONE, std::nullopt, ICON_NONE);
583 }
584}
585
586static void wm_alembic_import_draw(bContext *C, wmOperator *op)
587{
588 ui_alembic_import_settings(C, op->layout, op->ptr);
589}
590
591/* op->invoke, opens fileselect if path property not set, otherwise executes */
592static wmOperatorStatus wm_alembic_import_invoke(bContext *C, wmOperator *op, const wmEvent *event)
593{
594 if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) {
595 RNA_boolean_set(op->ptr, "as_background_job", true);
596 }
598}
599
600static wmOperatorStatus wm_alembic_import_exec(bContext *C, wmOperator *op)
601{
603 if (paths.is_empty()) {
604 BKE_report(op->reports, RPT_ERROR, "No filepath given");
605 return OPERATOR_CANCELLED;
606 }
607
608 const float scale = RNA_float_get(op->ptr, "scale");
609 const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
610 const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range");
611 const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
612 const bool always_add_cache_reader = RNA_boolean_get(op->ptr, "always_add_cache_reader");
613 const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
614
615 int sequence_min_frame = std::numeric_limits<int>::max();
616 int sequence_max_frame = std::numeric_limits<int>::min();
617
618 if (is_sequence) {
619 for (const std::string &path : paths) {
620 int offset = 0;
621 int sequence_len = get_sequence_len(path.c_str(), &offset);
622 if (sequence_len < 0) {
623 BKE_report(op->reports, RPT_ERROR, "Unable to determine ABC sequence length");
624 return OPERATOR_CANCELLED;
625 }
626 sequence_min_frame = std::min(sequence_min_frame, offset);
627 sequence_max_frame = std::max(sequence_max_frame, offset + (sequence_len - 1));
628 }
629 }
630
631 /* Switch out of edit mode to avoid being stuck in it (#54326). */
632 Object *obedit = CTX_data_edit_object(C);
633 if (obedit) {
635 }
636
638 params.paths = std::move(paths);
639 params.global_scale = scale;
640 params.sequence_min_frame = sequence_min_frame;
641 params.sequence_max_frame = sequence_max_frame;
642 params.is_sequence = is_sequence;
643 params.set_frame_range = set_frame_range;
644 params.validate_meshes = validate_meshes;
645 params.always_add_cache_reader = always_add_cache_reader;
646
647 bool ok = ABC_import(C, &params, as_background_job);
648
649 return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
650}
651
653{
654 ot->name = "Import Alembic";
655 ot->description = "Load an Alembic archive";
656 ot->idname = "WM_OT_alembic_import";
657 ot->flag = OPTYPE_UNDO | OPTYPE_PRESET;
658
659 ot->invoke = wm_alembic_import_invoke;
660 ot->exec = wm_alembic_import_exec;
662 ot->ui = wm_alembic_import_draw;
663
672
673 PropertyRNA *prop = RNA_def_string(ot->srna, "filter_glob", "*.abc", 0, "", "");
675
677 ot->srna,
678 "scale",
679 1.0f,
680 0.0001f,
681 1000.0f,
682 "Scale",
683 "Value by which to enlarge or shrink the objects with respect to the world's origin",
684 0.0001f,
685 1000.0f);
686
688 ot->srna,
689 "set_frame_range",
690 true,
691 "Set Frame Range",
692 "If checked, update scene's start and end frame to match those of the Alembic archive");
693
695 ot->srna,
696 "validate_meshes",
697 false,
698 "Validate Meshes",
699 "Ensure the data is valid "
700 "(when disabled, data may be imported which causes crashes displaying or editing)");
701
702 RNA_def_boolean(ot->srna,
703 "always_add_cache_reader",
704 false,
705 "Always Add Cache Reader",
706 "Add cache modifiers and constraints to imported objects even if they are not "
707 "animated so that they can be updated when reloading the Alembic archive");
708
709 RNA_def_boolean(ot->srna,
710 "is_sequence",
711 false,
712 "Is Sequence",
713 "Set to true if the cache is split into separate files");
714
716 ot->srna,
717 "as_background_job",
718 false,
719 "Run as Background Job",
720 "Enable this to run the export in the background, disable to block Blender while exporting. "
721 "This option is deprecated; EXECUTE this operator to run in the foreground, and INVOKE it "
722 "to run as a background job");
723}
724
725namespace blender::ed::io {
727{
728 auto fh = std::make_unique<blender::bke::FileHandlerType>();
729 STRNCPY(fh->idname, "IO_FH_alembic");
730 STRNCPY(fh->import_operator, "WM_OT_alembic_import");
731 STRNCPY(fh->export_operator, "WM_OT_alembic_export");
732 STRNCPY(fh->label, "Alembic");
733 STRNCPY(fh->file_extensions_str, ".abc");
734 fh->poll_drop = poll_file_object_drop;
735 bke::file_handler_add(std::move(fh));
736}
737} // namespace blender::ed::io
738
739#endif
bool ABC_import(struct bContext *C, const struct AlembicImportParams *params, bool as_background_job)
bool ABC_export(struct Scene *scene, struct bContext *C, const char *filepath, const struct AlembicExportParams *params, bool as_background_job)
SpaceFile * CTX_wm_space_file(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
const char * BKE_main_blendfile_path_from_global()
Definition main.cc:877
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define FILE_MAX
bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
#define STREQLEN(a, b, n)
Compatibility-like things for windows.
struct __dirstream DIR
struct dirent * readdir(DIR *dp)
int closedir(DIR *dp)
DIR * opendir(const char *path)
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_ID_CAMERA
eEvaluationMode
@ DAG_EVAL_RENDER
@ DAG_EVAL_VIEWPORT
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
@ MOD_TRIANGULATE_NGON_BEAUTY
@ OB_MODE_OBJECT
Object is a sort of wrapper for general info.
@ FILE_SORT_DEFAULT
@ FILE_BLENDER
@ FILE_TYPE_ALEMBIC
@ FILE_TYPE_FOLDER
@ FILE_DEFAULTDISPLAY
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
Definition filesel.cc:1490
@ PROP_HIDDEN
Definition RNA_types.hh:324
#define C
Definition RandGen.cpp:29
@ UI_ITEM_R_SLIDER
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_ITEM_NONE
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
@ WM_FILESEL_FILES
Definition WM_api.hh:1076
@ WM_FILESEL_DIRECTORY
Definition WM_api.hh:1073
@ WM_FILESEL_RELPATH
Definition WM_api.hh:1072
@ WM_FILESEL_SHOW_PROPS
Definition WM_api.hh:1078
@ WM_FILESEL_FILEPATH
Definition WM_api.hh:1075
@ FILE_OPENFILE
Definition WM_api.hh:1084
@ FILE_SAVE
Definition WM_api.hh:1085
@ OPTYPE_PRESET
Definition WM_types.hh:195
@ OPTYPE_UNDO
Definition WM_types.hh:182
static void set_frame_range(ImportJobData *data)
void append(const T &value)
bool is_empty() const
const T & first() const
uint col
#define MAX_IDPROP_NAME
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void WM_OT_alembic_import(wmOperatorType *ot)
void WM_OT_alembic_export(wmOperatorType *ot)
static ulong * next
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
void alembic_file_handler_add()
bool poll_file_object_drop(const bContext *C, blender::bke::FileHandlerType *)
Definition io_utils.cc:57
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
Definition io_utils.cc:74
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition io_utils.cc:25
bool mode_set(bContext *C, eObjectMode mode)
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
SymEdge< T > * prev(const SymEdge< T > *se)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]
const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]
struct RenderData r
char * d_name
PanelLayout panel(const bContext *C, blender::StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
struct ReportList * reports
struct uiLayout * layout
struct PointerRNA * ptr
uint len
void WM_event_add_fileselect(bContext *C, wmOperator *op)
PointerRNA * ptr
Definition wm_files.cc:4226
wmOperatorType * ot
Definition wm_files.cc:4225
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
bool WM_operator_winactive(bContext *C)