0
$\begingroup$

i was making a addon and i have this problem , i was looking for two days ago and i have not found nothing , im so tired with this. i saw a lot of question about this but they are not help me

when i import my modules with a dot. the console show me about package parents ... if i use filepath , and i convert my scripts to zip, console show me that i dont write bpy.data.filepath because it is a code to execute things, but blender first load all the script ...

and i dont know that can i do whit this, i have spended all my day doing this . i hope u can understand me

i have 4 modules, or scripts with its respective functions

bl_info={
    "name":"Become to tree",
    "author":"Cristofer Erik Calvo Milla",
    "version":(1,0),
    "blend":(2,91,0),
    "location":"View3d>Tool",
    "description":"",
    "warning":"",
    "category":"Add Mesh"}
    
import bpy
import sys
import os
import importlib

from bpy.props import PointerProperty
from bpy.props import EnumProperty

from particles_to_leaves import system_particles
from Branch import Type_Trunk

class Panel_Maestro(bpy.types.Panel):
    bl_label="Generar rama"
    bl_idname="PT_PanelM"
    bl_space_type="VIEW_3D"
    bl_region_type='UI'                     #Dentro del view 3d donde se colocara?, en la UI
    bl_category='My_Tree_Addon'
    def draw(self,context):
        layout=self.layout
        row=layout.row()
        row.label(text="This is a Master Panel")
###############################################################################################
class layout_settings(bpy.types.Panel):
    bl_label="Tree Settings"                #Es para colocar el titulo en un panel en blender
    bl_idname="PT_PanelA"                   #Es el Id con el que se le identifica a un panel
    bl_space_type='VIEW_3D'                 #Donde se colocara? en el view_3d
    bl_region_type='UI'                     #Dentro del view 3d donde se colocara?, en la UI
    bl_category = 'Generar Forma'           #nombre como aparecera en el menú del panel, adema´ que se identifica como un tipo donde se pueden colocar datos, como Tool en la UI que al color category Tool, entraría dentro de Tool
    bl_parent_id='PT_PanelM'
    def draw(self,context):                 #Función para dibujar en los paneles desarrollados
        layout=self.layout
        box=layout.box()
        box.label(text="Options to trunk")
        box.operator("button.settings" , text='Become to Tree').action='Become_to_tree'
        box.operator("button.settings",text='Become to Mesh').action='Become_to_mesh'
        box.operator("button.settings",text='Become to Curve').action='Become_to_curve'

        scene=context.scene
        box2=layout.box()
        box2.label(text="Option to leafs")
        box2.prop(scene,"prop",text="leaf")
        box2.operator("button.settings" , text='Particles to leaves').action='Add_leaves'
###############################################################################################
class Button_settings(bpy.types.Operator):
    bl_label="Become"
    bl_idname="button.settings"
    bl_description='Data'
    
    action:EnumProperty(items=[
        ('Become_to_tree','Become to tree','Become to tree'),
        ('Become_to_mesh','Become to mesh','Become to mesh'),
        ('Become_to_curve','Become to curve','Become to curve'),
        ('Add_leaves','Add leaves','Add leaves')
    ])
    def execute(self,context):
        
        if self.action=='Become_to_tree':
            Type_Trunk()
        elif self.action=='Become_to_mesh':
            print("Become to mesh")
        elif self.action=='Become_to_curve':
            print("Become to curve")
        elif self.action=='Add_leaves':
            leaf_dropper=bpy.data.scenes["Scene"].prop
            system_particles(leaf_dropper)
        return{'FINISHED'}
###############################################################################################        
def path_modules():
    dir=os.path.dirname(bpy.data.filepath)
    if not dir in sys.path:
        sys.path.append(dir)
    import Become_branch
    import Branch
    import Find_Position
    import particles_to_leaves
#############################################################################################

classes=[Panel_Maestro,layout_settings,Button_settings]
def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.Scene.prop=PointerProperty(type=bpy.types.Object)
def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

if __name__ =="__main__":
    register()
    path_modules()
    #bpy.ops.wm.call_menu(name=PT_PanelM.bl_idname)

enter image description here

enter image description here

$\endgroup$
  • $\begingroup$ import Branch => from . import Branch. from Branch import Type_Trunk => from .Branch import Type_Trunk. $\endgroup$ – scurest Jan 13 at 17:51
  • $\begingroup$ i did what u told me , but i can't see my menu. i can add like a addon but i can't see it $\endgroup$ – Misha bytes Jan 13 at 18:20
  • $\begingroup$ It shows up for me in the sidebar of the 3D View. $\endgroup$ – scurest Jan 13 at 18:57
  • $\begingroup$ yes , but when i convert to a zip it is not show me :c , i m going to upload a image , i dont know what happen that it is not work :c $\endgroup$ – Misha bytes Jan 13 at 19:27
  • 1
    $\begingroup$ Thank u man , u are a genius thank u , I did not know why that happens . i spend two days looking for a solution <3 $\endgroup$ – Misha bytes Jan 13 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.