I wrote a script and I have been focusing on the hologram button I made. I used the selected operator but the button only works when I select the object and then run the script
import bpy
mat = bpy.data.materials.new(name = "Hologram")
mat.diffuse_color = (0,0.519,0.800)
mat.specular_intensity = 0
mat.emit = 1
mat.use_transparency = True
mat.alpha = 0.503
ob = bpy.context.active_object
data = ob.data
def item_type_lst(self,context):
types={obj.type:obj.type for obj in context.scene.objects}
return [(obj,obj,"")for obj in types]
def item_type_obj(self,context):
return[(obj.name,obj.name,"") for obj in context.scene.objects if obj.type==context.scene.myEnumitem]
class SimpleOperator(bpy.types.Operator):
bl_idname="dh.simple_opt"
bl_label="Simple Operator"
def execute(self,context):
if len(ob.data.materials):
ob.data.materials[0] = mat
else:
ob.data.materials.append(mat)
ob.modifiers.new("part", type = 'PARTICLE_SYSTEM')
part = ob.particle_systems[0]
settings = part.settings
settings.frame_start = 4
settings.name = "Hologram"
settings.frame_end = 34
settings.lifetime = 250
settings.count = len(data.polygons)
settings.normal_factor = 0
settings.physics_type = 'NO'
settings.render_type = 'NONE'
settings.effector_weights.gravity = 0
settings.effector_weights.force = 0
D = bpy.data
test = "Hologram"
bpy.ops.texture.new()
text =bpy.data.textures[len(bpy.data.textures)-1]
part = bpy.data.particles[test]
tex = bpy.data.textures.new(test, 'BLEND')
bpy.data.textures[test].use_flip_axis = 'VERTICAL'
slot = part.texture_slots.add()
slot.texture = tex
return{'FINISHED'}
class View3dPanel():
bl_space_type="VIEW_3D"
bl_region_type="TOOLS"
bl_category="Tech"
class PanelA(View3dPanel,bpy.types.Panel):
bl_label="Holograms"
def draw(self,context):
layout=self.layout
layout.operator(operator = "dh.simple_opt",text = "Hologram",icon = "OUTLINER_DATA_LAMP")
self.layout.split()
self.layout.split()
self.layout.split()
col=layout.column(align = True)
col.label(text = "Mesh Objects")
col.operator(operator = "mesh.primitive_cube_add",text = "Cube",icon = "MESH_CUBE")
col.operator(operator = "mesh.primitive_cone_add",text = "Cone",icon = "MESH_CONE")
row=col.row(align = True)
row.operator(operator = "mesh.primitive_monkey_add",text = "Monkey",icon = "MESH_MONKEY")
row.operator(operator = "mesh.primitive_torus_add",text = "Torus",icon = "MESH_TORUS")
col.operator(operator = "mesh.primitive_cylinder_add",text = "Cylinder",icon = "MESH_CYLINDER")
class PanelB(View3dPanel,bpy.types.Panel):
bl_label="Panel B"
def draw(self,context):
layout=self.layout
layout=layout.box()
layout.label(text = "object list",icon = "SORTALPHA")
col=layout.column(align = False)
col.prop(data = context.scene,property = "myEnumitem")
col.prop(data = context.scene,property = "myEnumitem_obj")
bpy.types.Scene.myEnumitem=bpy.props.EnumProperty(name ="Obj Type",items=item_type_lst)
bpy.types.Scene.myEnumitem_obj=bpy.props.EnumProperty(name ="Object",items=item_type_obj)
if __name__=='__main__':
bpy.utils.register_module(__name__)
Thanks in advance