### Setup PBR Nodes for Reallusion CC Characters in Blender Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Automatically creates a Principled BSDF shader node tree and connects PBR textures (Diffuse, Normal, Metallic, Roughness, AO) to the appropriate inputs for imported CC characters. It requires the FBX file path and assumes textures are in a '.fbm' subfolder. The script clears existing nodes and sets up the basic shader structure. ```python def dks_rl_pbr_nodes(fbx_file): _fbx_folder = path.dirname(fbx_file) _fbx_file = path.basename(fbx_file).replace('.Fbx', '') _objects = bpy.context.selected_objects for _obj in _objects: if _obj.type == 'MESH': _materials = _obj.data.materials for _material in _materials: _material_name = _material.name.split(".")[0] _textures_path = _fbx_folder + "\" + _fbx_file + ".fbm\" # Find texture files (supports PNG and JPG) _file_Diffuse = dks_rl_get_texture_file(_textures_path + _material_name + '_Diffuse.png') _file_Normal = dks_rl_get_texture_file(_textures_path + _material_name + '_Normal.png') _file_Metallic = dks_rl_get_texture_file(_textures_path + _material_name + '_metallic.png') _file_Roughness = dks_rl_get_texture_file(_textures_path + _material_name + '_roughness.png') _file_AO = dks_rl_get_texture_file(_textures_path + _material_name + '_ao.png') if _file_Diffuse: _material.use_nodes = True _nodes = _material.node_tree.nodes _material_links = _material.node_tree.links # Clear existing nodes for node in _nodes: _nodes.remove(node) # Create Principled BSDF shader node_shader = _nodes.new('ShaderNodeBsdfPrincipled') node_shader.location = 400, 0 # Create output node _material_output = _nodes.new('ShaderNodeOutputMaterial') _material_output.location = 600, 0 _material_links.new(node_shader.outputs['BSDF'], _material_output.inputs['Surface']) # Add texture nodes and connect to shader inputs # Base Color, Normal, Metallic, Roughness, AO... ``` -------------------------------- ### Import CC FBX Character and Setup PBR Materials (Python) Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Imports an FBX file exported from Character Creator into Blender. This operator automatically configures PBR materials using Blender's Principled BSDF shader by calling the `dks_rl_pbr_nodes` function. It requires the user to select the FBX file via a file browser. ```python class dks_rl_import_cc(bpy.types.Operator): bl_idname = "dks_rl.import_cc" bl_label = "Import CC (.fbx)" bl_description = "Import CC character and setup PBR" filepath: bpy.props.StringProperty(subtype="FILE_PATH") filter_glob: StringProperty(default="*.fbx") def execute(self, context): # Import FBX with proper axis settings bpy.ops.import_scene.fbx( filepath=self.filepath, axis_forward='-Z', axis_up='Y' ) # Setup PBR material nodes for imported character dks_rl_pbr_nodes(self.filepath) return {'FINISHED'} def invoke(self, context, event): context.window_manager.fileselect_add(self) return {'RUNNING_MODAL'} # Usage in Blender: # 1. Via menu: File -> Import -> Import CC (.fbx) # 2. Via Python: bpy.ops.dks_rl.import_cc(filepath="/path/to/character.fbx") ``` -------------------------------- ### Import CC Base Templates with fbxkey Handling (Python) Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Imports Character Creator base templates (like Neutral, Female, Male) into Blender with a single click. This operator also handles the copying and renaming of the `.fbxkey` file to ensure compatibility with Character Creator's import process. It requires the path to the templates to be configured in addon preferences. ```python class dks_rl_import_neutral(bpy.types.Operator): bl_idname = "dks_rl.import_neutral" bl_label = "CC Neutral Template (.fbx)" bl_description = "Import CC Neutral Template" def execute(self, context): _export_name = bpy.path.basename(bpy.context.blend_data.filepath).replace('.blend', '') _export_path = dks_rl_get_export_path() # Copy and rename fbxkey file for CC import compatibility system('copy /Y "' + bpy.context.preferences.addons[__package__].preferences.option_rl_templates_path + "Maya\FBX\CC3_Neutral_Maya_fbx\CC3_Neutral_Maya_fbx.fbxkey" + '" "' + _export_path + _export_name + '.fbxkey"') # Import the template FBX bpy.ops.import_scene.fbx( filepath=bpy.context.preferences.addons[__package__].preferences.option_rl_templates_path + "Maya\FBX\CC3_Neutral_Maya_fbx\CC3_Neutral_Maya_fbx.Fbx", axis_forward='-Z', axis_up='Y' ) # Apply material adjustments (eyelash blend mode) dks_rl_material_adjustments() return {'FINISHED'} # Additional template operators: # bpy.ops.dks_rl.import_female() - Import CC Female Template # bpy.ops.dks_rl.import_male() - Import CC Male Template ``` -------------------------------- ### Accessing Addon Operators via Python Scripting Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt This snippet demonstrates how to access and utilize the addon's functionalities programmatically using Blender's Python API. It shows the general pattern for calling operators related to the DKS Reallusion addon, which can be integrated into custom scripts or automated workflows. ```python import bpy # Example: Importing a CC character into Blender bpy.ops.dks_rl.import_cc_character() # Example: Exporting a modified character back to CC bpy.ops.dks_rl.export_to_cc() # Example: Renaming textures for Substance Painter compatibility bpy.ops.dks_rl.rename_textures_sp() ``` -------------------------------- ### Export Scene to FBX and Open in 3DXchange (Python) Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Exports the current Blender scene to FBX format with Reallusion-compatible settings and automatically opens the exported file in 3DXchange. It supports optional texture renaming and requires the path to the 3DXchange executable to be configured in Blender's addon preferences. ```python class dks_rl_export_3dx(bpy.types.Operator): bl_idname = "dks_rl.export_3dx" bl_label = "3DXchange (.fbx)" bl_description = "Export scene and open in 3DXchange" def execute(self, context): # Optionally rename textures to Reallusion conventions if bpy.context.preferences.addons[__package__].preferences.option_sp_rename: dks_rl_sp_textures_rename() # Export FBX file export_file = dks_rl_fbx_export(self, context) # Open in 3DXchange Popen([bpy.context.preferences.addons[__package__].preferences.option_rl_3dx_exe, export_file]) return {'FINISHED'} # Usage in Blender: # 1. Via menu: File -> Export -> 3DXchange (.fbx) # 2. Via toolbar button: Click "3DX" with export icon # 3. Via Python: bpy.ops.dks_rl.export_3dx() ``` -------------------------------- ### Blender Addon Preferences Configuration Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Defines the user preferences for the DKS Reallusion addon, allowing configuration of executable paths for Character Creator and 3DXchange, export/texture folder names, CC3 templates path, and options for renaming Substance Painter textures and saving before export. ```python class dks_rl_addon_prefs(bpy.types.AddonPreferences): bl_idname = __package__ # Path to Character Creator executable option_rl_cc_exe: bpy.props.StringProperty( name="Character Creator Executable", subtype='FILE_PATH', default="C:\\Program Files\\Reallusion\\Character Creator 3\\Bin64\\CharacterCreator.exe", ) # Path to 3DXchange executable option_rl_3dx_exe: bpy.props.StringProperty( name="3DXchange Executable", subtype='FILE_PATH', default="C:\\Program Files (x86)\\Reallusion\\iClone 3DXchange 7\\Bin\\iClone3DXchange.exe", ) # Export folder relative to .blend file option_export_folder: bpy.props.StringProperty( name="Export Folder Name", default="eXport", ) # Textures folder relative to .blend file option_textures_folder: bpy.props.StringProperty( name="Textures Folder Name", default="Textures", ) # Path to CC3 body templates option_rl_templates_path: bpy.props.StringProperty( name="CC Templates Path", subtype='DIR_PATH', default="", ) # Copy and rename Substance Painter textures option_sp_rename: bpy.props.BoolProperty( name="Copy and Rename SP Textures", default=False, ) # Save blend file before export option_save_before_export: bpy.props.BoolProperty( name="Save Before Export", default=True, ) ``` -------------------------------- ### Blender Addon Registration and Initialization Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Registers the DKS Reallusion addon with Blender's addon manager and adds custom menu items to the File menu for import and export operations. It defines addon metadata such as name, author, version, and compatibility. ```python # bl_info defines addon metadata for Blender's addon manager bl_info = { "name": "DKS Reallusion", "description": "Reallusion Pipeline", "author": "DigiKrafting.Studio", "version": (1, 4, 1), "blender": (2, 80, 0), "location": "Info Toolbar, File -> Import, File -> Export", "wiki_url": "https://github.com/DigiKrafting/blender_addon_reallusion/wiki", "tracker_url": "https://github.com/DigiKrafting/blender_addon_reallusion/issues", "category": "Import-Export", } # Register the addon in Blender import bpy from bpy.utils import register_class def register(): for cls in classes: register_class(cls) # Append menu items to Blender's File menu bpy.types.TOPBAR_MT_file_import.append(dks_rl_menu_func_import_cc) bpy.types.TOPBAR_MT_file_export.append(dks_rl_menu_func_export_cc) ``` -------------------------------- ### Export to Character Creator (Blender Operator) Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt An operator for the DKS Reallusion addon that exports the current Blender scene as an FBX file and then launches Character Creator with the exported file. It includes an option to rename Substance Painter textures before export and uses configured paths from addon preferences. ```python class dks_rl_export_cc(bpy.types.Operator): bl_idname = "dks_rl.export_cc" bl_label = "Character Creator (.fbx)" bl_description = "Export .fbx and open CC" def execute(self, context): # Optionally rename Substance Painter textures if bpy.context.preferences.addons[__package__].preferences.option_sp_rename: dks_rl_sp_textures_rename() # Export FBX with proper settings export_file = dks_rl_fbx_export(self, context) # Launch Character Creator with exported file Popen([bpy.context.preferences.addons[__package__].preferences.option_rl_cc_exe, export_file]) return {'FINISHED'} # Usage in Blender: # 1. Via menu: File -> Export -> Character Creator (.fbx) # 2. Via toolbar button: Click "CC" with export icon # 3. Via Python: bpy.ops.dks_rl.export_cc() ``` -------------------------------- ### Rename Substance Painter Textures for Reallusion in Python Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Renames texture files exported from Substance Painter to match Reallusion's naming conventions. It maps common Substance Painter suffixes (e.g., '_Base_Color') to Reallusion suffixes (e.g., '__Diffuse') and copies the renamed files to a 'Reallusion' subfolder. This script requires access to the texture directory and uses standard Python file operations. ```python # Texture name mapping from Substance Painter to Reallusion texture_names = { '_Base_Color': '__Diffuse', '_Normal_OpenGL': '__Normal', '_Ambient_occlusion': '__AO', '_Metallic': '__Metallic', '_Roughness': '__Roughness', '_Displacement': '__Displacement', '_Opacity': '__Opacity', '_Emissive': '__Glow', } def dks_rl_sp_textures_rename(): _textures_path = dks_rl_get_textures_path() if _textures_path: _reallusion_path = _textures_path + '\\Reallusion\\' if not path.exists(_reallusion_path): makedirs(_reallusion_path) # Iterate through texture files and rename for filename in listdir(_textures_path): for _match in texture_names: if _match in filename: _filepath = path.join(_textures_path, filename) _filename = filename.replace(_match, texture_names[_match]) _filepath_copy = path.join(_reallusion_path, _filename) system('copy /Y "' + _filepath + '" "' + _filepath_copy + '"') # Texture naming example: # Input: Material_Base_Color.png -> Output: Material__Diffuse.png # Input: Material_Normal_OpenGL.png -> Output: Material__Normal.png # Input: Material_Metallic.png -> Output: Material__Metallic.png ``` -------------------------------- ### Core FBX Export Function for Reallusion (Python) Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt A core Blender Python function to export the scene to FBX format. It sets Reallusion-compatible axis orientations (-Z forward, Y up), embeds textures, and allows for an optional save before export. The export path and filename are derived from the current blend file. ```python def dks_rl_fbx_export(self, context): # Get export filename from blend file _export_name = bpy.path.basename(bpy.context.blend_data.filepath).replace('.blend', '') _export_path = dks_rl_get_export_path() _export_file = _export_path + _export_name + '.fbx' # Optionally save before export if bpy.context.preferences.addons[__package__].preferences.option_save_before_export: bpy.ops.wm.save_mainfile() # Export FBX with Reallusion-compatible settings bpy.ops.export_scene.fbx( filepath=_export_file, check_existing=False, axis_forward='-Z', # Reallusion axis convention axis_up='Y', # Reallusion axis convention use_selection=False, object_types={'ARMATURE', 'MESH'}, add_leaf_bones=False, path_mode='COPY', embed_textures=True # Embed textures in FBX ) return _export_file ``` -------------------------------- ### Adjust Reallusion CC Material Blend Modes in Blender Source: https://context7.com/digikrafting/blender_addon_reallusion/llms.txt Automatically configures material blend modes for specific mesh objects in Blender, primarily targeting Reallusion CC characters. It specifically sets the 'Std_Eyelash' material's blend method to 'MULTIPLY' to ensure correct alpha blending and rendering of transparent elements like eyelashes. This script is intended to be called automatically after importing CC templates. ```python def dks_rl_material_adjustments(): _objects = bpy.context.scene.objects for _obj in _objects: if _obj.type == 'MESH': _obj_name = _obj.name # Find CC base body mesh if "CC_Base_Body" in _obj_name: _materials = _obj.data.materials for _material in _materials: # Set eyelash material to multiply blend for proper transparency if "Std_Eyelash" in _material.name: _material.blend_method = 'MULTIPLY' # Usage: Called automatically after importing CC templates # Ensures eyelashes render correctly with proper alpha blending ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.