57 "Use Render settings for object visibility, modifier settings, etc"},
62 "Use Viewport settings for object visibility, modifier settings, etc"},
63 {0,
nullptr, 0,
nullptr,
nullptr},
67 {int(MtlNameCollisionMode::MakeUnique),
71 "Import each USD material as a unique Blender material"},
72 {int(MtlNameCollisionMode::ReferenceExisting),
76 "If a material with the same name already exists, reference that instead of importing"},
77 {0,
nullptr, 0,
nullptr,
nullptr},
81 {int(PropertyImportMode::None),
"NONE", 0,
"None",
"Do not import USD custom attributes"},
82 {int(PropertyImportMode::User),
86 "Import USD attributes in the 'userProperties' namespace as Blender custom "
87 "properties. The namespace will be stripped from the property names"},
88 {int(PropertyImportMode::All),
92 "Import all USD custom attributes as Blender custom properties. "
93 "Namespaces will be retained in the property names"},
94 {0,
nullptr, 0,
nullptr,
nullptr},
98 {int(TexImportMode::None),
"IMPORT_NONE", 0,
"None",
"Don't import textures"},
99 {int(TexImportMode::Pack),
"IMPORT_PACK", 0,
"Packed",
"Import textures as packed data"},
100 {int(TexImportMode::Copy),
"IMPORT_COPY", 0,
"Copy",
"Copy files to textures directory"},
101 {0,
nullptr, 0,
nullptr,
nullptr},
105 {int(TexNameCollisionMode::UseExisting),
109 "If a file with the same name already exists, use that instead of copying"},
110 {int(TexNameCollisionMode::Overwrite),
114 "Overwrite existing files"},
115 {0,
nullptr, 0,
nullptr,
nullptr},
119 {int(SubdivExportMode::Ignore),
123 "Scheme = None. Export base mesh without subdivision"},
124 {int(SubdivExportMode::Tessellate),
128 "Scheme = None. Export subdivided mesh"},
129 {int(SubdivExportMode::Match),
133 "Scheme = Catmull-Clark, when possible. "
134 "Reverts to exporting the subdivided mesh for the Simple subdivision type"},
135 {0,
nullptr, 0,
nullptr,
nullptr},
139 {int(XformOpMode::TRS),
142 "Translate, Rotate, Scale",
143 "Export with translate, rotate, and scale Xform operators"},
144 {int(XformOpMode::TOS),
147 "Translate, Orient, Scale",
148 "Export with translate, orient quaternion, and scale Xform operators"},
149 {int(XformOpMode::MAT),
"MAT", 0,
"Matrix",
"Export matrix operator"},
150 {0,
nullptr, 0,
nullptr,
nullptr},
154 {int(TextureDownscaleSize::Keep),
"KEEP", 0,
"Keep",
"Keep all current texture sizes"},
155 {int(TextureDownscaleSize::Size256),
"256", 0,
"256",
"Resize to a maximum of 256 pixels"},
156 {int(TextureDownscaleSize::Size512),
"512", 0,
"512",
"Resize to a maximum of 512 pixels"},
157 {int(TextureDownscaleSize::Size1024),
"1024", 0,
"1024",
"Resize to a maximum of 1024 pixels"},
158 {int(TextureDownscaleSize::Size2048),
"2048", 0,
"2048",
"Resize to a maximum of 2048 pixels"},
159 {int(TextureDownscaleSize::Size4096),
"4096", 0,
"4096",
"Resize to a maximum of 4096 pixels"},
160 {int(TextureDownscaleSize::Custom),
"CUSTOM", 0,
"Custom",
"Specify a custom size"},
161 {0,
nullptr, 0,
nullptr,
nullptr},
165 {int(TexExportMode::Keep),
"KEEP", 0,
"Keep",
"Use original location of textures"},
166 {int(TexExportMode::Preserve),
170 "Preserve file paths of textures from already imported USD files.\n"
171 "Export remaining textures to a 'textures' folder next to the USD file"},
172 {int(TexExportMode::NewPath),
176 "Export textures to a 'textures' folder next to the USD file"},
177 {0,
nullptr, 0,
nullptr,
nullptr}};
180 {int(MtlPurpose::All),
184 "Attempt to import 'allPurpose' materials."},
185 {int(MtlPurpose::Preview),
189 "Attempt to import 'preview' materials. "
190 "Load 'allPurpose' materials as a fallback"},
191 {int(MtlPurpose::Full),
195 "Attempt to import 'full' materials. "
196 "Load 'allPurpose' or 'preview' materials, in that order, as a fallback"},
197 {0,
nullptr, 0,
nullptr,
nullptr},
201 {int(SceneUnits::Meters),
"METERS", 0,
"Meters",
"Scene meters per unit to 1.0"},
202 {int(SceneUnits::Kilometers),
206 "Scene meters per unit to 1000.0"},
207 {int(SceneUnits::Centimeters),
211 "Scene meters per unit to 0.01"},
212 {int(SceneUnits::Millimeters),
216 "Scene meters per unit to 0.001"},
217 {int(SceneUnits::Inches),
"INCHES", 0,
"Inches",
"Scene meters per unit to 0.0254"},
218 {int(SceneUnits::Feet),
"FEET", 0,
"Feet",
"Scene meters per unit to 0.3048"},
219 {int(SceneUnits::Yards),
"YARDS", 0,
"Yards",
"Scene meters per unit to 0.9144"},
220 {int(SceneUnits::Custom),
224 "Specify a custom scene meters per unit value"},
225 {0,
nullptr, 0,
nullptr,
nullptr},
230struct USDOperatorOptions {
231 bool as_background_job;
234static void free_operator_customdata(
wmOperator *op)
236 if (op->customdata) {
237 USDOperatorOptions *
options =
static_cast<USDOperatorOptions *
>(op->customdata);
239 op->customdata =
nullptr;
245static void process_prim_path(std::string &prim_path)
247 if (prim_path.empty()) {
252 if (prim_path ==
"/") {
256 else if (prim_path[0] !=
'/') {
257 prim_path.insert(0, 1,
'/');
266 options->as_background_job =
true;
280 free_operator_customdata(op);
284 const USDOperatorOptions *
options =
static_cast<USDOperatorOptions *
>(op->customdata);
285 const bool as_background_job = (
options !=
nullptr &&
options->as_background_job);
286 free_operator_customdata(op);
292 bool export_textures =
false;
293 bool use_original_paths =
false;
295 switch (textures_mode) {
296 case TexExportMode::Preserve:
297 export_textures =
false;
298 use_original_paths =
true;
300 case TexExportMode::NewPath:
301 export_textures =
true;
302 use_original_paths =
false;
304 case TexExportMode::Keep:
305 export_textures =
false;
306 use_original_paths =
false;
315 params.incremental_frames =
RNA_int_get(op->ptr,
"incremental_frames");
316 params.selected_objects_only =
RNA_boolean_get(op->ptr,
"selected_objects_only");
320 params.convert_world_material = params.export_lights &&
330 params.export_mesh_colors =
RNA_boolean_get(op->ptr,
"export_mesh_colors");
331 params.export_materials =
RNA_boolean_get(op->ptr,
"export_materials");
333 params.export_armatures =
RNA_boolean_get(op->ptr,
"export_armatures");
334 params.export_shapekeys =
RNA_boolean_get(op->ptr,
"export_shapekeys");
335 params.only_deform_bones =
RNA_boolean_get(op->ptr,
"only_deform_bones");
338 params.export_custom_properties =
RNA_boolean_get(op->ptr,
"export_custom_properties");
339 params.author_blender_name =
RNA_boolean_get(op->ptr,
"author_blender_name");
345 params.generate_preview_surface =
RNA_boolean_get(op->ptr,
"generate_preview_surface");
346 params.generate_materialx_network =
RNA_boolean_get(op->ptr,
"generate_materialx_network");
347 params.overwrite_textures =
RNA_boolean_get(op->ptr,
"overwrite_textures");
349 params.export_textures = export_textures;
350 params.use_original_paths = use_original_paths;
352 params.triangulate_meshes =
RNA_boolean_get(op->ptr,
"triangulate_meshes");
353 params.quad_method =
RNA_enum_get(op->ptr,
"quad_method");
354 params.ngon_method =
RNA_enum_get(op->ptr,
"ngon_method");
356 params.convert_orientation =
RNA_boolean_get(op->ptr,
"convert_orientation");
362 params.usdz_downscale_custom_size =
RNA_int_get(op->ptr,
"usdz_downscale_custom_size");
364 params.custom_meters_per_unit =
RNA_float_get(op->ptr,
"meters_per_unit");
366 params.merge_parent_xform =
RNA_boolean_get(op->ptr,
"merge_parent_xform");
368 params.root_prim_path =
RNA_string_get(op->ptr,
"root_prim_path");
369 process_prim_path(params.root_prim_path);
371 RNA_string_get(op->ptr,
"custom_properties_namespace", params.custom_properties_namespace);
374 params.accessibility_label =
RNA_string_get(op->ptr,
"accessibility_label");
375 params.accessibility_description =
RNA_string_get(op->ptr,
"accessibility_description");
377 bool ok =
USD_export(
C, filepath, ¶ms, as_background_job, op->reports);
387 layout.use_property_split_set(
true);
388 layout.use_property_decorate_set(
false);
396 sub->prop(ptr,
"selected_objects_only",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
400 sub->prop(ptr,
"incremental_frames",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
403 sub = &col->column(
true,
IFACE_(
"Blender Data"));
404 sub->prop(ptr,
"export_custom_properties",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
406 props_col->
prop(ptr,
"custom_properties_namespace",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
407 props_col->prop(ptr,
"author_blender_name",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
408 props_col->active_set(
RNA_boolean_get(op->ptr,
"export_custom_properties"));
409 sub->prop(ptr,
"allow_unicode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
411 sub = &col->column(
true,
IFACE_(
"File References"));
412 sub->prop(ptr,
"relative_paths",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
414 col = &panel->column(
false);
415 col->prop(ptr,
"convert_orientation",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
417 col->prop(ptr,
"export_global_forward_selection",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
418 col->prop(ptr,
"export_global_up_selection",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
421 col->prop(ptr,
"convert_scene_units",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
423 col->prop(ptr,
"meters_per_unit",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
426 col->prop(ptr,
"xform_op_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
428 col = &panel->column(
false);
429 col->prop(ptr,
"evaluation_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
435 col.prop(ptr,
"export_lights",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
438 row.
prop(ptr,
"convert_world_material",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
440 row.active_set(export_lights);
442 col.prop(ptr,
"export_cameras",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
443 col.prop(ptr,
"export_curves",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
444 col.prop(ptr,
"export_points",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
445 col.prop(ptr,
"export_volumes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
446 col.prop(ptr,
"export_hair",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
452 col.prop(ptr,
"rename_uvmaps",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
453 col.prop(ptr,
"export_normals",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
455 col.prop(ptr,
"merge_parent_xform",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
456 col.prop(ptr,
"triangulate_meshes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
462 col.prop(ptr,
"export_subdivision",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
469 col.prop(ptr,
"export_armatures",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
479 panel.header->prop(ptr,
"export_materials",
UI_ITEM_NONE,
"", ICON_NONE);
480 panel.header->label(
IFACE_(
"Materials"), ICON_NONE);
482 const bool export_materials =
RNA_boolean_get(ptr,
"export_materials");
483 panel.body->active_set(export_materials);
486 col->
prop(ptr,
"generate_preview_surface",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
487 col->prop(ptr,
"generate_materialx_network",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
489 col = &panel.body->column(
true);
490 col->use_property_split_set(
true);
491 col->prop(ptr,
"export_textures_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
498 sub_col.enabled_set(textures_mode == TexExportMode::NewPath);
499 sub_col.prop(ptr,
"overwrite_textures",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
500 sub_col.prop(ptr,
"usdz_downscale_size",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
502 TextureDownscaleSize::Custom)
504 sub_col.prop(ptr,
"usdz_downscale_custom_size",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
510 C,
"USD_export_accessibility",
true,
IFACE_(
"Accessibility")))
513 col.
prop(ptr,
"accessibility_label",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
514 col.prop(ptr,
"accessibility_description",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
526 free_operator_customdata(op);
545 int forward =
RNA_enum_get(ptr,
"export_global_forward_selection");
546 int up =
RNA_enum_get(ptr,
"export_global_up_selection");
547 if ((forward % 3) == (up % 3)) {
548 RNA_enum_set(ptr,
"export_global_up_selection", (up + 1) % 6);
554 int forward =
RNA_enum_get(ptr,
"export_global_forward_selection");
555 int up =
RNA_enum_get(ptr,
"export_global_up_selection");
556 if ((forward % 3) == (up % 3)) {
557 RNA_enum_set(ptr,
"export_global_forward_selection", (forward + 1) % 6);
563 ot->name =
"Export USD";
564 ot->description =
"Export current scene in a USD archive";
565 ot->idname =
"WM_OT_usd_export";
567 ot->invoke = wm_usd_export_invoke;
568 ot->exec = wm_usd_export_exec;
570 ot->ui = wm_usd_export_draw;
571 ot->cancel = wm_usd_export_cancel;
572 ot->check = wm_usd_export_check;
588 "selected_objects_only",
591 "Only export selected objects. Unselected parents of selected objects are "
592 "exported as empty transform");
602 "Export all frames in the render frame range, rather than only the current frame");
604 "incremental_frames",
609 "Incrementally save after the specified number of frames to reduce peak memory "
610 "usage. Incremental saves can result in longer export times and potential issues "
611 "with some file synchronization services. Zero disables incremental save",
616 ot->srna,
"export_hair",
false,
"Hair",
"Export hair particle systems as USD curves");
618 ot->srna,
"export_uvmaps",
true,
"UV Maps",
"Include all mesh UV maps in the export");
623 "Rename active render UV map to \"st\" to match USD conventions");
625 "export_mesh_colors",
628 "Include mesh color attributes in the export");
633 "Include normals of exported meshes in the export");
638 "Export viewport settings of materials as USD preview materials, and export "
639 "material assignments as geometry subsets");
642 "export_subdivision",
643 rna_enum_usd_export_subdiv_mode_items,
644 int(SubdivExportMode::Match),
646 "Choose how subdivision modifiers will be mapped to the USD subdivision scheme "
653 "Export armatures and meshes with armature modifiers as USD skeletons and "
660 "Only export deform bones and their parents");
663 ot->srna,
"export_shapekeys",
true,
"Shape Keys",
"Export shape keys as USD blend shapes");
669 "Export instanced objects as references in USD rather than real objects");
673 rna_enum_usd_export_evaluation_mode_items,
676 "Determines visibility of objects, modifier settings, and other areas where there "
677 "are different settings for viewport and rendering");
680 "generate_preview_surface",
682 "USD Preview Surface Network",
683 "Generate an approximate USD Preview Surface shader "
684 "representation of a Principled BSDF node network");
687 "generate_materialx_network",
690 "Generate a MaterialX network representation of the materials");
694 "convert_orientation",
696 "Convert Orientation",
697 "Convert orientation axis to a different convention to match other applications");
700 "export_global_forward_selection",
712 "export_textures_mode",
713 rna_enum_usd_tex_export_mode_items,
714 int(TexExportMode::NewPath),
716 "Texture export method");
719 "overwrite_textures",
721 "Overwrite Textures",
722 "Overwrite existing files when exporting textures");
728 "Use relative paths to reference external files (i.e. textures, volumes) in "
729 "USD, otherwise use absolute paths");
733 rna_enum_usd_xform_op_mode_items,
734 int(XformOpMode::TRS),
736 "The type of transform operators to write");
743 "If set, add a transform primitive with the given path to the stage "
744 "as the parent of all exported data");
747 "export_custom_properties",
750 "Export custom properties as USD attributes");
753 "custom_properties_namespace",
757 "If set, add the given namespace as a prefix to exported custom property names. "
758 "This only applies to property names that do not already have a prefix "
759 "(e.g., it would apply to name 'bar' but not 'foo:bar') and does not apply "
760 "to blender object and data names which are always exported in the "
761 "'userProperties:blender' namespace");
764 "accessibility_label",
768 "Set the accessibility label for the exported stage's default prim");
772 "accessibility_description",
776 "Set the accessibility description for the exported stage's default prim");
780 "author_blender_name",
783 "Author USD custom attributes containing the original Blender object and "
784 "object data names");
788 "convert_world_material",
791 "Convert the world material to a USD dome light. "
792 "Currently works for simple materials, consisting of an environment texture "
793 "connected to a background shader, with an optional vector multiply of the texture color");
800 "Preserve UTF-8 encoded characters when writing USD prim and property names "
801 "(requires software utilizing USD 24.03 or greater when opening the resulting files)");
803 RNA_def_boolean(ot->srna,
"export_meshes",
true,
"Meshes",
"Export all meshes");
805 RNA_def_boolean(ot->srna,
"export_lights",
true,
"Lights",
"Export all lights");
807 RNA_def_boolean(ot->srna,
"export_cameras",
true,
"Cameras",
"Export all cameras");
809 RNA_def_boolean(ot->srna,
"export_curves",
true,
"Curves",
"Export all curves");
811 RNA_def_boolean(ot->srna,
"export_points",
true,
"Point Clouds",
"Export all point clouds");
813 RNA_def_boolean(ot->srna,
"export_volumes",
true,
"Volumes",
"Export all volumes");
816 "triangulate_meshes",
818 "Triangulate Meshes",
819 "Triangulate meshes during export");
826 "Method for splitting the quads into triangles");
833 "Method for splitting the n-gons into triangles");
836 "usdz_downscale_size",
837 rna_enum_usdz_downscale_size,
839 "USDZ Texture Downsampling",
840 "Choose a maximum size for all exported textures");
843 "usdz_downscale_custom_size",
847 "USDZ Custom Downscale Size",
848 "Custom size for downscaling exported textures",
853 "merge_parent_xform",
855 "Merge parent Xform",
856 "Merge USD primitives with their Xform parent if possible. USD does not allow "
857 "nested UsdGeomGprims, intermediary Xform prims will be defined to keep the USD "
858 "file valid when encountering object hierarchies.");
861 "convert_scene_units",
862 rna_enum_usd_convert_scene_units_items,
863 int(SceneUnits::Meters),
865 "Set the USD Stage meters per unit to the chosen measurement, or a custom value");
873 "Custom value for meters per unit in the USD Stage",
883 options->as_background_job =
true;
893 free_operator_customdata(op);
897 const USDOperatorOptions *
options =
static_cast<USDOperatorOptions *
>(op->customdata);
898 const bool as_background_job = (
options !=
nullptr &&
options->as_background_job);
899 free_operator_customdata(op);
905 const bool read_mesh_colors =
RNA_boolean_get(op->ptr,
"read_mesh_colors");
906 const bool read_mesh_attributes =
RNA_boolean_get(op->ptr,
"read_mesh_attributes");
912 if (read_mesh_colors) {
915 if (read_mesh_attributes) {
921 params.light_intensity_scale =
RNA_float_get(op->ptr,
"light_intensity_scale");
922 params.apply_unit_conversion_scale =
RNA_boolean_get(op->ptr,
"apply_unit_conversion_scale");
924 params.mesh_read_flag = mesh_read_flag;
928 params.is_sequence =
false;
929 params.sequence_len = 1;
933 params.import_visible_only =
RNA_boolean_get(op->ptr,
"import_visible_only");
934 params.import_defined_only =
RNA_boolean_get(op->ptr,
"import_defined_only");
939 params.create_world_material = params.import_lights &&
941 params.import_materials =
RNA_boolean_get(op->ptr,
"import_materials");
942 params.import_all_materials =
RNA_boolean_get(op->ptr,
"import_all_materials");
945 params.import_subdivision =
RNA_boolean_get(op->ptr,
"import_subdivision");
948 params.create_collection =
RNA_boolean_get(op->ptr,
"create_collection");
949 params.support_scene_instancing =
RNA_boolean_get(op->ptr,
"support_scene_instancing");
952 params.import_skeletons =
RNA_boolean_get(op->ptr,
"import_skeletons");
953 params.import_blendshapes =
RNA_boolean_get(op->ptr,
"import_blendshapes");
956 params.merge_parent_xform =
RNA_boolean_get(op->ptr,
"merge_parent_xform");
962 params.import_usd_preview =
RNA_boolean_get(op->ptr,
"import_usd_preview");
963 params.set_material_blend =
RNA_boolean_get(op->ptr,
"set_material_blend");
973 params.prim_path_mask =
RNA_string_get(op->ptr,
"prim_path_mask");
975 RNA_string_get(op->ptr,
"import_textures_dir", params.import_textures_dir);
983 const bool ok =
USD_import(
C, filepath, ¶ms, as_background_job, op->reports);
990 free_operator_customdata(op);
998 layout.use_property_split_set(
true);
999 layout.use_property_decorate_set(
false);
1007 sub.
prop(ptr,
"import_visible_only",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1008 sub.prop(ptr,
"import_defined_only",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1010 col = &panel->column(
false);
1011 col->prop(ptr,
"set_frame_range",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1012 col->prop(ptr,
"create_collection",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1013 col->prop(ptr,
"relative_path",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1015 col->prop(ptr,
"apply_unit_conversion_scale",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1016 col->prop(ptr,
"scale",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1017 col->prop(ptr,
"light_intensity_scale",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1018 col->prop(ptr,
"property_import_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1023 obj_col.
prop(ptr,
"import_cameras",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1024 obj_col.prop(ptr,
"import_curves",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1025 obj_col.prop(ptr,
"import_lights",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1028 row.
prop(ptr,
"create_world_material",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1030 row.active_set(import_lights);
1032 obj_col.prop(ptr,
"import_materials",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1033 obj_col.prop(ptr,
"import_meshes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1034 obj_col.prop(ptr,
"import_volumes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1035 obj_col.prop(ptr,
"import_points",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1036 obj_col.prop(ptr,
"import_shapes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1039 disp_col.
prop(ptr,
"import_render",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1040 disp_col.prop(ptr,
"import_proxy",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1041 disp_col.prop(ptr,
"import_guide",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1050 col->prop(ptr,
"read_mesh_colors",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1051 col->prop(ptr,
"read_mesh_attributes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1052 col->prop(ptr,
"import_subdivision",
UI_ITEM_NONE,
IFACE_(
"Subdivision"), ICON_NONE);
1054 col = &panel->column(
false);
1055 col->prop(ptr,
"validate_meshes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1056 col->prop(ptr,
"merge_parent_xform",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1061 col.
prop(ptr,
"import_blendshapes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1062 col.prop(ptr,
"import_skeletons",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1068 col.
prop(ptr,
"import_all_materials",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1069 col.prop(ptr,
"import_usd_preview",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1073 row.
prop(ptr,
"set_material_blend",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1075 col.prop(ptr,
"mtl_name_collision_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1081 col.
prop(ptr,
"import_textures_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1083 TexImportMode::Copy;
1086 row->
prop(ptr,
"import_textures_dir",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1087 row->enabled_set(copy_textures);
1088 row = &col.row(
true);
1089 row->prop(ptr,
"tex_name_collision_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1090 row->enabled_set(copy_textures);
1095 C,
"USD_import_instancing",
true,
IFACE_(
"Particles and Instancing")))
1098 col.
prop(ptr,
"support_scene_instancing",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1104 ot->name =
"Import USD";
1105 ot->description =
"Import USD stage into current scene";
1106 ot->idname =
"WM_OT_usd_import";
1108 ot->invoke = wm_usd_import_invoke;
1109 ot->exec = wm_usd_import_exec;
1110 ot->cancel = wm_usd_import_cancel;
1112 ot->ui = wm_usd_import_draw;
1134 "Value by which to enlarge or shrink the objects with respect to the world's origin",
1142 "Update the scene's start and end frame to match those of the USD archive");
1152 RNA_def_boolean(ot->srna,
"import_blendshapes",
true,
"Shape Keys",
"");
1156 "import_subdivision",
1158 "Import Subdivision Scheme",
1159 "Create subdivision surface modifiers based on the USD "
1160 "SubdivisionScheme attribute");
1163 "support_scene_instancing",
1166 "Import USD scene graph instances as collection instances");
1169 "import_visible_only",
1171 "Visible Primitives Only",
1172 "Do not import invisible USD primitives. "
1173 "Only applies to primitives with a non-animated visibility attribute. "
1174 "Primitives with animated visibility will always be imported");
1177 "create_collection",
1179 "Create Collection",
1180 "Add all imported objects to a new collection");
1182 RNA_def_boolean(ot->srna,
"read_mesh_uvs",
true,
"UV Coordinates",
"Read mesh UV coordinates");
1185 ot->srna,
"read_mesh_colors",
true,
"Color Attributes",
"Read mesh color attributes");
1188 "read_mesh_attributes",
1191 "Read USD Primvars as mesh attributes");
1198 "Import only the primitive at the given path and its descendants. "
1199 "Multiple paths may be specified in a list delimited by commas or semicolons");
1201 RNA_def_boolean(ot->srna,
"import_guide",
false,
"Guide",
"Import guide geometry");
1203 RNA_def_boolean(ot->srna,
"import_proxy",
false,
"Proxy",
"Import proxy geometry");
1205 RNA_def_boolean(ot->srna,
"import_render",
true,
"Render",
"Import final render geometry");
1208 "import_all_materials",
1210 "Import All Materials",
1211 "Also import materials that are not used by any geometry. "
1212 "Note that when this option is false, materials referenced "
1213 "by geometry will still be imported");
1216 "import_usd_preview",
1218 "Import USD Preview",
1219 "Convert UsdPreviewSurface shaders to Principled BSDF shader networks");
1222 "set_material_blend",
1224 "Set Material Blend",
1225 "If the Import USD Preview option is enabled, "
1226 "the material blend method will automatically be set based on the "
1227 "shader's opacity and opacityThreshold inputs");
1230 "light_intensity_scale",
1234 "Light Intensity Scale",
1235 "Scale for the intensity of imported lights",
1241 rna_enum_usd_mtl_purpose_items,
1242 int(MtlPurpose::Full),
1244 "Attempt to import materials with the given purpose. "
1245 "If no material with this purpose is bound to the primitive, "
1246 "fall back on loading any other bound material");
1250 "mtl_name_collision_mode",
1251 rna_enum_usd_mtl_name_collision_mode_items,
1252 int(MtlNameCollisionMode::MakeUnique),
1253 "Material Name Collision",
1254 "Behavior when the name of an imported material conflicts with an existing material");
1257 "import_textures_mode",
1258 rna_enum_usd_tex_import_mode_items,
1259 int(TexImportMode::Pack),
1261 "Behavior when importing textures from a USDZ archive");
1264 "import_textures_dir",
1267 "Textures Directory",
1268 "Path to the directory where imported textures will be copied");
1272 "tex_name_collision_mode",
1273 rna_enum_usd_tex_name_collision_mode_items,
1274 int(TexNameCollisionMode::UseExisting),
1275 "File Name Collision",
1276 "Behavior when the name of an imported texture file conflicts with an existing file");
1279 "property_import_mode",
1280 rna_enum_usd_property_import_mode_items,
1281 int(PropertyImportMode::All),
1282 "Custom Properties",
1283 "Behavior when importing USD attributes as Blender custom properties");
1290 "Ensure the data is valid "
1291 "(when disabled, data may be imported which causes crashes displaying or editing)");
1294 "create_world_material",
1297 "Convert the first discovered USD dome light to a world background shader");
1300 "import_defined_only",
1302 "Defined Primitives Only",
1303 "Import only defined USD primitives. When disabled this allows importing USD "
1304 "primitives which are not defined, such as those with an override specifier");
1307 "merge_parent_xform",
1309 "Merge parent Xform",
1310 "Allow USD primitives to merge with their Xform parent "
1311 "if they are the only child in the hierarchy");
1315 "apply_unit_conversion_scale",
1317 "Apply Unit Conversion Scale",
1318 "Scale the scene objects by the USD stage's meters per unit value. "
1319 "This scaling is applied in addition to the value specified in the Scale option");
1325 auto fh = std::make_unique<bke::FileHandlerType>();
1329 STRNCPY_UTF8(fh->label,
"Universal Scene Description");
1330 STRNCPY_UTF8(fh->file_extensions_str,
".usd;.usda;.usdc;.usdz");
#define STRNCPY_UTF8(dst, src)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
CCL_NAMESPACE_BEGIN struct Options options
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, bke::FileHandlerType *)
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
void usd_file_handler_add()
bool mode_set(bContext *C, eObjectMode mode)
bool USD_import(bContext *C, const char *filepath, const USDImportParams *params, bool as_background_job, ReportList *reports)
bool USD_export(const bContext *C, const char *filepath, const USDExportParams *params, bool as_background_job, ReportList *reports)
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)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
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)
void WM_OT_usd_export(wmOperatorType *ot)
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_report(ReportList *reports, eReportType type, const char *message)
const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]
@ MOD_TRIANGULATE_NGON_BEAUTY
Object * CTX_data_edit_object(const bContext *C)
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MeshSeqCacheModifierReadFlag
@ MOD_MESHSEQ_READ_ATTRIBUTES
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)
bool WM_operator_winactive(bContext *C)
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
SpaceFile * CTX_wm_space_file(const bContext *C)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]
void WM_OT_usd_import(wmOperatorType *ot)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
const EnumPropertyItem io_transform_axis[]
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)
bool BLI_path_extension_check_n(const char *path,...) ATTR_NONNULL(1) ATTR_SENTINEL(0)
float RNA_float_get(PointerRNA *ptr, const char *name)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void use_property_split_set(bool is_sep)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
Layout & column(bool align)