Skip to content

Instantly share code, notes, and snippets.

@chepecarlos
Last active May 31, 2021 03:01
Show Gist options
  • Save chepecarlos/def48f6aeb7a75dafd78b255e171fc36 to your computer and use it in GitHub Desktop.
Save chepecarlos/def48f6aeb7a75dafd78b255e171fc36 to your computer and use it in GitHub Desktop.
Primer Demo de prueba echo en blender :)
# base https://docs.blender.org/api/blender_python_api_2_65_5/info_tutorial_addon.html
bl_info = {
"name": "pollo con papas",
"category": "Object",
}
import bpy
class ObjectCursorArray(bpy.types.Operator):
"""Object Cursor Array"""
bl_idname = "object.cursor_array"
bl_label = "pollo don papay"
bl_options = {'REGISTER', 'UNDO'}
total = bpy.props.IntProperty(name="Steps", default=2, min=1, max=100)
def execute(self, context):
scene = bpy.context.scene
for obj in scene.objects:
obj.location.x += 1.0
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(ObjectCursorArray.bl_idname)
# store keymaps here to access after registration
addon_keymaps = []
def register():
bpy.utils.register_class(ObjectCursorArray)
bpy.types.VIEW3D_MT_object.append(menu_func)
# handle the keymap
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)
kmi.properties.total = 4
addon_keymaps.append(km)
def unregister():
bpy.utils.unregister_class(ObjectCursorArray)
bpy.types.VIEW3D_MT_object.remove(menu_func)
# handle the keymap
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
# clear the list
del addon_keymaps[:]
if __name__ == "__main__":
register()
import bpy, os
bl_info = {
"name": "pollo con papas",
"category": "Object",
}
def ShowMessageBox(message = "", title = "Message Box", icon = 'INFO'):
def draw(self, context):
self.layout.label(text=message)
bpy.context.window_manager.popup_menu(draw, title = title, icon = icon)
class insertVideo(bpy.types.Operator):
bl_idname = "scene.invideo"
bl_label = "Insert Video"
def execute(self, context):
VideoActual = "/home/chepecarlos/2.VideoMusicales/demo/POP.mkv"
# bpy.context.area.type = 'SEQUENCE_EDITOR'
# FrameActual = bpy.context.scene.frame_current
if len(bpy.context.selected_sequences) > 0:
print("Insertando")
Inicio = bpy.context.selected_sequences[0].frame_final_start
Final = bpy.context.selected_sequences[0].frame_final_end
Canal = bpy.context.selected_sequences[0].channel + 1
bpy.ops.sequencer.sound_strip_add(filepath=VideoActual, frame_start=Inicio, channel=Canal)
bpy.context.selected_sequences[0].show_waveform = True
bpy.ops.sequencer.split(frame=Final, channel=Canal, type='SOFT', side='RIGHT')
bpy.ops.sequencer.delete()
# bpy.context.selected_sequences[0].use_proxy = True
else:
print("Selecione una pista")
ShowMessageBox("Selecione una pista", title="Error")
return{'FINISHED'}
class MyPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Panel ALSW"
bl_idname = "my.panel"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.label(text="Musica Velocidad")
row = layout.row()
row.operator("scene.invideo", text="Agregar Sonido MrTee")
def register():
bpy.utils.register_class(MyPanel)
bpy.utils.register_class(insertVideo)
def unregister():
bpy.utils.unregister_class(MyPanel)
bpy.utils.unregister_class(insertVideo)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment