[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EEGMG35P1H41WATH3BQ57M":3,"skill-same:01M6EEGMG35P1H41WATH3BQ57M":48},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":21,"linkOnly":22,"markdownContent":23,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M6EEGMG35P1H41WATH3BQ57M","blender-scripting",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Fblender-scripting\u002FSKILL.md",[],[18,19,20],"scripting","blender","blender scripting","2026-11-10 10:12:30",false,"# Blender Scripting\n\n## Overview\n\nAutomate Blender tasks using Python and the `bpy` API. Run scripts headlessly from the terminal to manipulate scenes, batch process files, import\u002Fexport models, and build 3D pipelines without opening the GUI.\n\n## Instructions\n\n### 1. Run a Blender script from the terminal\n\n```bash\n# Run a script in background mode (no GUI)\nblender --background --python script.py\n\n# Run with a specific .blend file\nblender myfile.blend --background --python script.py\n\n# Pass custom arguments (use -- to separate Blender args from script args)\nblender --background --python script.py -- --output \u002Ftmp\u002Fresult.png --scale 2.0\n```\n\nParse custom arguments in the script:\n\n```python\nimport sys\n\nargv = sys.argv\n# Everything after \"--\" is a custom argument\nif \"--\" in argv:\n    custom_args = argv[argv.index(\"--\") + 1:]\nelse:\n    custom_args = []\n```\n\n### 2. Understand the bpy module structure\n\n```python\nimport bpy\n\n# bpy.data — all data in the file (meshes, materials, objects, scenes)\nbpy.data.objects[\"Cube\"]\nbpy.data.meshes[\"Cube\"]\nbpy.data.materials[\"Material\"]\n\n# bpy.context — current state (active object, selected objects, scene)\nbpy.context.active_object\nbpy.context.selected_objects\nbpy.context.scene\n\n# bpy.ops — operators (actions like add, delete, transform)\nbpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))\nbpy.ops.object.delete()\n```\n\n### 3. Scene setup and cleanup\n\n```python\nimport bpy\n\ndef clear_scene():\n    \"\"\"Remove all objects from the scene.\"\"\"\n    bpy.ops.object.select_all(action='SELECT')\n    bpy.ops.object.delete(use_global=False)\n\n    # Also clear orphan data\n    for block in bpy.data.meshes:\n        if block.users == 0:\n            bpy.data.meshes.remove(block)\n    for block in bpy.data.materials:\n        if block.users == 0:\n            bpy.data.materials.remove(block)\n\ndef setup_scene():\n    \"\"\"Set up a clean scene with basic settings.\"\"\"\n    clear_scene()\n    scene = bpy.context.scene\n    scene.unit_settings.system = 'METRIC'\n    scene.unit_settings.scale_length = 1.0\n```\n\n### 4. Create and transform objects\n\n```python\nimport bpy\nfrom mathutils import Vector, Euler\nimport math\n\n# Add primitives\nbpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))\ncube = bpy.context.active_object\ncube.name = \"MyCube\"\n\n# Transform\ncube.location = (3, 0, 1)\ncube.rotation_euler = (0, 0, math.radians(45))\ncube.scale = (1, 2, 0.5)\n\n# Duplicate\nbpy.ops.object.duplicate(linked=False)\nduplicate = bpy.context.active_object\nduplicate.location.x += 5\n\n# Parent objects\nchild = bpy.data.objects[\"ChildObj\"]\nparent = bpy.data.objects[\"ParentObj\"]\nchild.parent = parent\n```\n\n### 5. Import and export 3D files\n\n```python\nimport bpy\n\n# Import\nbpy.ops.wm.obj_import(filepath=\"\u002Fpath\u002Fto\u002Fmodel.obj\")\nbpy.ops.import_scene.fbx(filepath=\"\u002Fpath\u002Fto\u002Fmodel.fbx\")\nbpy.ops.import_scene.gltf(filepath=\"\u002Fpath\u002Fto\u002Fmodel.glb\")\nbpy.ops.wm.stl_import(filepath=\"\u002Fpath\u002Fto\u002Fmodel.stl\")\n\n# Export\nbpy.ops.wm.obj_export(filepath=\"\u002Fpath\u002Fto\u002Foutput.obj\")\nbpy.ops.export_scene.fbx(filepath=\"\u002Fpath\u002Fto\u002Foutput.fbx\", use_selection=True)\nbpy.ops.export_scene.gltf(filepath=\"\u002Fpath\u002Fto\u002Foutput.glb\", export_format='GLB')\nbpy.ops.wm.stl_export(filepath=\"\u002Fpath\u002Fto\u002Foutput.stl\")\n```\n\n### 6. Batch process .blend files\n\n```python\nimport bpy\nimport glob\nimport os\n\nblend_files = glob.glob(\"\u002Fpath\u002Fto\u002Fprojects\u002F*.blend\")\n\nfor filepath in blend_files:\n    bpy.ops.wm.open_mainfile(filepath=filepath)\n\n    # Do work on each file\n    for obj in bpy.data.objects:\n        if obj.type == 'MESH':\n            print(f\"  Mesh: {obj.name}, verts: {len(obj.data.vertices)}\")\n\n    # Save modified file\n    output = filepath.replace(\".blend\", \"_processed.blend\")\n    bpy.ops.wm.save_as_mainfile(filepath=output)\n    print(f\"Saved: {output}\")\n```\n\n### 7. Work with custom properties\n\n```python\nimport bpy\n\nobj = bpy.context.active_object\n\n# Set custom properties\nobj[\"my_property\"] = 42\nobj[\"tags\"] = \"hero,main\"\n\n# Read custom properties\nvalue = obj.get(\"my_property\", 0)\n\n# Iterate all custom properties\nfor key, value in obj.items():\n    if key not in {\"_RNA_UI\"}:\n        print(f\"{key}: {value}\")\n```\n\n## Examples\n\n### Example 1: Export all objects as separate OBJ files\n\n**User request:** \"Export every mesh object in my .blend file as a separate OBJ\"\n\n```python\nimport bpy\nimport os\n\noutput_dir = \"\u002Ftmp\u002Fexports\"\nos.makedirs(output_dir, exist_ok=True)\n\nbpy.ops.object.select_all(action='DESELECT')\n\nfor obj in bpy.data.objects:\n    if obj.type == 'MESH':\n        bpy.ops.object.select_all(action='DESELECT')\n        obj.select_set(True)\n        bpy.context.view_layer.objects.active = obj\n        filepath = os.path.join(output_dir, f\"{obj.name}.obj\")\n        bpy.ops.wm.obj_export(filepath=filepath, export_selected_objects=True)\n        print(f\"Exported: {filepath}\")\n```\n\nRun: `blender scene.blend --background --python export_all.py`\n\n### Example 2: Batch rename objects by type\n\n**User request:** \"Rename all mesh objects to mesh_001, mesh_002, etc. and all lights to light_001, etc.\"\n\n```python\nimport bpy\n\ncounters = {}\n\nfor obj in sorted(bpy.data.objects, key=lambda o: o.name):\n    prefix = obj.type.lower()\n    counters[prefix] = counters.get(prefix, 0) + 1\n    obj.name = f\"{prefix}_{counters[prefix]:03d}\"\n    print(f\"Renamed to: {obj.name}\")\n\nbpy.ops.wm.save_mainfile()\n```\n\n### Example 3: Scene statistics report\n\n**User request:** \"Give me a summary of what's in this .blend file\"\n\n```python\nimport bpy\n\nprint(\"=== Scene Report ===\")\nprint(f\"Objects: {len(bpy.data.objects)}\")\nprint(f\"Meshes: {len(bpy.data.meshes)}\")\nprint(f\"Materials: {len(bpy.data.materials)}\")\nprint(f\"Textures: {len(bpy.data.images)}\")\nprint(f\"Scenes: {len(bpy.data.scenes)}\")\nprint(f\"Collections: {len(bpy.data.collections)}\")\n\ntotal_verts = sum(len(m.vertices) for m in bpy.data.meshes)\ntotal_faces = sum(len(m.polygons) for m in bpy.data.meshes)\nprint(f\"Total vertices: {total_verts:,}\")\nprint(f\"Total faces: {total_faces:,}\")\n\nfor obj in bpy.data.objects:\n    info = f\"  {obj.name} ({obj.type})\"\n    if obj.type == 'MESH':\n        info += f\" — {len(obj.data.vertices)} verts\"\n    print(info)\n```\n\n## Guidelines\n\n- Always use `--background` when running scripts from the terminal to avoid opening the GUI.\n- Start scripts with `clear_scene()` if building a scene from scratch to avoid leftover default objects.\n- Use `bpy.data` for direct data access (fast, reliable). Use `bpy.ops` for complex operations that mirror user actions (operators require correct context).\n- When using operators, ensure the correct object is active and selected: `bpy.context.view_layer.objects.active = obj` and `obj.select_set(True)`.\n- For batch processing, always save to a new file (not overwrite originals) unless the user explicitly requests in-place modification.\n- Import\u002Fexport operator names vary between Blender versions. The ones listed here work for Blender 3.6+. For older versions, check `dir(bpy.ops.import_scene)`.\n- Use `mathutils` for vector math, quaternions, and matrix operations — it's bundled with Blender's Python.\n- To debug, use `print()` statements — output goes to the terminal when running with `--background`.\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Fblender-scripting",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill blender-scripting",{"tool":40,"command":41},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill blender-scripting",{"tool":43,"command":44},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill blender-scripting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Fblender-scripting\u002FSKILL.md",true,[],[49,58,67,76,82,88],{"skillNo":50,"name":51,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":21},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[55,56,57],"model","model hierarchy","model hierarchy skill",{"skillNo":59,"name":60,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":21},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[64,65,66],"MCP","zoom","zoom mcp",{"skillNo":68,"name":69,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":21},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[73,74,75,65],"sdk","zoom apps sdk","apps",{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":21},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[78],{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":21},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[84],{"skillNo":89,"name":90,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":21},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[90]]