Blender Integrationο
Blender-specific modules for UI and scene integration.
Note: These modules require Blender to run and are not available in standalone Python environments.
Operatorsο
User actions and commands.
Blender Operators for exporting robot models.
This module implements the user-facing operators that handle the export of robot models from Blender to supported description formats.
- linkforge.blender.operators.export_ops.working_directory(path)[source]ο
Context manager for temporarily changing the working directory.
- class linkforge.blender.operators.export_ops.LINKFORGE_OT_export_robot_model(*args, **kwargs)[source]ο
Bases:
Operator,ExportHelperExport robot to robot model file
- bl_idname = 'linkforge.export_robot_model'ο
- bl_label = 'Export Robot Model'ο
- bl_description = 'Export robot to supported description formats'ο
- filepath: bpy.props.StringPropertyο
- filter_glob: bpy.props.StringPropertyο
- check(context)[source]ο
Verify if export can proceed based on current scene state.
- Parameters:
context (
Context)- Return type:
- class linkforge.blender.operators.export_ops.LINKFORGE_OT_validate_robot(*args, **kwargs)[source]ο
Bases:
OperatorValidate robot structure
- bl_idname = 'linkforge.validate_robot'ο
- bl_label = 'Validate Robot'ο
- bl_description = 'Validate the robot structure for errors'ο
Operators for managing robot joints.
- class linkforge.blender.operators.joint_ops.LINKFORGE_OT_create_joint(*args, **kwargs)[source]ο
Bases:
OperatorCreate a new robot joint at selected linkβs location.
This operator initializes a joint (Blender Empty with colored axes) at the world location of the currently selected link object, setting up default joint properties and hierarchy hints.
- bl_idname = 'linkforge.create_joint'ο
- bl_label = 'Create Joint'ο
- bl_description = "Create a new robot joint at the selected link's location and orientation"ο
- bl_options = {'REGISTER', 'UNDO'}ο
- class linkforge.blender.operators.joint_ops.LINKFORGE_OT_delete_joint(*args, **kwargs)[source]ο
Bases:
OperatorDelete the selected joint Empty.
This operator removes the selected joint object from the scene and cleans up any associated references in the ROS 2 control system to maintain architectural consistency.
- bl_idname = 'linkforge.delete_joint'ο
- bl_label = 'Remove Joint'ο
- bl_description = 'Remove the selected joint from the robot structure'ο
- bl_options = {'REGISTER', 'UNDO'}ο
- class linkforge.blender.operators.joint_ops.LINKFORGE_OT_auto_detect_parent_child(*args, **kwargs)[source]ο
Bases:
OperatorAuto-detect parent and child links based on hierarchy.
This operator uses proximity heuristics and world transform analysis to automatically assign parent and child link references to the currently selected joint.
- bl_idname = 'linkforge.auto_detect_parent_child'ο
- bl_label = 'Auto-Detect Links'ο
- bl_description = 'Automatically detect parent and child links from object hierarchy'ο
- bl_options = {'REGISTER', 'UNDO'}ο
Add a joint to the ros2_control system.
This operator allows users to select a joint from the robotβs kinematic tree and include it in the ROS 2 control configuration, setting up default command and state interfaces.
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_add_ros2_control_joint(*args, **kwargs)[source]ο
Bases:
Operator- bl_idname = 'linkforge.add_ros2_control_joint'ο
- bl_label = 'Add Joint'ο
- bl_description = "Add a joint from the robot's kinematic tree to the control system"ο
- bl_options = {'REGISTER', 'UNDO'}ο
- joint_name: bpy.props.StringPropertyο
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_remove_ros2_control_joint(*args, **kwargs)[source]ο
Bases:
OperatorRemove a joint from the ros2_control system.
This operator removes the currently selected joint from the ROS 2 control configuration list.
- bl_idname = 'linkforge.remove_ros2_control_joint'ο
- bl_label = 'Remove Joint'ο
- bl_description = 'Remove the selected joint from the control system'ο
- bl_options = {'REGISTER', 'UNDO'}ο
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_move_ros2_control_joint(*args, **kwargs)[source]ο
Bases:
OperatorMove a joint up or down in the control interface list.
This is a UI helper operator to reorder how joints appear in the LinkForge control panel.
- bl_idname = 'linkforge.move_ros2_control_joint'ο
- bl_label = 'Move Joint'ο
- bl_description = 'Move joint up or down in the list (cosmetic only)'ο
- bl_options = {'REGISTER', 'UNDO'}ο
- direction: bpy.props.StringPropertyο
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_add_ros2_control_parameter(*args, **kwargs)[source]ο
Bases:
OperatorAdd a parameter to ros2_control (global or joint).
This operator adds a new key-value pair to either the global hardware parameters or the parameters of the currently selected joint.
- bl_idname = 'linkforge.add_ros2_control_parameter'ο
- bl_label = 'Add Parameter'ο
- bl_description = 'Add a key-value parameter to the control system'ο
- bl_options = {'REGISTER', 'UNDO'}ο
- target: bpy.props.StringPropertyο
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_remove_ros2_control_parameter(*args, **kwargs)[source]ο
Bases:
OperatorRemove a parameter from ros2_control.
This operator deletes a key-value pair from either the global hardware parameters or a specific jointβs parameter list.
- bl_idname = 'linkforge.remove_ros2_control_parameter'ο
- bl_label = 'Remove Parameter'ο
- bl_description = 'Remove a hardware or joint parameter'ο
- bl_options = {'REGISTER', 'UNDO'}ο
- target: bpy.props.StringPropertyο
- index: bpy.props.IntPropertyο
- class linkforge.blender.operators.control_ops.LINKFORGE_OT_purge_ros2_control_data(*args, **kwargs)[source]ο
Bases:
OperatorClear all joints and parameters from the ros2_control configuration.
- bl_idname = 'linkforge.purge_ros2_control_data'ο
- bl_label = 'Purge Control Data'ο
- bl_description = 'Clear all joints and parameters from the control system'ο
- bl_options = {'REGISTER', 'UNDO'}ο
Panelsο
UI Panels for managing robot data.
Propertiesο
Blender scene properties for storing robot data.
Blender Property Groups for robot-level configuration.
This module defines the property groups used to store robot-level metadata and export settings directly within the Blender Scene. These properties drive the UI panels and provide the configuration parameters for the URDF and XACRO generators, including:
Robot Metadata: Name and global settings.
Export Configuration: Target formats (URDF/XACRO) and validation toggles.
Advanced XACRO Settings: Toggles for property extraction, macro generation, and modular file splitting.
- linkforge.blender.properties.robot_props.update_collision_visibility(self, context)[source]ο
Update visibility of all collision meshes in the scene.
- Parameters:
self (
RobotPropertyGroup)context (
Context)
- Return type:
- class linkforge.blender.properties.robot_props.RobotPropertyGroup(*args, **kwargs)[source]ο
Bases:
PropertyGroupGlobal robot properties stored on the Scene.
- robot_name: bpy.props.StringPropertyο
- export_format: bpy.props.EnumPropertyο
- use_ros2_control: bpy.props.BoolPropertyο
- ros2_control_name: bpy.props.StringPropertyο
- ros2_control_type: bpy.props.EnumPropertyο
- hardware_plugin: bpy.props.StringPropertyο
- gazebo_plugin_name: bpy.props.StringPropertyο
- controllers_yaml_path: bpy.props.StringPropertyο
- ros2_control_joints: bpy.props.CollectionPropertyο
- ros2_control_active_joint_index: bpy.props.IntPropertyο
- ros2_control_parameters: bpy.props.CollectionPropertyο
- show_ros2_control_parameters: bpy.props.BoolPropertyο
- export_meshes: bpy.props.BoolPropertyο
- mesh_format: bpy.props.EnumPropertyο
- mesh_directory_name: bpy.props.StringPropertyο
- validate_before_export: bpy.props.BoolPropertyο
- strict_mode: bpy.props.BoolPropertyο
- xacro_advanced_mode: bpy.props.BoolPropertyο
- xacro_extract_materials: bpy.props.BoolPropertyο
- xacro_extract_dimensions: bpy.props.BoolPropertyο
- xacro_generate_macros: bpy.props.BoolPropertyο
- xacro_split_files: bpy.props.BoolPropertyο
- show_kinematic_tree: bpy.props.BoolPropertyο
- component_browser_search: bpy.props.StringPropertyο
- show_collisions: bpy.props.BoolPropertyο
- is_importing: bpy.props.BoolPropertyο
- abort_import: bpy.props.BoolPropertyο
- import_status: bpy.props.StringPropertyο
- linkforge.blender.properties.robot_props.register()[source]ο
Register property group.
- Return type:
- linkforge.blender.properties.robot_props.unregister()[source]ο
Unregister property group.
- Return type:
Blender Property Groups for robot links.
These properties are stored on Blender objects and define link characteristics.
- class linkforge.blender.properties.link_props.LinkPropertyGroup(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperties for a robot link stored on a Blender object.
- is_robot_link: bpy.props.BoolPropertyο
- source_name_stored: bpy.props.StringPropertyο
- link_name: bpy.props.StringPropertyο
- use_auto_inertia: bpy.props.BoolPropertyο
- mass: bpy.props.FloatPropertyο
- inertia_ixx: bpy.props.FloatPropertyο
- inertia_ixy: bpy.props.FloatPropertyο
- inertia_ixz: bpy.props.FloatPropertyο
- inertia_iyy: bpy.props.FloatPropertyο
- inertia_iyz: bpy.props.FloatPropertyο
- inertia_izz: bpy.props.FloatPropertyο
- inertia_origin_xyz: bpy.props.FloatVectorPropertyο
- inertia_origin_rpy: bpy.props.FloatVectorPropertyο
- use_simulation_props: bpy.props.BoolPropertyο
- self_collide: bpy.props.BoolPropertyο
- gravity: bpy.props.BoolPropertyο
- mu: bpy.props.FloatPropertyο
- mu2: bpy.props.FloatPropertyο
- kp: bpy.props.FloatPropertyο
- kp_ui: bpy.props.StringPropertyο
- kd: bpy.props.FloatPropertyο
- kd_ui: bpy.props.StringPropertyο
- collision_type: bpy.props.EnumPropertyο
- collision_quality: bpy.props.FloatPropertyο
- use_material: bpy.props.BoolPropertyο
- linkforge.blender.properties.link_props.unregister()[source]ο
Unregister property group.
- Return type:
- linkforge.blender.properties.link_props.sanitize_name(name, allow_hyphen=True)[source]ο
Sanitize a name for robot model and Python identifier compatibility.
Replaces invalid characters with underscores and ensures it doesnβt start with a digit.
Blender Property Groups for robot joints.
These properties are stored on Empty objects and define joint characteristics.
- linkforge.blender.properties.joint_props.get_joint_name(self)[source]ο
Getter for joint_name - returns the persistent source identity.
- Parameters:
self (
JointPropertyGroup) β The JointPropertyGroup instance.- Return type:
- Returns:
The sanitized robot model name.
- linkforge.blender.properties.joint_props.set_joint_name(self, value)[source]ο
Setter for joint_name - updates persistent identity and object name.
- Parameters:
self (
JointPropertyGroup) β The JointPropertyGroup instance.value (
str) β The new name value to set.
- Return type:
- linkforge.blender.properties.joint_props.update_joint_hierarchy(self, context)[source]ο
Update Blender object hierarchy when parent/child links change.
Establishes hierarchy: parent_link β joint β child_link This matches import behavior and shows kinematic tree in outliner.
- Parameters:
self (
JointPropertyGroup)context (
Context)
- Return type:
- linkforge.blender.properties.joint_props.poll_robot_link(_self, obj)[source]ο
Filter to only allow robot link objects in pointer selection.
- Parameters:
_self (
JointPropertyGroup)obj (
Object)
- Return type:
- linkforge.blender.properties.joint_props.poll_robot_joint(self, obj)[source]ο
Filter to only allow other robot joint objects in pointer selection.
- Parameters:
self (
JointPropertyGroup)obj (
Object)
- Return type:
- class linkforge.blender.properties.joint_props.JointPropertyGroup(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperties for a robot joint stored on an Empty object.
- is_robot_joint: bpy.props.BoolPropertyο
- source_name_stored: bpy.props.StringPropertyο
- joint_name: bpy.props.StringPropertyο
- joint_type: bpy.props.EnumPropertyο
- parent_link: bpy.props.PointerPropertyο
- child_link: bpy.props.PointerPropertyο
- axis: bpy.props.EnumPropertyο
- custom_axis_x: bpy.props.FloatPropertyο
- custom_axis_y: bpy.props.FloatPropertyο
- custom_axis_z: bpy.props.FloatPropertyο
- use_limits: bpy.props.BoolPropertyο
- limit_lower: bpy.props.FloatPropertyο
- limit_upper: bpy.props.FloatPropertyο
- limit_effort: bpy.props.FloatPropertyο
- limit_velocity: bpy.props.FloatPropertyο
- use_dynamics: bpy.props.BoolPropertyο
- dynamics_damping: bpy.props.FloatPropertyο
- dynamics_friction: bpy.props.FloatPropertyο
- use_mimic: bpy.props.BoolPropertyο
- mimic_joint: bpy.props.PointerPropertyο
- mimic_multiplier: bpy.props.FloatPropertyο
- mimic_offset: bpy.props.FloatPropertyο
- use_safety_controller: bpy.props.BoolPropertyο
- safety_soft_lower_limit: bpy.props.FloatPropertyο
- safety_soft_upper_limit: bpy.props.FloatPropertyο
- safety_k_position: bpy.props.FloatPropertyο
- safety_k_velocity: bpy.props.FloatPropertyο
- use_calibration: bpy.props.BoolPropertyο
- calibration_rising: bpy.props.FloatPropertyο
- use_calibration_rising: bpy.props.BoolPropertyο
- calibration_falling: bpy.props.FloatPropertyο
- use_calibration_falling: bpy.props.BoolPropertyο
- linkforge.blender.properties.joint_props.register()[source]ο
Register property group.
- Return type:
- linkforge.blender.properties.joint_props.unregister()[source]ο
Unregister property group.
- Return type:
Blender Property Groups for robot sensors.
These properties are stored on Empty objects and define sensor characteristics.
- linkforge.blender.properties.sensor_props.get_sensor_name(self)[source]ο
Getter for sensor_name - returns the persistent robot model identity.
- Parameters:
self (
SensorPropertyGroup) β The SensorPropertyGroup instance.- Return type:
- Returns:
The sanitized robot model name.
- linkforge.blender.properties.sensor_props.set_sensor_name(self, value)[source]ο
Setter for sensor_name - updates persistent identity and object name.
- Parameters:
self (
SensorPropertyGroup) β The SensorPropertyGroup instance.value (
str) β The new name value to set.
- Return type:
- linkforge.blender.properties.sensor_props.update_sensor_hierarchy(self, context)[source]ο
Update Blender object hierarchy when attached link changes.
Automatically reparents sensor to new link and moves to linkβs collection. This ensures visual hierarchy matches logical structure.
- Parameters:
self (
SensorPropertyGroup)context (
Context)
- Return type:
- linkforge.blender.properties.sensor_props.poll_robot_link(_self, obj)[source]ο
Filter to only allow robot link objects in pointer selection.
- Parameters:
_self (
SensorPropertyGroup)obj (
Object)
- Return type:
- class linkforge.blender.properties.sensor_props.SensorPropertyGroup(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperties for a robot sensor stored on an Empty object.
- is_robot_sensor: bpy.props.BoolPropertyο
- source_name_stored: bpy.props.StringPropertyο
- sensor_name: bpy.props.StringPropertyο
- sensor_type: bpy.props.EnumPropertyο
- attached_link: bpy.props.PointerPropertyο
- update_rate: bpy.props.FloatPropertyο
- always_on: bpy.props.BoolPropertyο
- visualize: bpy.props.BoolPropertyο
- topic_name: bpy.props.StringPropertyο
- camera_horizontal_fov: bpy.props.FloatPropertyο
- camera_width: bpy.props.IntPropertyο
- camera_height: bpy.props.IntPropertyο
- camera_near_clip: bpy.props.FloatPropertyο
- camera_far_clip: bpy.props.FloatPropertyο
- camera_format: bpy.props.EnumPropertyο
- lidar_horizontal_samples: bpy.props.IntPropertyο
- lidar_horizontal_min_angle: bpy.props.FloatPropertyο
- lidar_horizontal_max_angle: bpy.props.FloatPropertyο
- lidar_vertical_samples: bpy.props.IntPropertyο
- lidar_vertical_min_angle: bpy.props.FloatPropertyο
- lidar_vertical_max_angle: bpy.props.FloatPropertyο
- lidar_range_min: bpy.props.FloatPropertyο
- lidar_range_max: bpy.props.FloatPropertyο
- lidar_range_resolution: bpy.props.FloatPropertyο
- contact_collision: bpy.props.StringPropertyο
- use_noise: bpy.props.BoolPropertyο
- noise_type: bpy.props.EnumPropertyο
- noise_mean: bpy.props.FloatPropertyο
- noise_stddev: bpy.props.FloatPropertyο
- use_gazebo_plugin: bpy.props.BoolPropertyο
- plugin_filename: bpy.props.StringPropertyο
- plugin_raw_xml: bpy.props.StringPropertyο
- linkforge.blender.properties.sensor_props.register()[source]ο
Register property group.
- Return type:
- linkforge.blender.properties.sensor_props.unregister()[source]ο
Unregister property group.
- Return type:
Blender Property Groups for centralized ros2_control configuration.
These properties are stored on the Scene and define the mapping between robot joints and ros2_control interfaces (command and state).
- class linkforge.blender.properties.control_props.Ros2ControlParameterProperty(*args, **kwargs)[source]ο
Bases:
PropertyGroupKey-value pair for ros2_control parameters.
- name: bpy.props.StringPropertyο
- value: bpy.props.StringPropertyο
- class linkforge.blender.properties.control_props.Ros2ControlInterfaceProperty(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperty group for a single ros2_control interface.
- name: bpy.props.EnumPropertyο
- parameters: bpy.props.CollectionPropertyο
- class linkforge.blender.properties.control_props.Ros2ControlJointProperty(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperty group for a jointβs ros2_control mapping.
- name: bpy.props.StringPropertyο
- joint_obj: bpy.props.PointerPropertyο
- cmd_position: bpy.props.BoolPropertyο
- cmd_velocity: bpy.props.BoolPropertyο
- cmd_effort: bpy.props.BoolPropertyο
- state_position: bpy.props.BoolPropertyο
- state_velocity: bpy.props.BoolPropertyο
- state_effort: bpy.props.BoolPropertyο
- show_parameters: bpy.props.BoolPropertyο
- parameters: bpy.props.CollectionPropertyο
- linkforge.blender.properties.control_props.register()[source]ο
Register property groups.
- Return type:
- linkforge.blender.properties.control_props.unregister()[source]ο
Unregister property groups.
- Return type:
Blender Property Groups for robot transmissions.
These properties are stored on Empty objects and define transmission characteristics for ros2_control integration.
- linkforge.blender.properties.transmission_props.get_transmission_name(self)[source]ο
Getter for transmission_name - returns the persistent robot model identity.
- Parameters:
self (
TransmissionPropertyGroup) β The TransmissionPropertyGroup instance.- Return type:
- Returns:
The sanitized robot model name.
- linkforge.blender.properties.transmission_props.set_transmission_name(self, value)[source]ο
Setter for transmission_name - updates persistent identity and object name.
- Parameters:
self (
TransmissionPropertyGroup) β The TransmissionPropertyGroup instance.value (
str) β The new name value to set.
- Return type:
- linkforge.blender.properties.transmission_props.update_transmission_hierarchy(self, context)[source]ο
Update Blender object hierarchy when joint changes.
Automatically reparents transmission to new joint and moves to jointβs collection. This ensures visual hierarchy matches logical structure.
- Parameters:
self (
TransmissionPropertyGroup) β The property group instance.context (
Context) β The current Blender context.
- Return type:
- linkforge.blender.properties.transmission_props.poll_robot_joint(_self, obj)[source]ο
Filter to only allow robot joint objects in pointer selection.
- Parameters:
self β The property group instance.
obj (
Object) β The object to check._self (
TransmissionPropertyGroup)
- Return type:
- Returns:
True if the object is a valid robot joint.
- class linkforge.blender.properties.transmission_props.TransmissionPropertyGroup(*args, **kwargs)[source]ο
Bases:
PropertyGroupProperties for a robot transmission stored on an Empty object.
- is_robot_transmission: bpy.props.BoolPropertyο
- source_name_stored: bpy.props.StringPropertyο
- transmission_name: bpy.props.StringPropertyο
- transmission_type: bpy.props.EnumPropertyο
- custom_type: bpy.props.StringPropertyο
- joint_name: bpy.props.PointerPropertyο
- joint1_name: bpy.props.PointerPropertyο
- joint2_name: bpy.props.PointerPropertyο
- hardware_interface: bpy.props.EnumPropertyο
- mechanical_reduction: bpy.props.FloatPropertyο
- offset: bpy.props.FloatPropertyο
- use_custom_actuator_name: bpy.props.BoolPropertyο
- actuator_name: bpy.props.StringPropertyο
- actuator1_name: bpy.props.StringPropertyο
- actuator2_name: bpy.props.StringPropertyο
- linkforge.blender.properties.transmission_props.register()[source]ο
Register property group.
- Return type:
- linkforge.blender.properties.transmission_props.unregister()[source]ο
Unregister property group.
- Return type:
Blender Property Groups for validation results.
These properties store the last validation result for display in the UI.
- class linkforge.blender.properties.validation_props.ValidationIssueProperty(*args, **kwargs)[source]ο
Bases:
PropertyGroupA single validation issue (error or warning).
- title: bpy.props.StringPropertyο
- message: bpy.props.StringPropertyο
- suggestion: bpy.props.StringPropertyο
- affected_objects: bpy.props.StringPropertyο
- error_code: bpy.props.StringPropertyο
- class linkforge.blender.properties.validation_props.ValidationResultProperty(*args, **kwargs)[source]ο
Bases:
PropertyGroupValidation result stored in window manager.
- has_results: bpy.props.BoolPropertyο
- is_valid: bpy.props.BoolPropertyο
- error_count: bpy.props.IntPropertyο
- warning_count: bpy.props.IntPropertyο
- link_count: bpy.props.IntPropertyο
- joint_count: bpy.props.IntPropertyο
- dof_count: bpy.props.IntPropertyο
- errors: bpy.props.CollectionPropertyο
- warnings: bpy.props.CollectionPropertyο
- show_errors: bpy.props.BoolPropertyο
- show_warnings: bpy.props.BoolPropertyο
Adaptersο
Conversion between Blender and core models.
Converters between Blender properties and Core models.
These functions bridge the gap between Blenderβs property system and LinkForgeβs core data models.
- linkforge.blender.adapters.blender_to_core.detect_primitive_type(obj)[source]ο
Detect if a Blender mesh object matches a standard primitive shape.
Analyzes topology and dimensions to determine if the object can be exported as a URDF primitive (BOX, CYLINDER, or SPHERE). This function is critical for optimizing exports and ensuring compatibility with physics simulators.
- Parameters:
obj (bpy.types.Object | None) β The Blender mesh object to analyze.
- Return type:
str | None
- Returns:
βboxβ, βcylinderβ, or βsphereβ if a match is detected, else None.
- linkforge.blender.adapters.blender_to_core.get_object_geometry(obj, geometry_type='auto', link_name=None, geom_purpose='visual', meshes_dir=None, mesh_format='STL', simplify=False, decimation_ratio=0.5, dry_run=False, suffix='', depsgraph=None)[source]ο
Extract geometry from Blender object.
- Parameters:
obj (bpy.types.Object | None) β Blender Object
geometry_type (str) β Type of geometry to extract - βautoβ: Auto-detect (primitives for simple shapes, mesh for complex) - βmeshβ: Force mesh export - βboxβ, βcylinderβ, βsphereβ: Force specific primitive
link_name (str | None) β Name of the link (for mesh filename)
geom_purpose (str) β βvisualβ or βcollisionβ (use PURPOSE_VISUAL, PURPOSE_COLLISION)
meshes_dir (Path | None) β Directory to export mesh files to
mesh_format (str) β βSTLβ, βOBJβ, or βGLBβ (use FORMAT_STL, etc.)
simplify (bool) β Whether to simplify mesh (for collision)
decimation_ratio (float) β Simplification ratio if simplify=True
dry_run (bool) β If True, generate mesh paths but donβt write files
suffix (str) β Optional unique suffix (e.g., index or name)
depsgraph (Any | None)
- Return type:
tuple[Geometry | None, Matrix]
- Returns:
tuple of (Core Geometry or None, geometry_world_matrix)
- linkforge.blender.adapters.blender_to_core.extract_mesh_triangles(obj, depsgraph=None, as_numpy=False)[source]ο
Extract triangle mesh data from Blender object.
- Parameters:
obj (bpy.types.Object | None) β Blender mesh object
depsgraph (Any | None) β Optional evaluated dependency graph
as_numpy (bool) β If True, return NumPy arrays instead of Python lists
- Returns:
vertices: List of (x, y, z) coordinates or (N, 3) NumPy array
triangles: List of (v0, v1, v2) vertex indices or (M, 3) NumPy array
- Return type:
tuple[Any, Any] | None
- linkforge.blender.adapters.blender_to_core.get_object_material(obj, props)[source]ο
Extract material from Blender object.
- class linkforge.blender.adapters.blender_to_core.SceneToRobotTranslator(context, meshes_dir=None, dry_run=False, depsgraph=None)[source]ο
Bases:
objectOrchestrates the conversion of a Blender scene to a Core Robot model.
This class follows the SOLID principles by encapsulating the translation logic and leveraging the RobotBuilder (Composer) API for structural integrity.
- Parameters:
- linkforge.blender.adapters.blender_to_core.scene_to_robot(context, meshes_dir=None, dry_run=False)[source]ο
Convert entire Blender scene to Core Robot using the Translator orchestrator.
- Parameters:
context (IBlenderContext | bpy.types.Context)
meshes_dir (Path | None)
dry_run (bool)
- Return type:
tuple[Robot, ValidationResult]
Scene Builder utilities for creating Blender objects from generic Robot models.
- linkforge.blender.adapters.core_to_blender.create_material_from_color(context, color, name)[source]ο
Create Blender material from Color model.
- Parameters:
context (IBlenderContext) β Blender context adapter
color (Color) β Color model
name (str) β Material name
- Return type:
bpy.types.Material | None
- Returns:
Blender Material or None
- linkforge.blender.adapters.core_to_blender.create_primitive_mesh(context, geometry, name)[source]ο
Create a Blender mesh object from primitive geometry.
This function generates native Blender mesh primitives (Cube, Cylinder, Sphere) based on the Core geometry model and applies the correct dimensions and format-specific metadata tags.
- Parameters:
context (IBlenderContext) β Blender context adapter
geometry (Box | Cylinder | Sphere) β One of Box, Cylinder, or Sphere models.
name (str) β Name to assign to the created Blender object.
- Return type:
bpy.types.Object | None
- Returns:
The created Blender Object or None if creation failed.
- linkforge.blender.adapters.core_to_blender.import_mesh_file(context, mesh_path, name)[source]ο
Import an external mesh file into the Blender scene.
Supported formats include STL, OBJ, and GLB. This function utilizes modern Blender WM operators for improved performance and stability.
- Parameters:
context (IBlenderContext) β Blender context adapter
mesh_path (Path) β Absolute path to the mesh file.
name (str) β Name to assign to the imported object.
- Return type:
bpy.types.Object | None
- Returns:
The imported Blender Object or None if import failed.
- linkforge.blender.adapters.core_to_blender.normalize_and_consolidate_imported_objects(context, objects, name)[source]ο
Consolidation logic that processes all supplied objects (meshes β join, others β delete).
- Parameters:
context (IBlenderContext)
objects (typing.Iterable[bpy.types.Object])
name (str)
- Return type:
bpy.types.Object | None
- linkforge.blender.adapters.core_to_blender.create_link_object(context, link, robot, source_directory, collection=None)[source]ο
Create Blender object from Link model with support for multiple visual/collision elements.
- Parameters:
context (IBlenderContext) β Blender context adapter
link (Link) β Link model
robot (Robot) β Robot model (for resolving resources)
source_directory (Path) β Directory containing source file (for resolving relative paths)
collection (bpy.types.Collection | None) β Blender Collection to add object to
- Return type:
bpy.types.Object | None
- Returns:
Blender Object or None (returns the link Empty object with properties)
- linkforge.blender.adapters.core_to_blender.create_joint_object(context, joint, link_objects, collection=None)[source]ο
Create Empty object from Joint model.
- Parameters:
context (IBlenderContext) β Blender context adapter
joint (Joint) β Joint model
link_objects (dict[str, bpy.types.Object]) β Dictionary mapping link names to Blender objects
collection (bpy.types.Collection | None) β Blender Collection to add object to
- Return type:
bpy.types.Object | None
- Returns:
Blender Empty object or None
- linkforge.blender.adapters.core_to_blender.create_sensor_object(context, sensor, link_objects, collection=None)[source]ο
Create Empty object from Sensor model.
- Parameters:
context (IBlenderContext) β Blender context adapter
sensor (typing.Any) β Sensor model from core
link_objects (dict[str, bpy.types.Object]) β Dictionary mapping link names to Blender objects
collection (bpy.types.Collection | None) β Blender Collection to add object to
- Return type:
bpy.types.Object | None
- Returns:
Blender Empty object or None
- linkforge.blender.adapters.core_to_blender.setup_scene_for_robot(context, robot)[source]ο
Initialize scene properties for a robot model.
This populates the Centralized Control Dashboard, Gazebo settings, and metadata based on the robot model.
- Parameters:
context (
IBlenderContext) β Blender context adapterrobot (
Robot) β Robot model to extract settings from
- Return type:
- linkforge.blender.adapters.core_to_blender.import_robot_to_scene(robot, source_path, context)[source]ο
Import Robot model to Blender scene.
- Parameters:
robot (Robot) β Robot model
source_path (Path) β Path to source file
context (IBlenderContext | bpy.types.Context) β Blender context (real or adapter)
- Return type:
bool
Mesh export utilities for LinkForge.
Export Blender mesh objects to STL, OBJ, and GLB files for URDF.
- linkforge.blender.adapters.mesh_io.export_mesh_stl(obj, filepath)[source]ο
Export a Blender object to an STL file.
This function utilizes the modern Blender WM STL exporter, ensuring correct axis orientations (Y-forward, Z-up) for ROS 2 compatibility.
- linkforge.blender.adapters.mesh_io.export_mesh_obj(obj, filepath)[source]ο
Export a Blender object to an OBJ file with associated MTL materials.
This function ensures that materials are correctly exported alongside the geometry, maintaining visual fidelity in the target URDF.
- linkforge.blender.adapters.mesh_io.create_simplified_mesh(obj, decimation_ratio)[source]ο
Create a simplified mesh copy using Blenderβs Decimate modifier.
This function is primarily used to generate lightweight collision geometry from high-fidelity visual meshes, reducing physics computation overhead.
- linkforge.blender.adapters.mesh_io.get_mesh_filename(link_name, geometry_type, mesh_format, suffix='')[source]ο
Generate mesh filename based on link and geometry type.
- Parameters:
- Return type:
- Returns:
Filename string (e.g., βbase_link_visual_0.stlβ).
- linkforge.blender.adapters.mesh_io.export_mesh_glb(obj, filepath)[source]ο
Export Blender object to GLB (glTF Binary) file.
- linkforge.blender.adapters.mesh_io.export_link_mesh(obj, link_name, geometry_type, mesh_format, meshes_dir, simplify=False, decimation_ratio=0.5, dry_run=False, suffix='', depsgraph=None)[source]ο
Export mesh for a robot link.
CRITICAL: Exports mesh geometry centered at origin (0,0,0) with no transforms. The visual origin in URDF will handle all positioning. This prevents double-offset issues when the mesh is re-imported.
- Parameters:
obj (
Any) β Blender Object to exportlink_name (
str) β Name of the robot linkgeometry_type (
str) β βvisualβ or βcollisionβ (PURPOSE_VISUAL, PURPOSE_COLLISION)mesh_format (
str) β βSTLβ, βOBJβ, or βGLBβ (FORMAT_STL, etc.)meshes_dir (
Path) β Directory where mesh files should be savedsimplify (
bool) β Whether to simplify mesh (for collision)decimation_ratio (
float) β Simplification ratio if simplify=Truedry_run (
bool) β If True, return expected path without exportingsuffix (
str)
- Return type:
- Returns:
tuple of (Path to exported mesh file or None, geometric_offset)
Utilitiesο
Blender-specific helpers.
Helper utilities for Blender property groups.
This module provides optimized helper functions for property update callbacks.
- linkforge.blender.utils.property_helpers.find_property_owner(context, property_group, property_attr)[source]ο
Find the Blender object that owns a given property group instance.
This is an optimized helper for property update callbacks that need to find their owning object. It tries multiple strategies from fastest to slowest: 1. Check id_data (most reliable and fastest) 2. Check context.object (active object) first 3. Check context.selected_objects 4. Fall back to full scene search as last resort
- Parameters:
- Return type:
- Returns:
The object that owns this property group, or None if not found
- linkforge.blender.utils.property_helpers.get_link_props(obj)[source]ο
Type-safe access to LinkForge link properties on a Blender object.
- Parameters:
obj (bpy.types.Object | None)
- Return type:
LinkPropertyGroup | None
- linkforge.blender.utils.property_helpers.get_joint_props(obj)[source]ο
Type-safe access to LinkForge joint properties on a Blender object.
- Parameters:
obj (bpy.types.Object | None)
- Return type:
JointPropertyGroup | None
- linkforge.blender.utils.property_helpers.get_sensor_props(obj)[source]ο
Type-safe access to LinkForge sensor properties on a Blender object.
- Parameters:
obj (bpy.types.Object | None)
- Return type:
SensorPropertyGroup | None
- linkforge.blender.utils.property_helpers.get_transmission_props(obj)[source]ο
Type-safe access to LinkForge transmission properties on a Blender object.
- Parameters:
obj (bpy.types.Object | None)
- Return type:
TransmissionPropertyGroup | None
- linkforge.blender.utils.property_helpers.get_robot_props(scene)[source]ο
Type-safe access to LinkForge robot properties on a Blender scene.
- Parameters:
scene (bpy.types.Scene | None)
- Return type:
RobotPropertyGroup | None
Utilities for managing object transforms and parenting.
- linkforge.blender.utils.transform_utils.matrix_to_transform(matrix)[source]ο
Convert a Blender 4x4 matrix to a Core Transform.
- linkforge.blender.utils.transform_utils.set_parent_keep_transform(child_obj, parent_obj)[source]ο
Set object parent while preserving its world transform (visual location/rotation).
This matches standard Blender βObject (Keep Transform)β behavior by setting matrix_parent_inverse to the inverse of the parentβs world matrix.
Contextο
Usage in Blenderο
Accessing from Blender Python Consoleο
import bpy
from linkforge.blender.adapters.blender_to_core import scene_to_robot
# Convert current scene to robot model
robot = scene_to_robot(bpy.context)
# Access robot data
print(f"Robot: {robot.name}")
for link in robot.links:
print(f" Link: {link.name}")
Creating Custom Operatorsο
import bpy
from linkforge.blender.utils.decorators import safe_execute
class LINKFORGE_OT_my_custom_op(bpy.types.Operator):
bl_idname = "linkforge.my_custom_op"
bl_label = "My Custom Operation"
@safe_execute
def execute(self, context):
# Your code here
self.report({'INFO'}, "Operation complete!")
return {'FINISHED'}