0
$\begingroup$

I'm working on free Addons named "Arc Blend" . I'm stuck a little...

My question is:

I have a PointerProperty group on my Mesh. And I add new property as mesh data. But I don't know how I can Handle this problem: I want to display just other meshes. How i can reach my PropertyGroup's queue(order) and automatically change my mesh For instance: 1.th is "Cube" to "Suzanne" 2.nd is "Suzanne" to "Other Mesh" using "display boolean icon"

problem

def proxy_display_upd(self,context): 

         
    if self.proxy_display == False: bpy.context.object.data =bpy.data.meshes["Cube"]

    elif self.proxy_display== True: bpy.context.object.data = bpy.data.meshes["Suzanne"]

proxy_display=bpy.props.BoolProperty(default=False,description="Display in Viewport",update=proxy_display_upd)
 
$\endgroup$
2
  • $\begingroup$ Hello, you can do if self.proxy_display: ... else: ... $\endgroup$
    – Gorgious
    Commented Jul 27, 2022 at 15:13
  • $\begingroup$ Thanks for the comment Gorgious. I change that lines are clear now. $\endgroup$
    – H3pron
    Commented Jul 27, 2022 at 16:00

1 Answer 1

-1
$\begingroup$

Ok I found a solution for this:

def return_one_time(mesh, active_idx, prop_api):
    """Returning once per elements"""
    AB_list = mesh.mesh_list

    for i in AB_list:
        if i.proxy_ui_index != active_idx:
            exec(f"i.{prop_api}= False")
    return None


def proxy_display_upd(self, context):

    if self.proxy_display == True:
        return_one_time(self.id_data, self.proxy_ui_index, "proxy_display")

    selected_objects = bpy.context.selected_objects

    if len(selected_objects) > 1:
        try:
            for i in range(0, len(selected_objects)):
                o = []

                disp_list = list(
                    bpy.data.meshes[f"{bpy.context.active_object.proxy_item_obj.name}"].mesh_list)

                for j in disp_list:

                    o.append(j.proxy_display)

                    true_count = sum(o)

                if true_count == 1:

                    selected_objects[i].data = bpy.data.meshes[self.proxy_item.name]

                # if proxy_display is off than active objects change to first object
                elif true_count == 0:

                    selected_objects[i].data = bpy.data.meshes[
                        f"{bpy.context.active_object.proxy_item_obj.name}"]

        except AttributeError:
            pass

    elif len(selected_objects) <= 1:

        try:
            for i in range(0, len(bpy.data.meshes[f"{bpy.context.active_object.proxy_item_obj.name}"].mesh_list)):
                o = []

                disp_list = list(
                    bpy.data.meshes[f"{bpy.context.active_object.proxy_item_obj.name}"].mesh_list)

                # All list item append to "o"list and count the "True"
                for j in disp_list:

                    o.append(j.proxy_display)

                    true_count = sum(o)

                # if proxy_display is on than selected objects change
                if true_count == 1:

                    bpy.context.object.data = bpy.data.meshes[self.proxy_item.name]

                # if proxy_display is off than active objects change to first object
                elif true_count == 0:

                    bpy.context.object.data = bpy.data.meshes[
                        f"{bpy.context.active_object.proxy_item_obj.name}"]

        except AttributeError:
            pass

    return None
```
$\endgroup$
2
  • $\begingroup$ Hello, I down voted because your code does the same thing in both if cases, and you should be using if self.proxy_display: ... else: ... instead of evaluating if self.proxy_display == True or False. And you don't need to return None since it's the default return value. $\endgroup$
    – Gorgious
    Commented Jul 27, 2022 at 15:50
  • $\begingroup$ Thanks for the comment Duerte Frarrajota Ramos.(I'm so new in here didn't know that.) Thanks for the another comment and reply Gorgious. Now new lines are clear... $\endgroup$
    – H3pron
    Commented Jul 27, 2022 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .