0
$\begingroup$

I am very new to scripting. My problem is that I want the panel to look like this: enter image description here

My code so far looks like this:

import bpy

class plm(bpy.types.Panel):
    bl_idname = "d"
    bl_label = "whatever"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = 'My 1st '
    def draw(self, context):
        layout = self.layout
        
        row = layout.row()
        row.label(text= "generate sphere based on xy positions")
        row.operator("mesh.primitive_uv_sphere_add")
        row = layout.row()

def register():
    bpy.utils.register_class(plm)
def unregister():
    bpy.utils.unregister_class(plm)
if __name__ == "__main__":
    register()

I want when the user clicks the icon to browse and select the file and the when it presses the (in this case sphere) button to generate the meshes based on the positions from the file.

I already have code to generate cubes and other meshes.

def genc(i,s,x,y):
    bpy.ops.mesh.primitive_plane_add(size=0.01, enter_editmode=False, align='WORLD', location=(x, y, 0), scale=(1,1,1))
    bpy.context.object.scale = s

The only problem is the panel, the icon click.

Thanks.

$\endgroup$
2
  • $\begingroup$ you need to add an Operator class that executes your cvs read and cube gen code and replace mesh.primitive_uv_sphere_add in you draw function with the name of that class from its bl_idname. $\endgroup$ Commented Apr 2, 2022 at 15:44
  • $\begingroup$ You also need code for the part of the layout that has the filebrowser input. $\endgroup$ Commented Apr 2, 2022 at 16:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.