0

I wanted to draw this Object selector layout using Python Script and Retrive the Selected Object Also Apply the Modifier to Selected Object

Screenshot

I have Tried this from the another question asking for same thing but that is not working

import bpy



class Test_PT_layout_panel(bpy.types.Panel):
    bl_label = "Prop Panels"
    bl_category = "Test Panel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "output"

    def draw(self, context):
        layout = self.layout
        string_property = PointerProperty(type=bpy.types.Object)
        col = layout.column()
        col.prop(scene, "string_property", context.scene, "objects")


def register():
    bpy.utils.register_class(Test_PT_layout_panel)


def unregister():
    bpy.utils.unregister_class(Tests_PT_layout_panel)





if __name__ == "__main__":
    register()
Rakesh choudhary
  • 467
  • 5
  • 25
  • 2
    Enable developer tools in user preferences. Right click on UI element and choose view source to open the python source of the UI in the text editor. – batFINGER Nov 24 '19 at 15:13
  • I am Not able to See or Understand Much in Source code col.label(text="Object:") col.prop("md, object", text="") I have seen These two Lines about this thing in source code but not understood How to add that Out of Modifier – Rakesh choudhary Nov 24 '19 at 15:37
  • 3
    I'd like to remind you that StackExchange is a Q&A site that values questions that show that an effort has been made to solve the issue before posting. This is explained in Search and research "How to ask a good question". – Robert Gützkow Nov 24 '19 at 15:47
  • 1
    Related question https://blender.stackexchange.com/questions/30487/object-selection-box-with-eyedropper – Robert Gützkow Nov 24 '19 at 15:50
  • @Robert Gutzkow Thats What I wanted thank you for Posting Link to that Question Now Let me Try it – Rakesh choudhary Nov 24 '19 at 16:04
  • 2
    Tested the code of the dupe, I don't have any trouble. Where your "string_property" is defined? – brockmann Nov 24 '19 at 20:58
  • Ok I edited this question and now string_property = PointerProperty(type = bpy.types.Object) but still it do not create that type of object selector layout – Rakesh choudhary Nov 25 '19 at 11:51
  • 1
    Either use col.prop_search(scene, "string_property", context.scene, "objects") or col.prop(scene, "pointer_property") (note the difference, coding is about attention to detail) Btw define your pointer property in the register method. The draw method is for drawing UI. – batFINGER Nov 25 '19 at 12:03
  • You forgot to "register" your property to any bpy type like the actual scene. Add bpy.types.Scene.string_property = bpy.props.PointerProperty(type=bpy.types.Object) to register() and col.prop(scene, "string_property") to your draw() method @Rakeshchoudhary – brockmann Nov 25 '19 at 12:06
  • More about Add-on development here: How to create a custom UI? – brockmann Nov 25 '19 at 12:08
  • sorry to be silly can anyone answer me somewhat descriptively so i could understand – Rakesh choudhary Nov 25 '19 at 14:54
  • Added answer to dupe. Please take some time to evaluate the changes between script above and script there. To reiterate, coding is attention to detail. – batFINGER Nov 25 '19 at 16:29

0 Answers0