How to make proxy selected linked objects?

Hi there, i hope someone can help me.

I need to find a way to make the selected linked objects proxied with just one python command or a button.

I stumbled upon with this line of script, but don’t how to continue:

import bpy

for obj in bpy.context.selected_objects:

I appreciate for any help! Thanks!

So i try with this :



import bpy

for obj in bpy.context.selected_objects:
    bpy.ops.object.proxy_make()



But only the last selected object become the proxy. The other was not :frowning: any thoughts?

The last selected is the context object. Some operators work on only the context object, it appears proxy_make is one of them.

Try this.


import bpy
context = bpy.context
scene = context.scene

for obj in context.selected_objects:
    scene.objects.active = obj # make it the context object
    bpy.ops.object.proxy_make()

That’s wonderful! thank you so much batFINGER! It works!

So i’m trying to make a button for this script just below the Make Proxy button in the Relations tab, but nothing shows up on the tool shelf. Can you please point out my mistakes? By the way i’m copied some part of code from space_view3d_toolbar.py to implemented in this script. Thanks

import bpy

from bpy.types import Panel

class View3DPanel:
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    
class Proxified(View3DPanel, Panel):
    bl_category = "Relations"
    bl_context = "objectmode"
    bl_label = "Relations"

    context = bpy.context
    scene = context.scene

    for obj in context.selected_objects:
        scene.objects.active = obj # make it the context object
        bpy.ops.object.proxy_make()
    
    def draw(self, context):
        layout = self.layout
        
        col.label(text="Linked Objects:")
        col.operator("object.proxy_make", text="Make Proxy to All Selected")

Ok,

In the blender text editor open two files from the templates menu > python > Panel Simple , and Operator Simple

The code i posted goes in the execute method of the operator. (Get rid of context = bpy.context), see how you go from there.

The actual operation needs to be implemented as operator, then add that operator to the panel:

import bpyfrom bpy.types import Panel, Operator


    
class VIEW3D_PT_proxy_make_all(Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Relations"
    bl_context = "objectmode"
    bl_label = "Make Proxies"
    
    def draw(self, context):
        layout = self.layout
        layout.operator("object.proxy_make_all")




class OBJECT_OT_proxy_make_all(Operator):
    """Make proxies from all selected objects"""
    bl_idname = "object.proxy_make_all"
    bl_label = "Make Proxies"


    def execute(self, context):
        scene = context.scene
        for obj in context.selected_objects:
            scene.objects.active = obj # make it the context object
            bpy.ops.object.proxy_make()
        return {'FINISHED'}




def register():
    bpy.utils.register_module(__name__)




def unregister():
    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()

That’s awesome! Thank you CoDEmanX, and thanks for pointing it out batFINGER! :slight_smile: