### Manage Asset Packs Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/assetservice.md This example shows how to check if the system assets pack is installed and how to list all available asset packs along with the number of assets they contain. ```python from mpfb.services.assetservice import AssetService # Check if system assets are installed if AssetService.system_assets_pack_is_installed(): print("System assets are available") # List all packs and their contents for pack_name in AssetService.get_pack_names(): assets = AssetService.get_asset_names_in_pack(pack_name) print(f"Pack '{pack_name}': {len(assets)} assets") ``` -------------------------------- ### Target File Header Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/target.md This is an example of the header section in a target file. Lines starting with '#' are comments and are ignored during parsing. ```text # This is a target file for MakeHuman # # It was written by the MakeTarget submodule of MPFB # # For more information, see MakeHuman's home page at http://www.makehumancommunity.org # # basemesh hm08 ``` -------------------------------- ### Target File Vertex Data Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/target.md This example demonstrates the structure of vertex data lines in a target file. Each line specifies the vertex index and its X, Z, and Y axis displacements. Note that the Y-axis is sign-inverted. ```text # This is a target file for MakeHuman # # It was written by the MakeTarget submodule of MPFB # # For more information, see MakeHuman's home page at http://www.makehumancommunity.org # # basemesh hm08 293 -0.0102 0.0087 0.0269 294 -0.0 0.0081 0.0296 296 -0.0086 -0.008 0.0311 297 -0.0 -0.0094 0.0331 5052 -0.0098 0.0004 0.0304 5054 -0.0 -0.0008 0.0328 7061 0.0102 0.0087 0.0269 7063 0.0086 -0.008 0.0311 11670 0.0098 0.0004 0.0304 ``` -------------------------------- ### Example MHMat Material Definition Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/mhmat.md This example demonstrates a complete MHMat file, including metadata, color, texture, intensity, SSS, various material properties, and shader configurations for MakeHuman's viewport. ```mhmat # This is a material for MakeHuman or MPFB // Metadata name My Skin Material description A realistic skin material uuid 59985471-ab08-479f-a32d-2d88411714ef license CC0 author John Doe tag skin tag realistic // Color diffuseColor 0.7210 0.5680 0.4310 specularColor 0.5000 0.5000 0.5000 // Texture diffuseTexture diffuse_skin.png normalmapTexture normalmap_skin.png roughnessmapTexture roughness_skin.png // Intensity diffuseIntensity 1.0000 normalmapIntensity 0.8000 // SSS sssEnabled true sssRScale 0.1000 sssGScale 0.1000 sssBScale 0.1000 // Various metallic 0.0000 roughness 0.5000 shininess 0.3000 opacity 1.0000 ior 1.4500 transparent false backfaceCull true castShadows true receiveShadows true // Shader (MakeHuman viewport only) shader shaders/glsl/litsphere shaderParam litsphereTexture litspheres/lit_leather.png ``` -------------------------------- ### Importer Preset Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/misc_presets.md Stores UI settings for the MakeHuman import workflow. Absent keys use their defaults. ```json { "import_body": true, "import_body_parts": true, "import_clothes": true, "import_rig": true, "scale_factor": "METER", "feet_on_ground": true, "handle_helpers": "HIDE", "skin_material_type": "ENHANCED", "procedural_eyes": true } ``` -------------------------------- ### Create and Setup Rig Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/rigservice.md Demonstrates how to create a rig from skeleton data, ensure an armature modifier is present on a base mesh, and identify the rig type. ```python from mpfb.services.rigservice import RigService # Create a rig from skeleton data armature = RigService.create_rig_from_skeleton_info( "MyRig", skeleton_data, parent=basemesh, scale=0.1 ) # Add armature modifier to the basemesh RigService.ensure_armature_modifier(basemesh, armature) # Identify the rig type rig_type = RigService.identify_rig(armature) print(f"Rig type: {rig_type}") ``` -------------------------------- ### Basic Connection Setup and Directory Info Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Configure the host and port for the SocketService connection if not using defaults. Then, retrieve user and system directory paths. ```python from mpfb.services.socketservice import SocketService # Configure connection (if not using defaults) SocketService.set_host("127.0.0.1") SocketService.set_port(12345) # Get directory information user_dir = SocketService.get_user_dir() sys_dir = SocketService.get_sys_dir() print(f"MakeHuman user dir: {user_dir}") print(f"MakeHuman system dir: {sys_dir}") ``` -------------------------------- ### List Installed Asset Packs and Asset Counts Source: https://github.com/makehumancommunity/mpfb2/blob/master/script_samples/index.md Use AssetService to get a list of all installed asset packs and the number of assets each pack contains. This is useful for understanding the available content and its organization. ```python from mpfb2.asset import AssetService asset_service = AssetService() asset_service.rescan_pack_metadata() if asset_service.have_any_pack_meta_data(): for pack_name in asset_service.get_pack_names(): asset_count = len(asset_service.get_asset_names_in_pack(pack_name)) print(f"Pack: {pack_name}, Assets: {asset_count}") else: print("No asset packs found.") ``` -------------------------------- ### Check Hair and Fur Asset Installation Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/haireditorservice.md Use these methods to verify if hair or fur assets are installed before attempting to use them. This prevents errors when accessing asset paths. ```python if HairEditorService.is_hair_asset_installed(): hair_path = HairEditorService.get_hair_blend_path() print(f"Hair blend file: {hair_path}") if HairEditorService.is_fur_asset_installed(): fur_path = HairEditorService.get_fur_blend_path() print(f"Fur blend file: {fur_path}") ``` -------------------------------- ### MHCLO File Structure Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/mhclo.md This example demonstrates the typical structure of an MHCLO file, including header comments, basic metadata, scale references, display properties, vertex mapping, and vertex deletion sections. ```plaintext # MHCLO asset for MakeHuman and MPFB # author: John Doe # license: CC0 basemesh hm08 name shirt uuid 59985471-ab08-479f-a32d-2d88411714ef obj_file shirt.obj material shirt.mhmat x_scale 5399 11998 1.4340 y_scale 791 881 2.4098 z_scale 962 5320 2.0001 z_depth 50 max_pole 4 verts 0 1234 5678 5679 5680 0.5000 0.3000 0.2000 0.0100 -0.0050 0.0020 ... delete_verts 100 - 150 200 - 250 ``` -------------------------------- ### Create a Simple Material Node Tree Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/nodeservice.md Demonstrates creating a basic material with a Principled BSDF shader and connecting it to the output. Clears existing nodes before setup. ```python from mpfb.services.nodeservice import NodeService import bpy # Create a new material material = bpy.data.materials.new("MyMaterial") material.use_nodes = True node_tree = material.node_tree # Clear default nodes NodeService.clear_node_tree(node_tree) # Create nodes output = NodeService.create_node(node_tree, "ShaderNodeOutputMaterial", xpos=300) principled = NodeService.create_principled_node(node_tree, xpos=0, ypos=0) # Connect them NodeService.add_link(node_tree, principled, output, "BSDF", "Surface") ``` -------------------------------- ### Basic timing block example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/primitiveprofiler.md Demonstrates how to use PrimitiveProfiler to time a single code section. ```APIDOC ## Basic timing block ```python from mpfb.entities.primitiveprofiler import PrimitiveProfiler profiler = PrimitiveProfiler("my_profiler") profiler.enter("expensive_step") # ... code being timed ... profiler.leave("expensive_step") profiler.dump() # Example output: # expensive_step count=1 total=0.0321 min=0.0321 max=0.0321 avg=0.0321 ``` ``` -------------------------------- ### Multiple sections, same profiler example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/primitiveprofiler.md Shows how to use the same profiler instance to time multiple different code sections. ```APIDOC ## Multiple sections, same profiler ```python from mpfb.entities.primitiveprofiler import PrimitiveProfiler profiler = PrimitiveProfiler("build_stages") for i in range(10): profiler.enter("stage_a") # ... stage A work ... profiler.leave("stage_a") profiler.enter("stage_b") # ... stage B work ... profiler.leave("stage_b") profiler.dump() # Prints one line per section with count=10 and aggregated statistics ``` ``` -------------------------------- ### Setup Hair Operator Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/ui/operators_reference.md Sets up hair for the mesh. This operator is MPFB_OT_SetupHair_Operator. ```APIDOC ## mpfb.setup_hair_operator ### Description Set up hair for the mesh. ### Method (Not specified, likely a Python call) ### Endpoint (Not applicable, Python operator) ### Parameters (Not specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Makeup Preset Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/misc_presets.md Stores a list of ink layers to apply. Each string is the filename of an ink layer JSON file. ```json [ "eye_shadow.json", "lip_color.json" ] ``` -------------------------------- ### as_dict Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/configurationset.md Get settings as a dictionary, applying overrides from a template JSON file. ```APIDOC ## as_dict(entity_reference=None, exclude_keys=None, json_with_overrides=None) ### Description Get settings as a dictionary, applying overrides from a template JSON file. ### Parameters #### Path Parameters - **entity_reference** (any) - Optional - Context-specific reference for setting values - **exclude_keys** (list[str]) - Optional - List of keys to exclude from the dictionary - **json_with_overrides** (str) - Optional - Path to a JSON file to use for overrides ``` -------------------------------- ### Example target.json Section Structure Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/target_metadata.md Illustrates the structure of a section within the `target.json` file, detailing categories, left/right flags, and target names. ```json { "arms": { "label": "Arms", "include_per_default": true, "categories": [ { "name": "lowerarm-scale-depth-decr-incr", "label": "lowerarm-scale-depth-decr-incr", "has_left_and_right": true, "opposites": { "negative-left": "l-lowerarm-scale-depth-decr", "negative-right": "r-lowerarm-scale-depth-decr", "negative-unsided": "", "positive-left": "l-lowerarm-scale-depth-incr", "positive-right": "r-lowerarm-scale-depth-incr", "positive-unsided": "" }, "targets": [ "l-lowerarm-scale-depth-decr", "r-lowerarm-scale-depth-incr", "r-lowerarm-scale-depth-decr", "l-lowerarm-scale-depth-incr" ] } ], "unsorted": [] } } ``` -------------------------------- ### Example macro.json Combinations Structure Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/target_metadata.md Demonstrates the `combinations` object within `macro.json`, showing how macro attributes are grouped to define compound targets. ```json "combinations": { "racegenderage": ["race", "gender", "age"], "genderagemuscleweight": ["gender", "age", "muscle", "weight"], "genderagemuscleweightproportions": ["gender", "age", "muscle", "weight", "proportions"], "genderagemuscleweightheight": ["gender", "age", "muscle", "weight", "height"], "genderagemuscleweightcupsizefirmness": ["gender", "age", "muscle", "weight", "cupsize", "firmness"] } ``` -------------------------------- ### Use BlenderConfigSet to Manage Properties Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/blenderconfigset.md Demonstrates setting, getting, and checking for the existence of properties on a Blender entity using the BlenderConfigSet. ```python # Set a value config.set_value("detail_level", 5, entity_reference=bpy.context.scene) # Get a value level = config.get_value("detail_level", entity_reference=bpy.context.scene) # Check if property exists if config.has_key("use_smoothing"): smoothing = config.get_value("use_smoothing", entity_reference=bpy.context.scene) ``` -------------------------------- ### is_faceunits01_installed Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/faceservice.md Checks if the 'faceunits01' ARKit asset pack is installed. It can optionally force a recheck of the installation status, bypassing any cached results. ```APIDOC ## is_faceunits01_installed(force_recheck=False) ### Description Returns `True` if the `faceunits01` ARKit asset pack appears to be installed. The probe calls `TargetService.target_full_path("cheekPuff")` once per session and caches the result. Pass `force_recheck=True` to bust the cache. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters - **force_recheck** (`bool`) - Optional - Re-probe even if a cached result is available (Default: False) ### Returns `bool` - `True` if the pack is installed, `False` otherwise. ``` -------------------------------- ### mpfb.setup_sculpt Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/ui/operators_reference.md Sets up the mesh for sculpting. ```APIDOC ## mpfb.setup_sculpt ### Description Sets up the mesh for sculpting. ### Method Not specified (likely a Python function call). ### Endpoint Not applicable (Python function). ### Parameters None explicitly documented. ### Request Example None provided. ### Response None explicitly documented. ``` -------------------------------- ### Install Dev Dependencies Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/type-checking.md Installs Pyright and Blender stubs required for static type checking. Ensure you are using the correct requirements file. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Full MpfbOperator Subclass Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/ui/meta.md This example demonstrates a complete subclass of MpfbOperator, including overriding get_logger() and hardened_execute(), and registering the class. It utilizes a pollstrategy decorator. ```python from mpfb.ui.mpfboperator import MpfbOperator from mpfb.services import LogService, ClassManager from mpfb.ui.pollstrategy import pollstrategy, PollStrategy _LOG = LogService.get_logger("myfeature.myoperator") @pollstrategy(PollStrategy.BASEMESH_AMONGST_RELATIVES) class MPFB_OT_My_Operator(MpfbOperator): bl_idname = "mpfb.my_operator" bl_label = "Do Something" bl_description = "Performs some action on the active character" def get_logger(self): return _LOG def hardened_execute(self, context): _LOG.enter() # ... operator logic here ... self.report({'INFO'}, "Done") return {'FINISHED'} ClassManager.add_class(MPFB_OT_My_Operator) ``` -------------------------------- ### Create Input Socket with Properties Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/nodetreeservice.md Demonstrates creating an input socket and setting its default value, minimum, and maximum values. Use this when you need to define specific properties for a new input socket. ```python from mpfb.services.nodetreeservice import NodeTreeService import bpy # Get or create a node group node_tree = bpy.data.node_groups.get("MyNodeGroup") if not node_tree: node_tree = bpy.data.node_groups.new("MyNodeGroup", "ShaderNodeTree") # Check if a socket exists before creating if not NodeTreeService.has_input_socket(node_tree, "Factor"): socket = NodeTreeService.create_input_socket( node_tree, "Factor", "NodeSocketFloat" ) socket.default_value = 0.5 socket.min_value = 0.0 socket.max_value = 1.0 ``` -------------------------------- ### Check if Modern MakeHuman System Assets Installed Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/assetservice.md Checks if the MakeHuman system assets pack is installed and if it includes the `brown.mhmat` eye material, indicating a modern version. ```APIDOC ## check_if_modern_makehuman_system_assets_installed() ### Description Check whether the MakeHuman system assets pack is installed and whether it includes the `brown.mhmat` eye material (which indicates a modern version of the pack). ### Returns `tuple[bool, bool]` — `(system_assets_installed, brown_mhmat_installed)`. ``` -------------------------------- ### Example: Mark object as Clothes and set source Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/objectproperties.md Illustrates how to mark a newly created object as MPFB Clothes and record its source file path using the `set_value` method. ```APIDOC ## Example: Mark object as Clothes and set source ### Description Mark a newly created object as an MPFB Clothes object and record its source file: ### Code ```python from mpfb.entities.objectproperties import GeneralObjectProperties obj = bpy.context.active_object GeneralObjectProperties.set_value("object_type", "Clothes", entity_reference=obj) GeneralObjectProperties.set_value("asset_source", "/path/to/shirt.mhclo", entity_reference=obj) ``` ``` -------------------------------- ### Get Base Directories and Sub-Paths Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/locationservice.md Demonstrates how to retrieve essential base directories like user home, data, and configuration, and how to access specific files or subdirectories within them. ```python from mpfb.services.locationservice import LocationService # Get base directories user_home = LocationService.get_user_home() data_dir = LocationService.get_user_data() config_dir = LocationService.get_user_config() # Get paths within directories targets_path = LocationService.get_mpfb_data("targets") preset_path = LocationService.get_user_config("my_preset.json") cache_file = LocationService.get_user_cache("baked_normals.png") ``` -------------------------------- ### __init__(settings) Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/rigging/eyehelpers.md Initializes the EyeHelpers instance with a configuration dictionary. The 'eye_parenting_strategy' must be specified in the settings. ```APIDOC ## __init__(settings) ### Description Initialise the helper with a configuration dict. ### Arguments - **settings** (dict) - Must include `eye_parenting_strategy` (`"HEAD"` or `"ROOT"`) ``` -------------------------------- ### __init__ Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/rigging/rigifyhelpers.md Initialises the RigifyHelpers helper with a configuration dictionary. It extracts flags for producing the rig and handling the meta-rig action. ```APIDOC ## __init__ ### Description Initialise the helper with a configuration dict, extracting `produce` and `meta_rig_action` flags. ### Parameters #### Arguments - **settings** (dict) - May include `produce` (bool), `meta_rig_action` (str — `"keep"`, `"hide"` or `"delete"`; default `"hide"`), and `name` (str for the output rig name) ### Returns `RigifyHelpers` instance. ``` -------------------------------- ### List Installed Clothes Assets Source: https://github.com/makehumancommunity/mpfb2/blob/master/script_samples/index.md Retrieve a comprehensive list of all installed clothes assets using the AssetService. This pattern can be adapted for other asset types like eyes, hair, or skins by changing the asset subdirectory and type. ```python from mpfb2.asset import AssetService asset_service = AssetService() asset_service.update_asset_list(asset_subdir='clothes', asset_type='mhclo') clothes_assets = asset_service.get_asset_list(asset_subdir='clothes', asset_type='mhclo') if clothes_assets: print(f"Found {len(clothes_assets)} clothes assets:") for asset in clothes_assets: print(f"- {asset.name} ({asset.full_path})") else: print("No clothes assets found.") ``` -------------------------------- ### set_up_rigging Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/clothesservice.md Performs the full rigging pipeline for clothes, including weight interpolation, sub-rig setup, and custom weight application. It can also be configured to skip certain steps like sub-rig or custom weight import. ```APIDOC ## set_up_rigging(basemesh, clothes_obj, rig, mhclo, import_subrig=True, import_weights=True) ### Description Full rigging pipeline: weights, sub-rig, and custom weights. This function automates the process of preparing clothes for animation by applying rigging data. ### Parameters #### Path Parameters - **basemesh** (bpy.types.Object) - Required - The basemesh of the character. - **clothes_obj** (bpy.types.Object) - Required - The clothes mesh to rig. - **rig** (bpy.types.Object) - Required - The rig object to use for rigging. - **mhclo** (Mhclo) - Required - The MHCLO object containing rigging information. #### Query Parameters - **import_subrig** (bool) - Optional - Whether to import the sub-rig. Defaults to True. - **import_weights** (bool) - Optional - Whether to import weights. Defaults to True. ``` -------------------------------- ### MHM File Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/mhm.md This example demonstrates the structure of an MHM file, including version, name, camera settings, modifiers for body features, eyes, eyelashes, skeleton, skin material, clothes, and face hiding settings. ```plaintext version v1.2.0 name testchar camera 15.0 49.0 0.0 0.0 0.0 1.0 modifier head/head-square 0.422000 modifier breast/BreastSize 0.500000 modifier breast/BreastFirmness 0.500000 modifier macrodetails/Gender 1.000000 modifier macrodetails/Age 0.500000 modifier macrodetails/African 0.000000 modifier macrodetails/Asian 0.000000 modifier macrodetails/Caucasian 1.000000 modifier macrodetails-universal/Muscle 0.721000 modifier macrodetails-universal/Weight 0.361000 modifier macrodetails-height/Height 0.500000 modifier macrodetails-proportions/BodyProportions 0.653000 eyes High-poly 361c783e-0e8a-4a6e-a4e0-b3ef6cf7bbfd eyelashes Eyelashes01 49b6efab-7c46-4a7f-b7a6-49743a39e2a0 skeleton default.mhskel skinMaterial skins/young_caucasian_female/young_caucasian_female.mhmat clothes female_casualsuit01 8d0a6e81-4195-47fa-b235-0323e9cc862c clothes Sneakers02 0c11e4cb-5cb2-4951-ad2f-916e08fa9e27 clothesHideFaces True subdivide False ``` -------------------------------- ### set_up_rigging Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/clothesservice.md Sets up the full rigging pipeline for a clothes object. This includes optionally loading a custom sub-rig, parenting clothes to the rig, interpolating weights, loading custom weight overrides, and ensuring the armature modifier is in place. ```APIDOC ## set_up_rigging(basemesh, clothes, rig, mhclo, *, interpolate_weights=True, import_subrig=True, import_weights=True) ### Description Set up the full rigging pipeline for a clothes object: optionally load a custom sub-rig from an `.mpfbskel` sidecar file, parent the clothes to the rig (or sub-rig), interpolate weights, load custom weight overrides, and ensure the armature modifier is in place. ### Parameters #### Path Parameters - `basemesh` (bpy.types.Object) - Required - The basemesh object - `clothes` (bpy.types.Object) - Required - The clothes mesh to rig - `rig` (bpy.types.Object) - Required - The main armature object - `mhclo` (Mhclo) - Required - MHCLO mapping data #### Query Parameters - `interpolate_weights` (bool) - Optional - Whether to interpolate weights from the basemesh. Defaults to `True`. - `import_subrig` (bool) - Optional - Whether to import a custom sub-rig if available. Defaults to `True`. - `import_weights` (bool) - Optional - Whether to load custom weight files. Defaults to `True`. ### Returns None ``` -------------------------------- ### Create an armature from a JSON rig file Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/rig.md Demonstrates how to create an armature by loading a rig from a JSON file and fitting it to a basemesh. ```APIDOC ```python from mpfb.entities.rig import Rig rig = Rig.from_json_file_and_basemesh("/path/to/rig.json", basemesh_object) armature = rig.create_armature_and_fit_to_basemesh() ``` ``` -------------------------------- ### get_property_id_for_draw Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/blenderconfigset.md Get the full property name for direct `layout.prop()` calls. ```APIDOC ## get_property_id_for_draw(name) ### Description Get the full property name for direct `layout.prop()` calls. ### Parameters #### Arguments - **name** (str) - Required - Short property name ### Returns - **str or None** - Full property name, or `None` if not found. ``` -------------------------------- ### __init__ Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/material/makeskinmaterial.md Initialises MakeSkinMaterial with optional importer preset values. Presets are stored in self.presets. ```APIDOC ## __init__(importer_presets=None) ### Description Initialise `MakeSkinMaterial` with optional importer preset values. | Argument | Type | Default | Description | |---|---|---|---| | `importer_presets` | dict or None | `None` | Preset dictionary from the importer UI; stored in `self.presets` | **Returns:** `None`. ``` -------------------------------- ### Get Proxy Material Information Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves material information for a given proxy. ```APIDOC ## get_proxy_material_info(uuid) ### Description Get material information for a proxy. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **dict** - Material properties for the proxy. ``` -------------------------------- ### __init__ Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/material/enhancedskinmaterial.md Initializes the EnhancedSkinMaterial with importer presets. Requires a dictionary containing at least 'skin_material_type' and optionally 'scale_factor'. ```APIDOC ## __init__(importer_presets) ### Description Initialise `EnhancedSkinMaterial` with the required importer preset dictionary. ### Parameters #### Path Parameters - **importer_presets** (dict) - Required - Preset dictionary (required; no default). Must contain at least `"skin_material_type"`. Optionally `"scale_factor"` for SSS radius scaling. ### Returns None. ``` -------------------------------- ### Get Proxy Weight Information Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves metadata about the vertex weights for a given proxy. ```APIDOC ## get_proxy_weight_info(uuid) ### Description Get metadata about proxy vertex weights. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **dict** - Weight metadata for the proxy. ``` -------------------------------- ### __init__ Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/clothes/vertexmatch.md Initializes VertexMatch by running four matching strategies to map a clothes vertex to basemesh vertices. Results are stored in instance attributes. ```APIDOC ## __init__(focus_obj, focus_vert_index, focus_crossref, target_obj, target_crossref, scale_factor=1.0, reference_scale=None) ### Description Run all four matching strategies in order and store the result in `self.mhclo_line`. ### Parameters #### Path Parameters - **focus_obj** (`bpy.types.Object`) - Required - The clothes (or bodypart) mesh object whose vertex is being matched - **focus_vert_index** (`int`) - Required - Index of the clothes vertex to match - **focus_crossref** (`MeshCrossRef`) - Required - Cross-reference tables for `focus_obj` - **target_obj** (`bpy.types.Object`) - Required - The base-mesh object to match against - **target_crossref** (`MeshCrossRef`) - Required - Cross-reference tables for `target_obj` (must be built with `build_faces_by_group_reference=True` for EXTENDED_FACE strategy) #### Query Parameters - **scale_factor** (`float`) - Optional - Divisor applied to the offset displacement to normalise units. Defaults to `1.0`. - **reference_scale** (`any`) - Optional - Reserved for future scale data; currently unused. Defaults to `None`. ### Returns `None` (results are stored in instance attributes). ### Raises - `ValueError` if `focus_vert_index` does not belong to any vertex group. - `ValueError` if the vertex group name does not exist on `target_obj`. - `ValueError` if all four strategies fail to find a match. ``` -------------------------------- ### Get Default Deserialization Settings Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/humanservice.md Returns a dictionary with default values for all deserialization options. ```APIDOC ## get_default_deserialization_settings() ### Description Return a dictionary with default values for all deserialization options. ### Returns `dict` — Default settings: | Key | Default | Description | |---|---|---| | `mask_helpers` | `True` | Mask helper geometry | | `detailed_helpers` | `True` | Include detailed helper groups | | `extra_vertex_groups` | `True` | Include extra vertex groups | | `feet_on_ground` | `True` | Place feet at Z=0 | | `scale` | `0.1` | Basemesh scale factor | | `subdiv_levels` | `1` | Subdivision render levels | | `load_clothes` | `True` | Equip clothes from the preset | | `override_skin_model` | `"PRESET"` | Skin material override (`"PRESET"` uses the saved value) | | `override_rig` | `"PRESET"` | Rig override (`"PRESET"` uses the saved value, `"NONE"` skips rig) | | `material_instances` | `"NEVER"` | Material instance mode for enhanced skins | ``` -------------------------------- ### Get Proxy Weights Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves the vertex weights for a given proxy as raw binary data. ```APIDOC ## get_proxy_weights(uuid) ### Description Get proxy vertex weights as binary data. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **bytearray** - Raw binary weight data. ``` -------------------------------- ### __init__() Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/material/mhmaterial.md Initializes an empty MhMaterial object with default empty states for settings, shader configuration, and lit-sphere data. ```APIDOC ## __init__() ### Description Initialise an empty `MhMaterial` with no settings, no shader config, and no lit-sphere data. ### Returns `None`. ``` -------------------------------- ### get_deform_group_bones Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/rigservice.md Gets all bones that should have vertex groups, including bones marked `use_deform` plus any extra bones. ```APIDOC ## get_deform_group_bones(armature_object) ### Description Get all bones that should have vertex groups: bones marked `use_deform` plus any extra bones from `find_extra_bones`. ### Parameters #### Arguments - **armature_object** (bpy.types.Object) - Required - The armature to query ### Returns list[str] - List of deform group bone names. ``` -------------------------------- ### Work with Poses Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/rigservice.md Shows how to save the current pose, load a pose from a JSON file, and copy poses between armatures. Ensure global poses are available before proceeding. ```python from mpfb.services.rigservice import RigService import json # Ensure built-in poses are available RigService.ensure_global_poses_are_available() # Save the current pose pose = RigService.get_pose_as_dict(armature) with open("/path/to/pose.json", "w") as f: json.dump(pose, f) # Load and apply a pose with open("/path/to/pose.json", "r") as f: saved_pose = json.load(f) RigService.set_pose_from_dict(armature, saved_pose) # Copy pose between armatures RigService.copy_pose(source_armature, target_armature, only_rotation=True) ``` -------------------------------- ### Get Weighted Proxy Vertices Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves the list of weighted proxy vertices as raw binary data. ```APIDOC ## get_proxy_weight_vertices(uuid) ### Description Get the list of weighted proxy vertices as binary data. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **bytearray** - Raw binary vertex index data. ``` -------------------------------- ### Get Proxy Texture Coordinates Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves the texture coordinates for a given proxy as raw binary data. ```APIDOC ## get_proxy_texture_coords(uuid) ### Description Get proxy texture coordinates as binary data. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **bytearray** - Raw binary UV data. ``` -------------------------------- ### Get Proxy Face Indices Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves the face indices for a given proxy as raw binary data. ```APIDOC ## get_proxy_faces(uuid) ### Description Get proxy face indices as binary data. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **bytearray** - Raw binary face data. ``` -------------------------------- ### Working with Proxies (Clothes, Hair, etc.) Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Fetch information about loaded proxies, including their names, types, and UUIDs. For each proxy, retrieve its vertex data size and material information. ```python from mpfb.services.socketservice import SocketService # Get all loaded proxies proxies_info = SocketService.get_proxies_info() for uuid, proxy_data in proxies_info.items(): proxy_name = proxy_data.get('name', 'Unknown') proxy_type = proxy_data.get('type', 'Unknown') print(f"Proxy: {proxy_name} ({proxy_type}) - UUID: {uuid}") # Get this proxy's vertices vertices = SocketService.get_proxy_vertices(uuid) print(f" Vertex data size: {len(vertices)} bytes") # Get material info material = SocketService.get_proxy_material_info(uuid) print(f" Material: {material.get('name', 'default')}") ``` -------------------------------- ### MPFB Operator Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/ui/meta.md Demonstrates how to create a custom MPFB operator, initialize the MpfbContext with scene properties, and access context attributes like basemesh and scale factor. Ensure MY_SCENE_PROPS is correctly defined. ```python from mpfb.ui.mpfboperator import MpfbOperator from mpfb.ui.mpfbcontext import MpfbContext, ContextFocusObject, ContextResolveEffort from mpfb.services import LogService, SceneConfigSet, ClassManager import os _LOG = LogService.get_logger("myfeature.myoperator") _PROPERTIES_DIR = os.path.join(os.path.dirname(__file__), "properties") MY_SCENE_PROPS = SceneConfigSet.from_definitions_in_json_directory(_PROPERTIES_DIR, prefix="myfeature_") class MPFB_OT_My_Operator(MpfbOperator): bl_idname = "mpfb.my_operator" bl_label = "Do Something" def get_logger(self): return _LOG def hardened_execute(self, context): # Build context: find basemesh and rig, load scene properties ctx = MpfbContext( context, scene_properties=MY_SCENE_PROPS, focus_object_type=ContextFocusObject.BASEMESH, effort=ContextResolveEffort.COMMON ) if ctx.basemesh is None: self.report({'ERROR'}, "No character found") return {'CANCELLED'} # Scene properties are now accessible as attributes scale = ctx.scale_factor # from MY_SCENE_PROPS _LOG.debug("Scale factor", scale) _LOG.debug("Basemesh", ctx.basemesh.name) return {'FINISHED'} ClassManager.add_class(MPFB_OT_My_Operator) ``` -------------------------------- ### Get Proxy Vertex Positions Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/socketservice.md Retrieves the vertex positions for a given proxy as raw binary data. ```APIDOC ## get_proxy_vertices(uuid) ### Description Get proxy vertex positions as binary data. ### Parameters #### Path Parameters - **uuid** (str) - Required - The proxy's unique identifier ### Returns - **bytearray** - Raw binary vertex data. ``` -------------------------------- ### Get Available Data Roots Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/assetservice.md Retrieves all available data root directories by checking predefined locations. ```APIDOC ## get_available_data_roots() ### Description Retrieve all available data root directories. Checks four locations in order: MPFB built-in data, MakeHuman user data, MPFB user data, and the secondary root. Only directories that exist on disk are included. ### Returns `list[str]` — List of valid data root paths. ``` -------------------------------- ### Load and Apply Targets Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/targetservice.md Demonstrates loading a single target with a specified weight and checking for the existence of a target, retrieving its value if present. ```python from mpfb.services.targetservice import TargetService # Load a single target with a specific weight TargetService.load_target(basemesh, "/path/to/nose-width.target", weight=0.5) # Check if a target exists if TargetService.has_target(basemesh, "nose-width-incr"): value = TargetService.get_target_value(basemesh, "nose-width-incr") print(f"Current value: {value}") ``` -------------------------------- ### enter(location) Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/entities/primitiveprofiler.md Records the start of a timed code section. If the location is already entered, a warning is printed. ```APIDOC ## enter(location) ### Description Record the start of a timed section. ### Parameters #### Path Parameters - **location** (str) - Required - Name of the code section being timed ### Returns - None. Stores `time.time()` keyed by `location`. If `enter` is called for a `location` that is already entered (i.e., `leave` has not yet been called), a warning is printed to stdout. ``` -------------------------------- ### Example Macrotarget Definition Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/target_metadata.md Defines macrotargets for 'gender' and 'age', specifying ranges and corresponding labels for character attributes. ```json { "macrotargets": { "gender": { "label": "Gender", "parts": [ { "lowest": -0.01, "highest": 1.01, "low": "female", "high": "male" } ] }, "age": { "label": "Age", "parts": [ { "lowest": -0.01, "highest": 0.1874998, "low": "baby", "high": "child" }, { "lowest": 0.1874999, "highest": 0.49998, "low": "child", "high": "young" }, { "lowest": 0.49999, "highest": 1.01, "low": "young", "high": "old" } ] } } } ``` -------------------------------- ### Asset Path Example Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/fileformats/human_preset.md Illustrates how asset paths are specified within the preset file. The path is relative to asset roots, with the first segment indicating the asset type. ```json { ... "eyes": "high-poly/high-poly.mhclo" ... } ``` -------------------------------- ### Panel Implementation Pattern with SceneConfigSet Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/sceneconfigset.md Illustrates a common pattern for implementing MPFB panels using SceneConfigSet for managing UI settings. ```python from mpfb.services.sceneconfigset import SceneConfigSet import os ``` -------------------------------- ### Concrete Methods Source: https://github.com/makehumancommunity/mpfb2/blob/master/docs/services/configurationset.md These methods are implemented by ConfigurationSet and available to all subclasses. ```APIDOC ## as_dict(entity_reference=None, exclude_keys=None, json_with_overrides=None) ### Description Convert the configuration settings to a dictionary. ### Parameters #### Arguments - **entity_reference** (any) - Optional - Context-specific reference for reading values. Defaults to None. - **exclude_keys** (list[str]) - Optional - Keys to exclude from the output. Defaults to None. - **json_with_overrides** (str) - Optional - Path to a JSON file with override values. Defaults to None. ### Returns - **dict** - Dictionary mapping key names to their current values. When `json_with_overrides` is provided, values from that file take precedence over the stored values. This is useful for applying preset files. ``` ```APIDOC ## serialize_to_json(json_file_path, entity_reference=None, exclude_keys=None) ### Description Serialize the configuration settings to a JSON file. ### Parameters #### Arguments - **json_file_path** (str) - Path to the output JSON file - **entity_reference** (any) - Optional - Context-specific reference for reading values. Defaults to None. - **exclude_keys** (list[str]) - Optional - Keys to exclude from serialization. Defaults to None. ### Returns - None The output is formatted with 4-space indentation and sorted keys for readability. ```