### Generate VRM Character and Export to File Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Automates the steps in Create Humanoid VRM and exports it as a VRM. Initializes the add-on if running as a module, creates an armature with humanoid bones, and exports. ```python from pathlib import Path import bpy # Initialize if bpy.app.module: bpy.ops.preferences.addon_enable(module="io_scene_vrm") # Create an armature armature_data = bpy.data.armatures.new("Armature") armature_object = bpy.data.objects.new("Armature", armature_data) bpy.context.scene.collection.objects.link(armature_object) bpy.context.view_layer.objects.active = armature_object bpy.ops.object.mode_set(mode="EDIT") hips_bone = armature_data.edit_bones.new("hips") hips_bone.head = (0, 0, 0.5) hips_bone.tail = (0, 1, 0.5) hips_bone_name = hips_bone.name right_upper_leg_bone = armature_data.edit_bones.new("upper_leg.R") right_upper_leg_bone.head = (-0.125, 0, 0.5) right_upper_leg_bone.tail = (-0.125, 1, 0.5) right_upper_leg_bone.parent = hips_bone right_upper_leg_bone_name = right_upper_leg_bone.name right_lower_leg_bone = armature_data.edit_bones.new("lower_leg.R") right_lower_leg_bone.head = (-0.125, 0, 0.25) right_lower_leg_bone.tail = (-0.125, 1, 0.25) right_lower_leg_bone.parent = right_upper_leg_bone right_lower_leg_bone_name = right_lower_leg_bone.name right_foot_bone = armature_data.edit_bones.new("foot.R") right_foot_bone.head = (-0.125, 0, 0) right_foot_bone.tail = (-0.125, 1, 0) right_foot_bone.parent = right_lower_leg_bone right_foot_bone_name = right_foot_bone.name left_upper_leg_bone = armature_data.edit_bones.new("upper_leg.L") left_upper_leg_bone.head = (0.125, 0, 0.5) left_upper_leg_bone.tail = (0.125, 1, 0.5) left_upper_leg_bone.parent = hips_bone left_upper_leg_bone_name = left_upper_leg_bone.name left_lower_leg_bone = armature_data.edit_bones.new("lower_leg.L") left_lower_leg_bone.head = (0.125, 0, 0.25) left_lower_leg_bone.tail = (0.125, 1, 0.25) left_lower_leg_bone.parent = left_upper_leg_bone left_lower_leg_bone_name = left_lower_leg_bone.name left_foot_bone = armature_data.edit_bones.new("foot.L") left_foot_bone.head = (0.125, 0, 0) left_foot_bone.tail = (0.125, 1, 0) left_foot_bone.parent = left_lower_leg_bone left_foot_bone_name = left_foot_bone.name spine_bone = armature_data.edit_bones.new("spine") spine_bone.head = (0, 0, 0.625) spine_bone.tail = (0, 1, 0.625) spine_bone.parent = hips_bone spine_bone_name = spine_bone.name right_upper_arm_bone = armature_data.edit_bones.new("upper_arm.R") right_upper_arm_bone.head = (-0.125, 0, 0.75) right_upper_arm_bone.tail = (-0.125, 1, 0.75) right_upper_arm_bone.parent = spine_bone right_upper_arm_bone_name = right_upper_arm_bone.name right_lower_arm_bone = armature_data.edit_bones.new("lower_arm.R") right_lower_arm_bone.head = (-0.25, 0, 0.75) right_lower_arm_bone.tail = (-0.25, 1, 0.75) right_lower_arm_bone.parent = right_upper_arm_bone right_lower_arm_bone_name = right_lower_arm_bone.name right_hand_bone = armature_data.edit_bones.new("hand.R") right_hand_bone.head = (-0.375, 0, 0.75) right_hand_bone.tail = (-0.375, 1, 0.75) right_hand_bone.parent = right_lower_arm_bone right_hand_bone_name = right_hand_bone.name left_upper_arm_bone = armature_data.edit_bones.new("upper_arm.L") left_upper_arm_bone.head = (0.125, 0, 0.75) left_upper_arm_bone.tail = (0.125, 1, 0.75) left_upper_arm_bone.parent = spine_bone left_upper_arm_bone_name = left_upper_arm_bone.name left_lower_arm_bone = armature_data.edit_bones.new("lower_arm.L") left_lower_arm_bone.head = (0.25, 0, 0.75) left_lower_arm_bone.tail = (0.25, 1, 0.75) left_lower_arm_bone.parent = left_upper_arm_bone left_lower_arm_bone_name = left_lower_arm_bone.name left_hand_bone = armature_data.edit_bones.new("hand.L") left_hand_bone.head = (0.375, 0, 0.75) left_hand_bone.tail = (0.375, 1, 0.75) left_hand_bone.parent = left_lower_arm_bone left_hand_bone_name = left_hand_bone.name head_bone = armature_data.edit_bones.new("head") head_bone.head = (0, 0, 0.75) head_bone.tail = (0, 1, 0.75) head_bone.parent = spine_bone head_bone_name = head_bone.name bpy.ops.object.mode_set(mode="OBJECT") # Assign VRM human bones ``` -------------------------------- ### VRM MToon Material Settings Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Demonstrates how to create a new MToon material and configure its properties, including textures, shading, and outline settings, using the add-on's scripting API. ```APIDOC ## VRM MToon Material Settings ### Description This script creates a new MToon material and configures its various properties such as base color, textures, alpha mode, and outline settings. ### Method Python script (Blender API) ### Usage Run in Blender's Scripting workspace or as a script. ### Code Example ```python import bpy context = bpy.context image = context.blend_data.images.new(name="New Image", width=32, height=32) material = context.blend_data.materials.new("New MToon Material") material.vrm_addon_extension.mtoon1.enabled = True gltf = material.vrm_addon_extension.mtoon1 gltf.pbr_metallic_roughness.base_color_factor = (0, 1, 0, 1) gltf.pbr_metallic_roughness.base_color_texture.index.source = image # Similar settings can be made for textures other than "base_color_texture" gltf.pbr_metallic_roughness.base_color_texture.index.sampler.mag_filter = ( "NEAREST" # or "LINEAR" ) gltf.pbr_metallic_roughness.base_color_texture.index.sampler.min_filter = "NEAREST" # or "LINEAR", "NEAREST_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", "NEAREST_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR" gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_s = ( "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT" ) gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_t = ( "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT" ) gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.offset = ( 0, 0, ) gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.scale = ( 1, 1, ) gltf.alpha_mode = "OPAQUE" # or "MASK", "BLEND" gltf.double_sided = False gltf.alpha_cutoff = 0.5 gltf.normal_texture.index.source = image gltf.normal_texture.scale = 1 gltf.emissive_texture.index.source = image gltf.emissive_factor = (0, 0, 0) gltf.extensions.khr_materials_emissive_strength.emissive_strength = 1.0 mtoon = gltf.extensions.vrmc_materials_mtoon mtoon.transparent_with_z_write = False mtoon.render_queue_offset_number = 0 mtoon.shade_multiply_texture.index.source = image mtoon.shade_color_factor = (0, 0, 1) mtoon.shading_shift_texture.index.source = image mtoon.shading_shift_texture.scale = 1 mtoon.shading_shift_factor = 0 mtoon.shading_toony_factor = 0 mtoon.gi_equalization_factor = 0 mtoon.matcap_factor = (1, 1, 1) mtoon.matcap_texture.index.source = image mtoon.parametric_rim_color_factor = (0, 0, 0) mtoon.rim_multiply_texture.index.source = image mtoon.rim_lighting_mix_factor = 0 mtoon.parametric_rim_fresnel_power_factor = 1.0 mtoon.parametric_rim_lift_factor = 1.0 mtoon.outline_width_mode = "worldCoordinates" # or "none", "screenCoordinates" mtoon.outline_width_factor = 0.01 mtoon.outline_width_multiply_texture.index.source = image mtoon.outline_color_factor = (0, 0, 0) mtoon.outline_lighting_mix_factor = 0 mtoon.uv_animation_mask_texture.index.source = image mtoon.uv_animation_scroll_x_speed_factor = 0 mtoon.uv_animation_scroll_y_speed_factor = 0 mtoon.uv_animation_rotation_speed_factor = 0 ``` ### Notes - The script enables the MToon extension on the material. - Various texture properties are set to the same image for demonstration. - The `mtoon` object provides access to MToon-specific settings. ``` -------------------------------- ### Create development link for Blender 4.1.1 or earlier on Linux Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a symbolic link from the repository's src/io_scene_vrm folder to Blender's scripts/addons directory for Blender 4.1.1 or earlier on Linux. ```sh blender_version=3.6 mkdir -p "$HOME/.config/blender/$blender_version/scripts/addons" ln -Ts "$PWD/src/io_scene_vrm" "$HOME/.config/blender/$blender_version/scripts/addons/io_scene_vrm" ``` -------------------------------- ### Create development link for Blender 4.1.1 or earlier on Windows PowerShell Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a directory junction from the repository's src/io_scene_vrm folder to Blender's scripts/addons directory for Blender 4.1.1 or earlier on Windows PowerShell. ```powershell $blenderVersion = "3.6" New-Item -ItemType Directory -Path "$Env:APPDATA\Blender Foundation\Blender\$blenderVersion\scripts\addons" -Force New-Item -ItemType Junction -Path "$Env:APPDATA\Blender Foundation\Blender\$blenderVersion\scripts\addons\io_scene_vrm" -Value "$(Get-Location)\src\io_scene_vrm" ``` -------------------------------- ### Import VRM file using bpy.ops.import_scene.vrm Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Imports a VRM model from a file path. Raises an exception if the import operation does not return {"FINISHED"}. ```python import bpy result = bpy.ops.import_scene.vrm(filepath="path_to_your_vrm_model.vrm") if result != {"FINISHED"}: raise Exception(f"Failed to import vrm: {result}") ``` -------------------------------- ### Export VRM file using bpy.ops.export_scene.vrm Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Exports the current scene as a VRM file to the user's home directory. Raises an exception if the export operation does not return {"FINISHED"} and prints the output filepath. ```python import bpy from pathlib import Path output_filepath = str(Path.home() / "path_to_your_new_vrm_model.vrm") result = bpy.ops.export_scene.vrm(filepath=output_filepath) if result != {"FINISHED"}: raise Exception(f"Failed to export vrm: {result}") print(f"{output_filepath=}") ``` -------------------------------- ### VRM Human Bone Settings Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Demonstrates how to create an armature, add bones, and assign them to VRM 1.0 humanoid bone slots using the add-on's scripting API. ```APIDOC ## VRM Human Bone Settings ### Description This script creates an armature, adds hips and spine bones, and assigns them to the VRM 1.0 humanoid bone slots using the add-on's extension properties. ### Method Python script (Blender API) ### Usage Run in Blender's Scripting workspace or as a script. ### Code Example ```python import bpy context = bpy.context bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0)) armature = context.object armature.data.vrm_addon_extension.spec_version = "1.0" bpy.ops.object.mode_set(mode="EDIT") hips_bone = armature.data.edit_bones.new("hips") hips_bone.head = (0, 0, 0.5) hips_bone.tail = (0, 0, 0.75) spine_bone = armature.data.edit_bones.new("spine") spine_bone.parent = hips_bone spine_bone.head = (0, 0, 0.75) spine_bone.tail = (0, 0, 1) bpy.ops.object.mode_set(mode="OBJECT") armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.hips.node.bone_name = "hips" armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.spine.node.bone_name = ( "spine" ) ``` ### Notes - The script sets the VRM specification version to "1.0". - Bones are created in Edit Mode and assigned in Object Mode. - The `bone_name` property is used to link the bone to the VRM humanoid slot. ``` -------------------------------- ### Create development link for Blender 4.2+ on Linux Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a symbolic link from the repository's src/io_scene_vrm folder to Blender's extensions/user_default directory for Blender 4.2 or later on Linux. Uses a junction for Windows, but this is the Linux variant. ```sh blender_version=4.5 mkdir -p "$HOME/.config/blender/$blender_version/extensions/user_default" ln -Ts "$PWD/src/io_scene_vrm" "$HOME/.config/blender/$blender_version/extensions/user_default/vrm" ``` -------------------------------- ### Create development link for Blender 4.2+ on Windows PowerShell Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a directory junction from the repository's src/io_scene_vrm folder to Blender's extensions/user_default directory for Blender 4.2 or later on Windows PowerShell. ```powershell $blenderVersion = "4.5" New-Item -ItemType Directory -Path "$Env:APPDATA\Blender Foundation\Blender\$blenderVersion\extensions\user_default" -Force New-Item -ItemType Junction -Path "$Env:APPDATA\Blender Foundation\Blender\$blenderVersion\extensions\user_default\vrm" -Value "$(Get-Location)\src\io_scene_vrm" ``` -------------------------------- ### Create development link for Blender 4.1.1 or earlier on macOS Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a symbolic link from the repository's src/io_scene_vrm folder to Blender's scripts/addons directory for Blender 4.1.1 or earlier on macOS. ```sh blender_version=3.6 mkdir -p "$HOME/Library/Application Support/Blender/$blender_version/scripts/addons" ln -s "$PWD/src/io_scene_vrm" "$HOME/Library/Application Support/Blender/$blender_version/scripts/addons/io_scene_vrm" ``` -------------------------------- ### Configure VRM MToon Material Settings Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Creates a new MToon material, enables it, and sets a wide range of properties including base color, textures, alpha mode, double-sided, emissive, and MToon-specific parameters. Use this to programmatically configure a VRM 1.0 MToon material. ```python import bpy context = bpy.context image = context.blend_data.images.new(name="New Image", width=32, height=32) material = context.blend_data.materials.new("New MToon Material") material.vrm_addon_extension.mtoon1.enabled = True gltf = material.vrm_addon_extension.mtoon1 gltf.pbr_metallic_roughness.base_color_factor = (0, 1, 0, 1) gltf.pbr_metallic_roughness.base_color_texture.index.source = image # Similar settings can be made for textures other than "base_color_texture" gltf.pbr_metallic_roughness.base_color_texture.index.sampler.mag_filter = ( "NEAREST" # or "LINEAR" ) gltf.pbr_metallic_roughness.base_color_texture.index.sampler.min_filter = "NEAREST" # or "LINEAR", "NEAREST_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", "NEAREST_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR" gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_s = ( "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT" ) gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_t = ( "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT" ) gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.offset = ( 0, 0, ) gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.scale = ( 1, 1, ) gltf.alpha_mode = "OPAQUE" # or "MASK", "BLEND" gltf.double_sided = False gltf.alpha_cutoff = 0.5 gltf.normal_texture.index.source = image gltf.normal_texture.scale = 1 gltf.emissive_texture.index.source = image gltf.emissive_factor = (0, 0, 0) gltf.extensions.khr_materials_emissive_strength.emissive_strength = 1.0 mtoon = gltf.extensions.vrmc_materials_mtoon mtoon.transparent_with_z_write = False mtoon.render_queue_offset_number = 0 mtoon.shade_multiply_texture.index.source = image mtoon.shade_color_factor = (0, 0, 1) mtoon.shading_shift_texture.index.source = image mtoon.shading_shift_texture.scale = 1 mtoon.shading_shift_factor = 0 mtoon.shading_toony_factor = 0 mtoon.gi_equalization_factor = 0 mtoon.matcap_factor = (1, 1, 1) mtoon.matcap_texture.index.source = image mtoon.parametric_rim_color_factor = (0, 0, 0) mtoon.rim_multiply_texture.index.source = image mtoon.rim_lighting_mix_factor = 0 mtoon.parametric_rim_fresnel_power_factor = 1.0 mtoon.parametric_rim_lift_factor = 1.0 mtoon.outline_width_mode = "worldCoordinates" # or "none", "screenCoordinates" mtoon.outline_width_factor = 0.01 mtoon.outline_width_multiply_texture.index.source = image mtoon.outline_color_factor = (0, 0, 0) mtoon.outline_lighting_mix_factor = 0 mtoon.uv_animation_mask_texture.index.source = image mtoon.uv_animation_scroll_x_speed_factor = 0 mtoon.uv_animation_scroll_y_speed_factor = 0 mtoon.uv_animation_rotation_speed_factor = 0 ``` -------------------------------- ### Set VRM Metadata and Export to File Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Sets the VRM metadata (name and version) and exports the model to a .vrm file using bpy.ops.export_scene.vrm. Raises an error if the export fails and prints the output file path on success. ```python # Set metadata meta = armature_data.vrm_addon_extension.vrm1.meta meta.vrm_name = "Your Model Name" meta.version = "1.0.0" # Save to a file output_filepath = str(Path(__file__).parent / "path_to_your_vrm_model.vrm") result = bpy.ops.export_scene.vrm(filepath=output_filepath) if result != {"FINISHED"}: message = f"Failed to export vrm: {result}" raise RuntimeError(message) print(f'Saved the VRM file to "{output_filepath}"') ``` -------------------------------- ### Create development link for Blender 4.2+ on macOS Source: https://vrm-addon-for-blender.info/en-us/development/ Creates a symbolic link from the repository's src/io_scene_vrm folder to Blender's extensions/user_default directory for Blender 4.2 or later on macOS. ```sh blender_version=4.5 mkdir -p "$HOME/Library/Application Support/Blender/$blender_version/extensions/user_default" ln -s "$PWD/src/io_scene_vrm" "$HOME/Library/Application Support/Blender/$blender_version/extensions/user_default/vrm" ``` -------------------------------- ### Build Release Output Source: https://vrm-addon-for-blender.info/en-us/development/ Expected output after running ./tools/build_release.sh, indicating a successful build. It shows the paths to the generated zip files for Blender 4.2 or later and Blender 2.93 - 4.1. ```text | | Release Build Completed | | - Blender 4.2 or later: | /workspace/release_output/VRM_Addon_for_Blender-Extension-0_0_0.zip | | - Blender 2.93 - 4.1: | /workspace/release_output/VRM_Addon_for_Blender-0_0_0.zip | ``` -------------------------------- ### Set VRM 1.0 metadata on an armature Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Creates an armature and configures VRM 1.0 metadata fields such as name, version, authors, permissions, and usage restrictions. Comments indicate allowed values for several fields. ```python import bpy context = bpy.context bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0)) armature = context.object armature.data.vrm_addon_extension.spec_version = "1.0" meta = armature.data.vrm_addon_extension.vrm1.meta meta.vrm_name = "Your Model Name" meta.version = "1.0.0" meta.authors.add().value = "Author 1" meta.copyright_information = "Copyright Information" meta.contact_information = "Contact Information" meta.references.add().value = "https://example.com" meta.third_party_licenses = "Third Party Licenses" thumbnail_image = context.blend_data.images.new(name="New Image", width=32, height=32) meta.thumbnail_image = thumbnail_image meta.avatar_permission = "onlyAuthor" # or "onlySeparatelyLicensedPerson", "everyone" meta.allow_excessively_violent_usage = False meta.allow_excessively_sexual_usage = False meta.commercial_usage = "personalNonProfit" # or "personalProfit", "corporation" meta.allow_political_or_religious_usage = False meta.allow_antisocial_or_hate_usage = False meta.credit_notation = "required" # or "unnecessary" meta.allow_redistribution = False meta.modification = ( "prohibited" # or "allowModification", "allowModificationRedistribution" ) meta.other_license_url = "" ``` -------------------------------- ### Set VRM 1.0 Human Bone Settings (hips and spine) Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Creates an armature, sets its spec_version to "1.0", adds hips and spine edit bones, and assigns them to the VRM humanoid human_bones nodes. Use this to programmatically define the required human bones for a VRM 1.0 model. ```python import bpy context = bpy.context bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0)) armature = context.object armature.data.vrm_addon_extension.spec_version = "1.0" bpy.ops.object.mode_set(mode="EDIT") hips_bone = armature.data.edit_bones.new("hips") hips_bone.head = (0, 0, 0.5) hips_bone.tail = (0, 0, 0.75) spine_bone = armature.data.edit_bones.new("spine") spine_bone.parent = hips_bone spine_bone.head = (0, 0, 0.75) spine_bone.tail = (0, 0, 1) bpy.ops.object.mode_set(mode="OBJECT") armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.hips.node.bone_name = "hips" armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.spine.node.bone_name = ( "spine" ) ``` -------------------------------- ### Add Meshes and Parent to Armature Bones Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Creates primitive meshes (sphere, cube, ico sphere) and parents each to the corresponding armature bone using the parent_bone property. This step visually represents the VRM character's body parts. ```python # Add meshes bpy.ops.mesh.primitive_uv_sphere_add(radius=0.25) head = bpy.context.active_object head.parent = armature_object head.parent_bone = humanoid.human_bones.head.node.bone_name head.parent_type = "BONE" bpy.ops.mesh.primitive_cube_add(size=0.4) spine = bpy.context.active_object spine.parent = armature_object spine.parent_bone = humanoid.human_bones.spine.node.bone_name spine.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) left_upper_arm = bpy.context.active_object left_upper_arm.parent = armature_object left_upper_arm.parent_bone = humanoid.human_bones.left_upper_arm.node.bone_name left_upper_arm.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) left_hand = bpy.context.active_object left_hand.parent = armature_object left_hand.parent_bone = humanoid.human_bones.left_hand.node.bone_name left_hand.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) right_upper_arm = bpy.context.active_object right_upper_arm.parent = armature_object right_upper_arm.parent_bone = humanoid.human_bones.right_upper_arm.node.bone_name right_upper_arm.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) right_hand = bpy.context.active_object right_hand.parent = armature_object right_hand.parent_bone = humanoid.human_bones.right_hand.node.bone_name right_hand.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) left_upper_leg = bpy.context.active_object left_upper_leg.parent = armature_object left_upper_leg.parent_bone = humanoid.human_bones.left_upper_leg.node.bone_name left_upper_leg.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) right_upper_leg = bpy.context.active_object right_upper_leg.parent = armature_object right_upper_leg.parent_bone = humanoid.human_bones.right_upper_leg.node.bone_name right_upper_leg.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) left_lower_leg = bpy.context.active_object left_lower_leg.parent = armature_object left_lower_leg.parent_bone = humanoid.human_bones.left_lower_leg.node.bone_name left_lower_leg.parent_type = "BONE" bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1) right_lower_leg = bpy.context.active_object right_lower_leg.parent = armature_object right_lower_leg.parent_bone = humanoid.human_bones.right_lower_leg.node.bone_name right_lower_leg.parent_type = "BONE" ``` -------------------------------- ### Importing VRM files Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Imports a VRM model from a file path using the Blender operator bpy.ops.import_scene.vrm. The result is checked to ensure the operation finished successfully. ```APIDOC ## Importing VRM files ### Description Imports a VRM model from a file path using the Blender operator `bpy.ops.import_scene.vrm`. ### Method `bpy.ops.import_scene.vrm` ### Parameters - `filepath` (string) - Required - The path to the VRM file to import. ### Request Example ```python import bpy result = bpy.ops.import_scene.vrm(filepath="path_to_your_vrm_model.vrm") if result != {"FINISHED"}: raise Exception(f"Failed to import vrm: {result}") ``` ### Response Returns a set indicating the operation result, e.g., `{"FINISHED"}` on success. ``` -------------------------------- ### Exporting VRM files Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Exports the current scene to a VRM file using the Blender operator bpy.ops.export_scene.vrm. The output file path is specified and the result is checked for success. ```APIDOC ## Exporting VRM files ### Description Exports the current scene to a VRM file using the Blender operator `bpy.ops.export_scene.vrm`. ### Method `bpy.ops.export_scene.vrm` ### Parameters - `filepath` (string) - Required - The output file path for the VRM file. ### Request Example ```python import bpy from pathlib import Path output_filepath = str(Path.home() / "path_to_your_new_vrm_model.vrm") result = bpy.ops.export_scene.vrm(filepath=output_filepath) if result != {"FINISHED"}: raise Exception(f"Failed to export vrm: {result}") print(f"{output_filepath=}") ``` ### Response Returns a set indicating the operation result, e.g., `{"FINISHED"}` on success. ``` -------------------------------- ### VRM Metadata Settings (VRM 1.0) Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Sets VRM 1.0 metadata on an armature object, including model name, version, authors, permissions, and usage restrictions. ```APIDOC ## VRM Metadata Settings (VRM 1.0) ### Description Sets VRM 1.0 metadata on an armature object, including model name, version, authors, permissions, and usage restrictions. ### Method Direct property assignment on `armature.data.vrm_addon_extension`. ### Parameters - `spec_version` (string) - Required - The VRM specification version, e.g., "1.0". - `vrm_name` (string) - Required - The model name. - `version` (string) - Required - The model version. - `authors` (collection) - Required - List of author names; use `.add().value` to append. - `copyright_information` (string) - Optional - Copyright information. - `contact_information` (string) - Optional - Contact information. - `references` (collection) - Optional - List of reference URLs; use `.add().value` to append. - `third_party_licenses` (string) - Optional - Third-party licenses. - `thumbnail_image` (image) - Optional - Thumbnail image. - `avatar_permission` (enum) - Required - One of "onlyAuthor", "onlySeparatelyLicensedPerson", "everyone". - `allow_excessively_violent_usage` (bool) - Required - Whether excessively violent usage is allowed. - `allow_excessively_sexual_usage` (bool) - Required - Whether excessively sexual usage is allowed. - `commercial_usage` (enum) - Required - One of "personalNonProfit", "personalProfit", "corporation". - `allow_political_or_religious_usage` (bool) - Required - Whether political or religious usage is allowed. - `allow_antisocial_or_hate_usage` (bool) - Required - Whether antisocial or hate usage is allowed. - `credit_notation` (enum) - Required - One of "required", "unnecessary". - `allow_redistribution` (bool) - Required - Whether redistribution is allowed. - `modification` (enum) - Required - One of "prohibited", "allowModification", "allowModificationRedistribution". - `other_license_url` (string) - Optional - URL to other license. ### Request Example ```python import bpy context = bpy.context bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0)) armature = context.object armature.data.vrm_addon_extension.spec_version = "1.0" meta = armature.data.vrm_addon_extension.vrm1.meta meta.vrm_name = "Your Model Name" meta.version = "1.0.0" meta.authors.add().value = "Author 1" meta.copyright_information = "Copyright Information" meta.contact_information = "Contact Information" meta.references.add().value = "https://example.com" meta.third_party_licenses = "Third Party Licenses" thumbnail_image = context.blend_data.images.new(name="New Image", width=32, height=32) meta.thumbnail_image = thumbnail_image meta.avatar_permission = "onlyAuthor" # or "onlySeparatelyLicensedPerson", "everyone" meta.allow_excessively_violent_usage = False meta.allow_excessively_sexual_usage = False meta.commercial_usage = "personalNonProfit" # or "personalProfit", "corporation" meta.allow_political_or_religious_usage = False meta.allow_antisocial_or_hate_usage = False meta.credit_notation = "required" # or "unnecessary" meta.allow_redistribution = False meta.modification = ( "prohibited" # or "allowModification", "allowModificationRedistribution" ) meta.other_license_url = "" ``` ### Response No explicit response; the properties are set directly on the object. ``` -------------------------------- ### Set VRM Humanoid Bone Assignments Source: https://vrm-addon-for-blender.info/en-us/scripting-api/ Assigns bone names to the VRM humanoid's required bones (head, spine, hips, arms, hands, legs, feet) via the vrm_addon_extension.vrm1.humanoid API. This is the first step in generating a VRM character dynamically. ```python humanoid = armature_data.vrm_addon_extension.vrm1.humanoid humanoid.human_bones.head.node.bone_name = head_bone_name humanoid.human_bones.spine.node.bone_name = spine_bone_name humanoid.human_bones.hips.node.bone_name = hips_bone_name humanoid.human_bones.right_upper_arm.node.bone_name = right_upper_arm_bone_name humanoid.human_bones.right_lower_arm.node.bone_name = right_lower_arm_bone_name humanoid.human_bones.right_hand.node.bone_name = right_hand_bone_name humanoid.human_bones.left_upper_arm.node.bone_name = left_upper_arm_bone_name humanoid.human_bones.left_lower_arm.node.bone_name = left_lower_arm_bone_name humanoid.human_bones.left_hand.node.bone_name = left_hand_bone_name humanoid.human_bones.right_upper_leg.node.bone_name = right_upper_leg_bone_name humanoid.human_bones.right_lower_leg.node.bone_name = right_lower_leg_bone_name humanoid.human_bones.right_foot.node.bone_name = right_foot_bone_name humanoid.human_bones.left_upper_leg.node.bone_name = left_upper_leg_bone_name humanoid.human_bones.left_lower_leg.node.bone_name = left_lower_leg_bone_name humanoid.human_bones.left_foot.node.bone_name = left_foot_bone_name ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.