It seems there is now way to bring this dialog box that Append and Link are using.
I've wrote some custom append operator by reworking the code from the previous answer, hope it will be useful.
import bpy
import os
bl_info = {
"name": "Blender Custom Append",
"author": "@Andrej730",
"version": (1, 0),
"blender": (2, 90, 0),
"location": "",
"description": "",
"warning": "",
"category": ""
}
def append_data_block(filepath, data_block_type, name, link=False, relative=False):
with bpy.data.libraries.load(filepath, link=link, relative=relative) as (data_from, data_to):
if name not in getattr(data_from, data_block_type):
return {
"data_block": None,
"msg": f"Data-block {data_block_type}/{name} not found in {filepath}"
}
getattr(data_to, data_block_type).append(name)
return {
"data_block": getattr(data_to, data_block_type)[0],
"msg": ""
}
class CustomBlendAppend(bpy.types.Operator):
"""Import a .blend file to append model from"""
bl_idname = "blend.custom_append"
bl_label = "Custom Blend Append"
bl_options = {'UNDO'}
filepath: bpy.props.StringProperty(
name="File Path", description="Filepath used to import from",
maxlen=1024, default="", subtype="FILE_PATH"
)
filter_glob: bpy.props.StringProperty(
default="*.blend",
options={'HIDDEN'},
)
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
def get_lib_groups(self, context):
l = [("0", "", "")]
if os.path.exists(self.filepath) and self.filepath.endswith('.blend'):
with bpy.data.libraries.load(self.filepath) as (data_from, data_to):
for data_block_type in dir(data_from):
data = getattr(data_from, data_block_type)
if data:
item = (data_block_type,) * 3
l.append(item)
return l
def get_lib_objects(self, context):
l = [("", "", "")]
if self.data_block_type != '0' and os.path.exists(self.filepath) and self.filepath.endswith('.blend'):
with bpy.data.libraries.load(self.filepath) as (data_from, data_to):
objects = getattr(data_from, self.data_block_type);
for o in objects:
l.append((o, o, o))
return l
data_block_type: bpy.props.EnumProperty(
name = "Data Block Type",
description = "List of data blocks in the .blend file",
items=get_lib_groups,
)
data_block: bpy.props.EnumProperty(
name = "List of objects in the .blend file",
description = "List of objects in the .blend file",
items=get_lib_objects,
)
def draw(self, context):
layout = self.layout
layout.label(text="Data Block Type")
layout.prop(self, "data_block_type", text = "", icon = "GROUP")
layout.label(text="Data Block")
layout.prop(self,'data_block', text = "")
def execute(self, context):
if self.data_block_type == "0":
self.report({"ERROR"}, "Select a data block type")
return {"CANCELLED"}
if self.data_block == "":
self.report({"ERROR"}, "Select a data block")
return {"CANCELLED"}
if not os.path.exists(self.filepath):
self.report({"ERROR"}, f"File not found:\n'{self.filepath}'")
return {"CANCELLED"}
db = append_data_block(self.filepath, self.data_block_type, self.data_block)
if not db['data_block']:
self.report({"ERROR"}, db["msg"])
return {"CANCELLED"}
props = context.scene.AppendedDatablockProps
props.data_block_type = self.data_block_type
props.data_block_name = db['data_block'].name
props.blend_filepath = self.filepath
print(db['data_block'], props.data_block_type, props.data_block_name, props.blend_filepath)
return {"FINISHED"}
class AppendedDatablockProps(bpy.types.PropertyGroup):
data_block_type: bpy.props.StringProperty(name="Data Block Type", default="")
data_block_name: bpy.props.StringProperty(name="Data Block Name", default="")
blend_filepath: bpy.props.StringProperty(name="Blend Filepth", default="")
def register():
bpy.utils.register_class(CustomBlendAppend)
bpy.utils.register_class(AppendedDatablockProps)
bpy.types.Scene.AppendedDatablockProps = bpy.props.PointerProperty(type=AppendedDatablockProps)
def unregister():
bpy.utils.unregister_class(CustomBlendAppend)
bpy.utils.unregister_class(AppendedDatablockProps)
del bpy.types.Scene.AppendedDatablockProps
if name == "main":
register()
```