Last active
May 31, 2021 04:10
-
-
Save chepecarlos/36d79aad7b8da0afd7262f6b0b739dee to your computer and use it in GitHub Desktop.
Demo Agregar en Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", icon="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") | |
addon_keymaps = [] | |
def add_hotkey(): | |
wm = bpy.context.window_manager | |
kc = wm.keyconfigs.addon | |
if not kc: | |
return | |
km = kc.keymaps.new(name='Object Mode', space_type='EMPTY') | |
kmi = km.keymap_items.new("scene.invideo", 'P', 'PRESS', shift=True) | |
addon_keymaps.append((km, kmi)) | |
def register(): | |
bpy.utils.register_class(MyPanel) | |
bpy.utils.register_class(insertVideo) | |
add_hotkey() | |
def unregister(): | |
bpy.utils.unregister_class(MyPanel) | |
bpy.utils.unregister_class(insertVideo) | |
for km, kmi in addon_keymaps: | |
km.keymap_items.remove(kmi) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment