{"id":12085,"date":"2023-08-18T22:51:45","date_gmt":"2023-08-18T13:51:45","guid":{"rendered":"http:\/\/leavebehind.iobb.net\/wordpress\/?p=12085"},"modified":"2023-08-27T20:19:04","modified_gmt":"2023-08-27T11:19:04","slug":"blender-re-instantiate","status":"publish","type":"post","link":"http:\/\/leavebehind.mydns.jp\/wordpress\/2023\/08\/18\/blender-re-instantiate\/","title":{"rendered":"Blender:\u540c\u3058\u5f62\u72b6\u3092\u63a2\u3057\u3066\u30ea\u30f3\u30af"},"content":{"rendered":"\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4fdd\u6301(Preserve Instances)\u305b\u305a\u306b\u66f8\u304d\u51fa\u3055\u308c\u305fFBX\u30d5\u30a1\u30a4\u30eb\u3092Blender\u3067\u8aad\u307f\u8fbc\u3093\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9(Mesh\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30ea\u30f3\u30af)\u3092\u5fa9\u5143\u3057\u3066\u307f\u308b\u30c6\u30b9\u30c8\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1921\" height=\"1220\" src=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh.jpg\" alt=\"\" class=\"wp-image-12084\" srcset=\"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh.jpg 1921w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh-960x610.jpg 960w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh-700x445.jpg 700w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh-768x488.jpg 768w, http:\/\/leavebehind.mydns.jp\/wordpress\/wp-content\/uploads\/2023\/08\/blender_detect_similar_mesh-1536x975.jpg 1536w\" sizes=\"auto, (max-width: 1921px) 100vw, 1921px\" \/><\/figure>\n<\/div>\n\n\n<p>Mesh\u306e\u540c\u4e00\u6027\u306e\u6bd4\u8f03\u3068\u3057\u3066\u3001\u9802\u70b9\u6570\u3001\u30a8\u30c3\u30b8\u6570\u3001\u30d5\u30a7\u30fc\u30b9\u6570\u3068\u30d0\u30a6\u30f3\u30c7\u30a3\u30f3\u30b0\u30dc\u30c3\u30af\u30b9\u304c\u4e00\u81f4\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u6bd4\u3079\u3066\u3044\u307e\u3059\u3002\u7121\u7406\u3084\u308ahash\u3092\u53d6\u5f97\u3057\u3066\u6bd4\u8f03\u306e\u307b\u3046\u304c\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import bpy\nfrom pprint import pprint\ndef is_similar(obj_a, obj_b):\n    results = []\n    # compare componet count\n    mesh_a = obj_a.to_mesh()\n    mesh_b = obj_b.to_mesh()\n    results.append(len(mesh_a.vertices) == len(mesh_b.vertices))\n    results.append(len(mesh_a.edges) == len(mesh_b.edges))\n    results.append(len(mesh_a.polygons) == len(mesh_b.polygons))\n    # compare bounding box\n    for p in range(len(obj_a.bound_box)):\n        p_a = [c for c in obj_a.bound_box[p]]\n        p_b = [c for c in obj_b.bound_box[p]]\n        results.append(p_a == p_b)\n    return all(results)\n        \ndef sorting_similar_mesh(objects):\n    results =[[objects.pop(0)]]\n    \n    for obj in objects:\n        is_sim = False\n        for r in results:\n            if is_similar(obj, r[0]):\n                r.append(obj)\n                is_sim = True\n        if not is_sim:\n            results.append([obj])\n            \n    return results\ndef link_data_block(objects):\n    if len(objects) &lt;= 1:\n        return\n    origin = objects.pop(0)\n    for obj in objects:\n        obj.data = origin.data\nif __name__ == \"__main__\":\n    # get all objects has mesh data.\n    mesh_objects = [obj for obj in bpy.data.objects if type(obj.data) == bpy.types.Mesh]\n    # sort\n    results = sorting_similar_mesh(mesh_objects)\n    for r in results:\n        link_data_block(r)\n        <\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4fdd\u6301(Preserve Instances)\u305b\u305a\u306b\u66f8\u304d\u51fa\u3055\u308c\u305fFBX\u30d5\u30a1\u30a4\u30eb\u3092Blender\u3067\u8aad\u307f\u8fbc\u3093\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9(Mesh\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30ea\u30f3\u30af)\u3092\u5fa9\u5143\u3057\u3066\u307f\u308b\u30c6\u30b9\u30c8\u3067\u3059\u3002 Mesh\u306e\u540c\u4e00\u6027\u306e\u6bd4\u8f03\u3068\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[58,230],"class_list":["post-12085","post","type-post","status-publish","format-standard","hentry","category-cg","tag-blender","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8YSE4-38V","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/12085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=12085"}],"version-history":[{"count":4,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/12085\/revisions"}],"predecessor-version":[{"id":12100,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/12085\/revisions\/12100"}],"wp:attachment":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=12085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=12085"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=12085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}