메시를 내보내기 전에 결합하고 복제 하시겠습니까?
개체를 FBX 파일 형식으로 내보내는 추가 기능을 작성 중입니다.
그 기능 중 하나는 내보내기를 위해 다른 개체를 병합하는 기능입니다. 따라서 사용자는 object를 선택 A하고 "choose merge object"버튼을 클릭 한 다음 object를 클릭합니다 B. 내보내기 중에 개체는 Ctrl+ J유형 작업에 따라 결합되고 단일 개체로 내 보낸 다음 모든 것이 정상으로 복원됩니다 (다시 2 개 개체).
이것은 내 생각입니다.
- 두 개체 복제-나머지 단계는 복사본을 처리합니다.
 - 설정 
B선택으로A활성 상태로 - 사용하다 
bpy.ops.object.join() - 내보내기 
A(active_object) - 지우다 
A 
누군가가 그것에 대해 아는 것이 있다면 이것에 대해 몇 가지 질문이 있습니다 ..
X . 임시를 생성하고 나중에 삭제할 필요가없는 대안이 있습니까? 개체는 상상할 수있는 복잡성 일 수 있으므로 입력을 읽기 전용으로 사용하는 방법이 더 좋습니다. 대체 합병? A+B=C대신 A+=delete(B)?
편집 : 나중에 개체를 링크 (메시 데이터를 복사하지 않음)로 복제 한 다음 해당 연결된 복제를 join ()에 대한 입력 개체로 사용할 수 있음을 알게되었습니다. 이는 메시 데이터가 복제되지 않기 때문에 임시를 생성 할 필요가없는 것과 매우 유사합니다.
Y.를 사용하는 위의 시나리오 join()에서의 임시 사본이 B자동으로 삭제됩니까? join()후드 아래에서 어떻게 작동 하는지 확실하지 않습니다 . 그리고 코드에서 삭제 된 객체 참조를 엉망으로 만드는 것에 대해 약간 걱정했습니다.
편집 : 예, 활성 개체를 제외한 모든 입력 개체는 join ()에 의해 삭제됩니다.
어떤 조언이라도 정말 감사합니다. 저는 파이썬과 애드온 개발을 처음 접했기 때문에 세부 사항도 높이 평가됩니다.
답변
우리의 오랜 친구 인 Undo 의 직업처럼 들립니다 . 당신은 할 수 는 확실히 복잡하게 ,하지만 작업이 어쨌든 메모리에 있기 때문에, 그것은 꽤 빨리 그것을해야한다.
import bpy
from bpy.props import (BoolProperty, FloatProperty, StringProperty)
from bpy.types import (Operator)
from bpy_extras.io_utils import ExportHelper
# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
class EXPORT_OT_customFBX(Operator, ExportHelper):
    """Export the scene to FBX"""
    bl_idname = "export_scene.custom_fbx"
    bl_label = "Export FBX"
    # ExportHelper mixin class uses this
    filename_ext = ".fbx"
    filter_glob: StringProperty(
        default="*.fbx",
        options={'HIDDEN'},
        maxlen=255,  # Max internal buffer length, longer would be clamped.
    )
    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    global_scale: FloatProperty(
        name="Scale",
        description="Scale",
        default=1.0,
    )
    use_subsurf: BoolProperty(
        name="Use Subsurf",
        description="Use Subsurf",
        default=False,
    )
    apply_unit_scale: BoolProperty(
        name="Apply Unit Scale",
        description="Use Subsurf",
        default=True,
    )
    def execute(self, context):
        viewport_selection = [o for o in context.selected_objects if o.type == 'MESH']
        if len(viewport_selection) == 2:
            if context.active_object in viewport_selection:
                # Join! 
                # https://blender.stackexchange.com/q/13986
                # https://blender.stackexchange.com/q/50160
                bpy.ops.object.join()
            else:
                print ("Can not call join operator")
        else:
            print ("Nothing to join.")
        # Export
        bpy.ops.export_scene.fbx(
                filepath=self.filepath,
                global_scale=self.global_scale, 
                apply_unit_scale=self.apply_unit_scale, 
                use_subsurf=self.use_subsurf,
                use_metadata=True, 
                axis_forward='-Z', 
                axis_up='Y'
            )
        # Undo!
        bpy.ops.ed.undo()
        return {'FINISHED'} 
# Only needed if you want to add into a dynamic menu
def draw_export_fbx(self, context):
    self.layout.operator(EXPORT_OT_customFBX.bl_idname, text="Custom FBX (.fbx)", icon="MESH_MONKEY")
# Registration
classes = (
    EXPORT_OT_customFBX,
)
def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
    bpy.types.TOPBAR_MT_file_export.prepend(draw_export_fbx)
def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
    bpy.types.TOPBAR_MT_file_export.remove(draw_export_fbx)
if __name__ == "__main__":
    register()
    # test call
    bpy.ops.export_scene.custom_fbx('INVOKE_DEFAULT')
 
     연산자는 템플릿> Python> 연산자 파일 내보내기를 기반으로합니다.
또 다른 지루한 방법 은 fbx로 내보내기 전에 파일을 저장 한 다음 블렌드를 다시로드하는 것입니다.
def execute(self, context):
    # Save!
    if bpy.data.is_dirty:
        bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)
    viewport_selection = [o for o in context.selected_objects if o.type == 'MESH']
    if len(viewport_selection) == 2:
        if context.active_object in viewport_selection:
            # Join! # https://blender.stackexchange.com/q/13986
            bpy.ops.object.join()
        else:
            print ("Can not call join operator")
    else:
        print ("Nothing to join.")
    # Export
    bpy.ops.export_scene.fbx(
            filepath=self.filepath,
            global_scale=self.global_scale, 
            apply_unit_scale=self.apply_unit_scale, 
            use_subsurf=self.use_subsurf,
            use_metadata=True, 
            axis_forward='-Z', 
            axis_up='Y'
        )
    # Reload
    bpy.ops.wm.open_mainfile(filepath=bpy.data.filepath)
    return {'FINISHED'} 
 
     메모리에서 둘 다의 실행 시간을 측정하기 위해 몇 가지 테스트를 수행하는 것이 좋을 것입니다.
블렌더 내에서 개체를 결합 할 필요가 전혀 없습니다. 당신 이후로? fbx 내보내기 코드를 작성하고 두 메시에 대한 삼각형 / 텍스처 / 애니메이션 데이터를 직접 병합하고 fbx 형식으로 단일 객체로 작성하면됩니다.