### Loading a JavaScript Root Object with Python Callback Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_javascript_root_object.html Demonstrates loading a JavaScript string that defines a UI setup function and connecting a Python callback to a button's press event. This example illustrates the interoperability between JavaScript and Python in Harmony scripting. ```python from ToonBoom import harmony sess = harmony.session() js = sess.javascript js_string = """ function setupUI( pythonFunc ) { var mainWidget = new QWidget(); var button = new QPushButton( mainWidget ); var layout = new QHBoxLayout(); mainWidget.setLayout(layout); layout.addWidget(button, 1, 0); button.text = "Hello World" button.pressed.connect( pythonFunc.call ); mainWidget.show(); return mainWidget; } " def myCallbackFunction(): print( "Hello Python World" ) js_obj = js.load_string( js_string ) #Initialize the JS UI with a Python callback function. js_obj["setupUI"].call( myCallbackFunction ) #Clicking the button will result in the Python Function to be called. ``` -------------------------------- ### ExportOGLMovieSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_o_g_l_movie_settings.html Initializes settings for exporting OGL movies. All parameters are optional and have default values. ```APIDOC ## ExportOGLMovieSettings Constructor ### Description Initializes settings for exporting OGL movies. All parameters are optional and have default values. ### Parameters #### Path Parameters - **i_file_path** (QString) - Optional - The complete file path to the generated file. - **i_file_name** (QString) - Optional - The file name of the generated movie. - **i_start_frame** (int) - Optional - The first frame to be exported. Defaults to 1. - **i_end_frame** (int) - Optional - The last frame to be exported. Defaults to the last frame of the scene. - **i_width** (int) - Optional - The horizontal pixel resolution. Defaults to the width resolution of the scene. - **i_height** (int) - Optional - The vertical pixel resolution. Defaults to the height resolution of the scene. - **i_sound** (bool) - Optional - Export with sound if option is available. Defaults to true. - **i_alpha** (bool) - Optional - Export with alpha if option is available. Defaults to true. - **i_stereo** (bool) - Optional - True if the exported file contains the left and right sound channels. Defaults to true. - **i_audio_channel_size** (int) - Optional - The sound channel bit rate (either 8 or 16 bits per second). Defaults to 16. - **i_audio_sample_rate** (int) - Optional - The audio sample rate. Defaults to 22050. ### Request Example ```python from ToonBoom import harmony # Example usage with some parameters specified movie_settings = harmony.ExportOGLMovieSettings( i_file_path=r"C:/myPath/", i_file_name='TheMovie', i_start_frame=1, i_end_frame=100, i_width=1920, i_height=1080, i_sound=True, i_alpha=False, i_stereo=False, i_audio_channel_size=16, i_audio_sample_rate=44100 ) ``` ``` -------------------------------- ### from_parameter Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_bezier.html Gets or sets the starting parameter of the Bezier curve, which defines the point where interpolation begins. ```APIDOC ## from_parameter ### Description Gets and sets the Bezier's from parameter. This is the point at which the Bezier begins to interpolate when evaluated. ### Method `double OMC::Bezier::from_parameter` ### Access readwrite ``` -------------------------------- ### Get Peg Node Pivot in Python Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_peg_node.html Retrieves the pivot of a PegNode at a specified frame. This example shows how to import the Harmony module, access the project and scene, find a specific peg node, and then get its pivot at a given frame. ```python from ToonBoom import harmony sess = harmony.session() proj = sess.project scene = proj.scene peg = scene.nodes["Top/Peg"] frame = 1 pivot = peg.pivot( frame, False ) print( "Pivot at frame %s : %s %s %s"%(frame, pivot.x, pivot.y, pivot.z) ) ``` -------------------------------- ### ExportWMVSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_w_m_v_settings.html Initializes an ExportWMVSettings object. All parameters are optional and have default values. ```APIDOC ## Constructor ### ExportWMVSettings() Initializes an ExportWMVSettings object with optional parameters for file path, file name, video bitrate quality, bit rate, start and end frames, width, height, and audio/alpha settings. #### Parameters - **_i_file_path_** (QString) - Optional - The path for the output file. - **_i_file_name_** (QString) - Optional - The name for the output file. - **_i_vbr_quality_** (int) - Optional - The video bitrate quality (default: 80). - **_i_bit_rate_** (int) - Optional - The bit rate in bits per second (default: 20000000). - **_i_start_frame_** (int) - Optional - The starting frame for export (default: 1). - **_i_end_frame_** (int) - Optional - The ending frame for export (default: -1, meaning last frame). - **_i_width_** (int) - Optional - The width of the exported video (default: -1, meaning automatic). - **_i_height_** (int) - Optional - The height of the exported video (default: -1, meaning automatic). - **_i_sound_** (bool) - Optional - Whether to include sound (default: true). - **_i_alpha_** (bool) - Optional - Whether to include alpha channel (default: true). - **_i_stereo_** (bool) - Optional - Whether to export in stereo (default: true). - **_i_audio_channel_size_** (int) - Optional - The audio channel bit size (default: 16). - **_i_audio_sample_rate_** (int) - Optional - The audio sample rate (default: 22050). ``` -------------------------------- ### OMC::Bezier::to_parameter Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_bezier.html Gets or sets the parameter value of a Bezier curve. This parameter indicates the starting point for interpolation. ```APIDOC ## OMC::Bezier::to_parameter ### Description Gets or sets the parameter value of a Bezier curve. This is the point at which the Bezier begins to interpolate when evaluated. ### Method readwrite ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **parameter** (double) - The interpolation parameter value. ### Request Example None ### Response Example None ``` -------------------------------- ### Render Handler with Frame-Ready Callback Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_cel.html This example demonstrates how to set up a render handler with a callback function to process frames as they are rendered. It includes a helper class to display the rendered images. ```python from PySide6.QtGui import QPixmap, QScreen from PySide6.QtWidgets import QApplication, QWidget, QLabel, QSizePolicy, QVBoxLayout import tempfile import math import os from ToonBoom import harmony #Import the Harmony Module #Helper Class to Render the Results into -- this is pure PySide Qt class ImageShow(QWidget): def __init__(self): super().__init__() self.init() def init(self): self.setWindowTitle( "Render-Tester" ) self.label = QLabel(self) self.pixmap = QPixmap() def setImage(self, path, title, frame, count): self.setWindowTitle( title ) frmn = frame-1 #0-indexed frame squared = int(math.sqrt(count)+0.5) offsetx = frmn%squared offsety = int(frmn/squared) screenSize = QScreen.availableGeometry( QApplication.primaryScreen() ) width_target = screenSize.width()/squared height_target = screenSize.height()/squared self.resize( width_target, height_target ) self.pixmap.load( path ) self.label.setPixmap( self.pixmap.scaled( self.width(), self.height() ) ); frmX = ( screenSize.width () - self.width () ) / 2.0 frmY = ( screenSize.height() - self.height() ) / 2.0 self.move( offsetx*width_target, offsety*height_target ) self.show() def resizeEvent( self, event ): self.label.setPixmap( self.pixmap.scaled( self.width(), self.height() ) ) self.label.resize( self.width(), self.height() ) sess = harmony.session() #Get access to the Harmony session, this class. proj = sess.project #Get the active session's currently loaded project. scene = proj.scene #Get the top scene in the project. nodes = scene.nodes readnode = False #This will keep the displayers alive -- otherwise they'll open and close as it leaves the method. displayers = [] #Find the first avbailable read node. for node in nodes: if node.type.upper() == "READ": readnode = node break if readnode: print( "Rendering %s"%(readnode.path) ) renderhandler = proj.create_render_handler() #Create a new render handler. frame_count = 25 def renderhandler_ready_frame( node, frame, cel ): #This will be the callback function displayer = ImageShow() #A helper utility for showing the rendered images. displayers.append( displayer ) #Keep it alive. print( "Frame Ready : %s at %s"%(node.path, frame) ) #The callback provides a frame. frame_output = os.path.join( tempfile.gettempdir(), "%s.%05d.png"%(node.name, frame) ) print( "Saving to: %s"%(frame_output) ) cel.write( frame_output ) #Write the cel to a temp directory. #Show it! displayer.setImage( frame_output, "%s at %s"%(node.path, frame), frame, frame_count ) renderhandler.frame_ready_callback = renderhandler_ready_frame #Add the callback function to the handler. renderhandler.node_add( readnode ) #Add the readnode to the list of nodes to render. renderhandler.render( 1, frame_count ) #Render the frames 1-10 else: print( "Unable to find a Read Node to render." ) ``` -------------------------------- ### OMC::Drawing::pivot Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_drawing.html Gets or sets the pivot point of a drawing. Setting the pivot to Null or None will unset it. The example demonstrates setting the pivot for a vector drawing after converting units. ```APIDOC ## ◆ pivot OMC::Drawing::pivot ### Description Gets or sets the pivot point of the drawing. Setting the pivot to Null or None will result in the pivot being unset. ### Method GET/SET ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pivot** (Point2d or None) - Required - The pivot point to set for the drawing. ### Request Example ```python # Assuming 'vector_drawing' is a valid drawing object and 'target_drawing_point' is a Point2d object vector_drawing.pivot = target_drawing_point ``` ### Response #### Success Response (200) - **pivot** (Point2d) - The current pivot point of the drawing. #### Response Example ```json { "pivot": { "x": 10, "y": 5 } } ``` ``` -------------------------------- ### Initialize and Use Harmony Render Handler Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_harmony_render_handler.html This snippet demonstrates how to initialize the Harmony session, get the active project, create a render handler, and add a node for rendering. It shows how to set the handler to block the application and then initiate the render process. ```python from ToonBoom import harmony sess = harmony.session() proj = sess.project render_handler = proj.create_render_handler() render_handler.blocking = True scn = proj.scene node = scn.nodes["Top/Write"] print( "Rendering : %s"%(node) ) if node: render_handler.node_add( node ) render_handler.render() print( "COMPLETE!" ) ``` -------------------------------- ### Get Bool Attribute Value at Frame Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_bool_attribute.html Retrieves the boolean value of an attribute at a specific frame. If a column is linked, its value is used; otherwise, the local value is returned. This example demonstrates how to access and print the value of a non-animateable boolean attribute. ```python from ToonBoom import harmony sess = harmony.session() proj = sess.project scene = proj.scene node = scene.nodes["Top/Node"] bool_attribute_keyword = "ENABLE_3D" attribute = node.attributes[bool_attribute_keyword] if attribute: at_frame = 1 current_value = attribute.value(at_frame) print( "VALUE AT FRAME %s : %s"%( at_frame, current_value ) ) else: print( "Unable to find attribute by keyword: %s"%(bool_attribute_keyword) ) ``` -------------------------------- ### Setting the Project to a Named Resolution Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_project_resolution.html This example shows how to set the project's resolution to a predefined named resolution like 'HDTV'. ```APIDOC ## ◆ default_name | QString OMC::ProjectResolution::default_name --- readwrite The default resolution name, if one is being used. The default_name is used to get the preset name of the project's resolution, or set it to a named resolution. **Setting theProject to a Named Resolution** from ToonBoom import harmony #Import the Harmony Module sess = harmony.session() #Get access to the Harmony session, this class. proj = sess.project #Get the current project. resolution = proj.resolution #The resolution object. resolution.default_name = "HDTV" #Set the resolution to the HDTV preset. ``` -------------------------------- ### Functions starting with 'b' Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/functions_func_b.html This section lists functions in the Harmony 24 Python Interface that start with the letter 'b'. ```APIDOC ## Functions starting with 'b' ### Description Provides access to various functions related to history, bezier paths, and render handling. ### Functions - **begin()** : OMC::History - Description: Starts a new history entry. - **bezier()** : OMC::BezierPath - Description: Creates a new Bezier path object. - **bezier_append()** : OMC::BezierPath - Description: Appends a Bezier curve to an existing path. - **bezier_append_front()** : OMC::BezierPath - Description: Appends a Bezier curve to the front of an existing path. - **bezier_degree()** : OMC::BezierPath - Description: Gets the degree of a Bezier curve. - **bezier_set()** : OMC::BezierPath - Description: Sets the control points of a Bezier curve. - **block_until_complete()** : OMH::HarmonyRenderHandler - Description: Blocks execution until a render job is complete. ``` -------------------------------- ### Create, Remove, and Monitor Palette List Size Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_list.html Demonstrates how to create a new palette, monitor the list size to confirm insertion, remove the palette, and verify its removal by checking the list size again. ```python list_initial_size = palette_list.size() # Create a new Palette: new_palette_type = 'Pencil Texture' new_pencil_texture_palette = palette_list.create(new_palette_type) # Size increase if list_initial_size + 1 == palette_list.size(): print("New palette inserted.") # remove palette_list.remove(new_pencil_texture_palette) # Size increase if list_initial_size == palette_list.size(): print("Palette removed.") ``` -------------------------------- ### Get and Set Color Object Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the OMC::Colour object associated with the gradient position. ```python color_obj = first_gradient_position.colour new_color = harmony.Colour(0, 255, 0) first_gradient_position.colour = new_color ``` -------------------------------- ### Create New Palette and Add Colors/Textures Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette.html Demonstrates creating a new color palette, adding a solid red color, and a texture color. It also shows how to list the names of colors within the palette. ```python from ToonBoom import harmony palette_list = harmony.session().project.palettes # Clear the palette list of palettes (Optional) palette_list.clear() # Create a new colour palette (it already comes with a default colour, with the name 'Default'): new_palette_type = 'Colour' new_palette_name = 'Colour_Palette_Name' new_colour_palette = palette_list.create(new_palette_type,new_palette_name) # Create a new solid red palette colour: new_colour_name = 'Red_Colour' newSolidRedPaletteColour = new_colour_palette.create_solid_colour(new_colour_name,[255,0,0,255]) # Create a new texture palette: new_texture_file_path = r'.../pathToTexture/texture.png' new_texture_name = 'Texture_Colour' new_texture_palette_colour = new_colour_palette.create_texture(new_texture_file_path,new_texture_name) # List palette contents: for palette_colour in new_colour_palette: print(palette_colour.name) ``` -------------------------------- ### start_frame_src Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_paste_options.html When pasting external or local content, this function controls the start frame of the content that will be pasted. The default start frame is 1. Set to a value >= 1 to specify the frame to use as a starting frame. Must be using the paste special mode. ```APIDOC ## start_frame_src ### Description When pasting an external template or local content, this functions controls the start frame of the content that will be pasted. The default start frame is 1, which means that it will be pasting starting from the first frame of the copied content. Set this to a value >= 1 to specific the frame to use as a starting frame. Must be using the paste special mode. ### Type int ``` -------------------------------- ### ExportWMVSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_w_m_v_settings.html Initializes the ExportWMVSettings object with various parameters for WMV export. All parameters are optional and have default values. ```APIDOC ## ExportWMVSettings Constructor ### Description Initializes the ExportWMVSettings object with various parameters for WMV export. All parameters are optional and have default values. ### Signature ExportWMVSettings(QString i_file_path="", QString i_file_name="", int i_vbr_quality=80, int i_bit_rate=20000000, int i_start_frame=1, int i_end_frame=-1, int i_width=-1, int i_height=-1, bool i_sound=true, bool i_alpha=true, bool i_stereo=true, int i_audio_channel_size=16, int i_audio_sample_rate=22050) ### Parameters - **i_file_path** (QString) - Optional - The complete file path to the generated file. - **i_file_name** (QString) - Optional - The file name of the generated movie. - **i_vbr_quality** (int) - Optional - The quality percentage of the exported video. Defaults to 80. - **i_bit_rate** (int) - Optional - The bits per second. Defaults to 20000000. - **i_start_frame** (int) - Optional - The first frame to be exported. Defaults to 1. - **i_end_frame** (int) - Optional - The last frame to be exported. Defaults to -1 (last frame of the scene). - **i_width** (int) - Optional - The horizontal pixel resolution. Defaults to -1 (width resolution of the scene). - **i_height** (int) - Optional - The vertical pixel resolution. Defaults to -1 (height resolution of the scene). - **i_sound** (bool) - Optional - Export with sound if option is available. Defaults to true. - **i_alpha** (bool) - Optional - Export with alpha if option is available. Defaults to true. - **i_stereo** (bool) - Optional - True if the exported file contains the left and right sound channels. Defaults to true. - **i_audio_channel_size** (int) - Optional - The sound channel bit rate (either 8 or 16 bits per second). Defaults to 16. - **i_audio_sample_rate** (int) - Optional - The audio sample rate. Defaults to 22050. ``` -------------------------------- ### create() Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_backdrop_list.html Adds a new backdrop to the list. It can accept details for the backdrop as a QVariant, which might include text, another backdrop's data, or allocated 2D rectangle information. ```APIDOC ## create() ### Description Adds a backdrop, accepting a text value, another backdrop or a OMC::AllocatedRect2D. ### Method OMC::Obj create(const QVariant & _backdropDetails_ = QVariant()) ### Parameters #### Request Body - **_backdropDetails_** (QVariant) - Optional - Details for the new backdrop. ``` -------------------------------- ### Set Scene Frame Start Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_scene.html Change the temporary start frame of the scene. This affects where the playhead begins and restarts during looping. ```python from ToonBoom import harmony sess = harmony.session() proj = sess.project scene = proj.scene scene.frame_start = 10 ``` -------------------------------- ### launch() Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_harmony_module.html Launches an instance of Harmony if none is currently available. This is a prerequisite for accessing Harmony global objects and subsequently opening projects. ```APIDOC ## launch() ### Description Launches the instance of Harmony if none is available. Launching an instance of harmony allows access to specific Harmony global objects, further access to a scene will require a project to be opened. Note When using open_project, or open_project_database – an instance of Harmony will be launched if no other instance is available ``` -------------------------------- ### Get and Set Preference by Name Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_preferences.html Allows direct access to get and set preference values using their string names. ```APIDOC ## operator[QString &name]() ### Description Get and set a preference by name. ### Method `OMC::PreferencePair* operator[QString &name](const QString &name)` ### Parameters #### Path Parameters - **name** (QString) - The name of the preference to get or set. ``` -------------------------------- ### Get and Set Hex Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the color's hexadecimal representation in the format #AARRGGBB. ```python hex_value = first_gradient_position.hex first_gradient_position.hex = "#FF0000FF" ``` -------------------------------- ### Create and Manage Color Palettes Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette.html Demonstrates creating a new color palette, adding solid colors with RGBA values, and listing the colors within the palette. This is useful for setting up custom color schemes. ```python from ToonBoom import harmony palette_list = harmony.session().project.palettes # Clear the palette list of palettes (Optional) palette_list.clear() # Create a new colour palette (it already comes with a default colour, with the name 'Default'): new_palette_type = 'Colour' new_palette_name = 'Colour_Palette_Name' new_colour_palette = palette_list.create(new_palette_type,new_palette_name) #Add colours to the Colour Palette new_colour_palette.create_solid_colour("Yellow",[255,255,0,255]) new_colour_palette.create_solid_colour("Magenta",harmony.Colour([255,0,255,255]),0) # List palette colours: for palette_colour in new_colour_palette: print(palette_colour.name) #Magenta #Default #Yellow ``` -------------------------------- ### Get and Set Saturation Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the saturation of a color, with values ranging from 0 to 100. ```python saturation_value = first_gradient_position.s first_gradient_position.s = 75 ``` -------------------------------- ### Export WMV Settings Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/functions_e.html Constructor for ExportWMVSettings. ```APIDOC ## ExportWMVSettings() ### Description Constructor for the OMH::ExportWMVSettings class, used to configure WMV export parameters. ### Method Not applicable (constructor) ### Endpoint Not applicable (constructor) ### Parameters None ### Request Example None ### Response #### Success Response - **OMH::ExportWMVSettings**: An instance of the export WMV settings. ### Response Example None ``` -------------------------------- ### Get and Set Lightness Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the lightness of a color, with values ranging from 0 to 100. ```python lightness_value = first_gradient_position.l first_gradient_position.l = 50 ``` -------------------------------- ### ExportGifSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_gif_settings.html Initializes GIF export settings. All parameters are optional and have default values. ```APIDOC ## ExportGifSettings() ### Description The default constructor for ExportGifSettings, with all parameters optional. ### Parameters * **_i_file_path_** (QString) - Optional - The complete file path to the generated file. * **_i_file_name_** (QString) - Optional - The file name of the generated animated GIF. * **_i_start_frame_** (int) - Optional - The first frame to be exported. Defaults to 1. * **_i_end_frame_** (int) - Optional - The last frame to be exported. Defaults to the last frame of the scene (-1). * **_i_width_** (int) - Optional - The horizontal pixel resolution. Defaults to the width resolution of the scene (-1). * **_i_height_** (int) - Optional - The vertical pixel resolution. Defaults to the height resolution of the scene (-1). * **_i_dith_** (int) - Optional - The dithering to use. Defaults to 0 (None). - Dithering options: None (0), Diffusion (1), Pattern (2). * **_i_loop_** (bool) - Optional - Set the animation to loop. Defaults to false. ``` -------------------------------- ### Get and Set Hue Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the hue of a color, with values ranging from 0 to 360. ```python hue_value = first_gradient_position.h first_gradient_position.h = 180 ``` -------------------------------- ### ExportOGLFramesSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_o_g_l_frames_settings.html Initializes settings for exporting OGL frames. All parameters are optional and have default values. ```APIDOC ## ExportOGLFramesSettings(QString i_file_path="", QString i_file_name="", QString i_image_format="png", int i_start_frame=1, int i_end_frame=-1, int i_width=-1, int i_height=-1, int i_trailing_zeros=0) ### Description This is the default constructor for the ExportOGLFramesSettings class. It allows for the configuration of various parameters related to exporting OpenGL frames. All parameters are optional and will use default values if not provided. ### Parameters #### Path Parameters - **i_file_path** (QString) - Optional - The complete file path to the generated file. - **i_file_name** (QString) - Optional - The file name of the generated video. - **i_image_format** (QString) - Optional - The image file format of the frames. Defaults to "png". Available formats: "tvg","tga","scan","pal","sgi","opt","yuv","omf","psd","png","tif","tiff","jpg","jpe","jpeg","bmp". - **i_start_frame** (int) - Optional - The first frame to be exported. Defaults to 1. - **i_end_frame** (int) - Optional - The last frame to be exported. Defaults to -1 (last frame of the scene). - **i_width** (int) - Optional - The horizontal pixel resolution. Defaults to -1 (width resolution of the scene). - **i_height** (int) - Optional - The vertical pixel resolution. Defaults to -1 (height resolution of the scene). - **i_trailing_zeros** (int) - Optional - The trailing zeros before the frame number on the export file names. Defaults to 0. ``` -------------------------------- ### key_exposure_next() Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_element_column.html Finds and returns the starting frame of the next key drawing in a drawing column, based on a starting frame and optional flags. ```APIDOC ## key_exposure_next() ### Description Returns the next key drawing in a drawing column. ### Method `double OMC::ElementColumn::key_exposure_next(double startFrame, const QVariant &flags)` ### Parameters #### Path Parameters - **startFrame** (double) - Required - The frame number that specifies the search start point. - **flags** (const QVariant &) - Required - The flags to filter for when searching for the next exposure. ### Returns Returns the starting frame of the next key drawing in a drawing column. ``` -------------------------------- ### Create and Access Solid Colour Palette Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Demonstrates how to clear the palette list, create a new solid colour palette, and add a solid colour to it. Also shows how to verify the colour's association with its palette. ```python from ToonBoom import harmony palette_list = harmony.session().project.palettes # Clear the palette list of palettes (Optional) palette_list.clear() # Create a new colour palette: new_colour_palette = palette_list.create('Colour','Palette_Name') # Create new colour inside palette: new_colour = new_colour_palette.create_solid_colour('Colour_A',[255,0,0]) # Access palette colours: print(new_colour.palette_list().id == palette_list.id ) # True print(new_colour.palette().id == new_colour_palette.id ) # True ``` -------------------------------- ### Get and Set Colorspace in Scene Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_scene.html Demonstrates how to get the current colorspace of the scene and how to set it to a new value. It prints the colorspace before and after the change. ```python from ToonBoom import harmony sess = harmony.session() proj = sess.project scene = proj.scene print( "Color Space: %s"%(scene.colorspace) ) scene.colorspace = "Rec.709" print( "Color Space: %s"%(scene.colorspace) ) ``` -------------------------------- ### Initialize ExportProResSettings Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_pro_res_settings.html Instantiate ExportProResSettings with specific parameters for file path, name, codec, frame range, resolution, and audio/alpha settings. This is useful for programmatic control over ProRes exports. ```python from ToonBoom import harmony scene = harmony.session().project.scene export_handler = harmony.session().project.export_handler prores_settings = harmony.ExportProResSettings(r"C:/myPath/",'TheProRes','prores422',5,25, 960, 540,True,True,True,16,22050); export_handler(scene,prores_settings) ``` -------------------------------- ### Initialize ExportOGLFramesSettings Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_o_g_l_frames_settings.html Instantiates the ExportOGLFramesSettings class with specific parameters for exporting OGL frames. This includes setting the file path, base name, image format, frame range, dimensions, and trailing zero count. ```python from ToonBoom import harmony scene = harmony.session().project.scene export_handler = harmony.session().project.export_handler export_settings = harmony.ExportOGLFramesSettings( r"C:/myPath/", 'Frame', 'bmp', 1, 25, 960, 540 , 1 ) export_handler(scene,export_settings) ``` -------------------------------- ### Get and Set Blue Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the blue component of a color, with values ranging from 0 to 255. ```python blue_value = first_gradient_position.b first_gradient_position.b = 50 ``` -------------------------------- ### Iterate and Print Palette Names and Paths Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_list_list.html This example demonstrates how to iterate through all palette lists in a project and print the path of each list, followed by the names of the palettes within that list. It requires importing the harmony module from ToonBoom. ```python from ToonBoom import harmony palette_lists = harmony.session().project.palette_lists # Iterate the project palettes: for palette_list in palette_lists: print('Palettes at path: ' + palette_list.path) for palette in palette_list: print( 'Palette: ' + palette.name) ``` -------------------------------- ### Get and Set Green Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the green component of a color, with values ranging from 0 to 255. ```python green_value = first_gradient_position.g first_gradient_position.g = 100 ``` -------------------------------- ### Get and Set Red Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the red component of a color, with values ranging from 0 to 255. ```python red_value = first_gradient_position.r first_gradient_position.r = 200 ``` -------------------------------- ### Create and Manipulate Color Palettes and Colors Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette.html Demonstrates creating new color palettes, adding solid colors to them, appending colors from other palettes, duplicating existing colors, and listing the contents of a palette. Use this for initial setup and population of palettes. ```python from ToonBoom import harmony palette_list = harmony.session().project.palettes # Create new colour palettes: new_colour_palette_a = palette_list.create('Colour','A') new_colour_palette_b = palette_list.create('Colour','B') # Append new colours inside the palettes: new_colour_at_a = new_colour_palette_a.create_solid_colour('Colour_A',[255,0,0]) new_colour_at_b = new_colour_palette_b.create_solid_colour('Colour_B',[0,255,0]) new_colour_palette_a.append(new_colour_at_b,0) # append colour from another palette new_duplicate_of_a = new_colour_palette_a.append(new_colour_at_a,True) # duplicate colour from the same palette new_duplicate_of_a.name = 'Colour_A_duplicate' # List palette colours: for palette_colour in new_colour_palette_a: print(palette_colour.name) #Default #Colour_A #Colour_B #Colour_A_duplicate ``` -------------------------------- ### Variables starting with 'o' Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/functions_vars_o.html Lists variables in the Harmony 24 Python Interface that start with the letter 'o'. Each entry includes the variable name and its associated class. ```APIDOC ## Variables ### offset_keyframes * **Class**: OMC::PasteOptions ### opacity_colour_id * **Class**: OMC::DrawingVectorLineStyle ### opacity_texture_offset * **Class**: OMC::DrawingVectorLineStyle ### opacity_texture_scaling * **Class**: OMC::DrawingVectorLineStyle ### opacity_texture_tiled * **Class**: OMC::DrawingVectorLineStyle ### opacity_textured * **Class**: OMC::DrawingVectorLineStyle ### operator[int idx] * **Classes**: OMC::BackdropList, OMC::CableList, OMC::EaseColumn, OMC::ElementColumn, OMC::ElementDrawingList, OMC::FlatCableList, OMC::Path3DColumn, OMC::PortList, OMC::SceneList, OMC::VeloBasedColumn, OMH::Selection ### operator[int idx] const * **Class**: OMH::TimelineMarkerList ### operator[int index] * **Classes**: OMC::Palette, OMC::PaletteColour, OMC::PaletteList, OMC::PaletteListList ### operator[QString name] * **Class**: OMC::MetaDataHandler ### options * **Class**: OMC::EnumAttribute ### origin * **Classes**: OMC::Matrix, OMC::Transformation ### outline_colour_used * **Class**: OMC::DrawingVectorContour ### outport * **Class**: OMC::Port ``` -------------------------------- ### ExportOGLMovieSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_o_g_l_movie_settings.html Initializes an ExportOGLMovieSettings object. All parameters are optional and have default values. ```APIDOC ## ExportOGLMovieSettings() ### Description The default constructor for the ExportOGLMovieSettings class. All parameters are optional and have default values, allowing for flexible initialization. ### Parameters - **_i_file_path_** (QString) - Optional - The path for the output file. Defaults to "". - **_i_file_name_** (QString) - Optional - The name for the output file. Defaults to "". - **_i_start_frame_** (int) - Optional - The starting frame for the export. Defaults to 1. - **_i_end_frame_** (int) - Optional - The ending frame for the export. Defaults to -1 (scene's last frame). - **_i_width_** (int) - Optional - The width of the exported movie. Defaults to -1. - **_i_height_** (int) - Optional - The height of the exported movie. Defaults to -1. - **_i_sound_** (bool) - Optional - Whether to include sound. Defaults to true. - **_i_alpha_** (bool) - Optional - Whether to export with alpha channel if available. Defaults to true. - **_i_stereo_** (bool) - Optional - Whether to export in stereo. Defaults to true. - **_i_audio_channel_size_** (int) - Optional - The audio channel bit rate (16 or 8 bits). Defaults to 16. - **_i_audio_sample_rate_** (int) - Optional - The audio sample rate. Defaults to 22050. ### Constructor Signature OMH::ExportOGLMovieSettings::ExportOGLMovieSettings(QString _i_file_path_ = "", QString _i_file_name_ = "", int _i_start_frame_ = 1, int _i_end_frame_ = -1, int _i_width_ = -1, int _i_height_ = -1, bool _i_sound_ = true, bool _i_alpha_ = true, bool _i_stereo_ = true, int _i_audio_channel_size_ = 16, int _i_audio_sample_rate_ = 22050) ``` -------------------------------- ### ExportOGLFramesSettings Constructor Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_o_g_l_frames_settings.html Initializes an ExportOGLFramesSettings object. All parameters are optional and have default values. ```APIDOC ## Constructor ### `ExportOGLFramesSettings()` Initializes an `ExportOGLFramesSettings` object. All parameters are optional and have default values. #### Parameters * `_i_file_path_` (QString) - Optional - The base file path for exported frames. Defaults to "". * `_i_file_name_` (QString) - Optional - The base file name for exported frames. Defaults to "". * `_i_image_format_` (QString) - Optional - The format of the exported image files. Defaults to "png". * `_i_start_frame_` (int) - Optional - The first frame to export. Defaults to 1. * `_i_end_frame_` (int) - Optional - The last frame to export. Defaults to -1 (scene's last frame). * `_i_width_` (int) - Optional - The width of the exported images in pixels. Defaults to -1 (scene's width). * `_i_height_` (int) - Optional - The height of the exported images in pixels. Defaults to -1 (scene's height). * `_i_trailing_zeros_` (int) - Optional - The number of trailing zeros in the frame number. Defaults to 0. ``` -------------------------------- ### Get and Set Alpha Color Value Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette_colour.html Allows getting and setting the alpha (transparency) component of a color, with values ranging from 0 to 255. ```python alpha_value = first_gradient_position.a first_gradient_position.a = 255 ``` -------------------------------- ### Retrieve a int Localvalue Example Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_int_attribute.html This Python code example demonstrates how to retrieve the local value of an integer attribute using the Toon Boom Harmony scripting module. ```APIDOC ## Retrieve a int Localvalue ```python from ToonBoom import harmony #Import the Harmony Module sess = harmony.session() #Get access to the Harmony session, this class. proj = sess.project #Get the active session's currently loaded project. scene = proj.scene #Get the top scene in the project. node = scene.nodes["Top/Drawing"] #Find the Peg node. int_attribute_keyword = "OPACITY" #The path to a int attribute attribute = node.attributes[int_attribute_keyword] #Get the attribute by name if attribute: current_value = attribute.localvalue() #Get the attribute's localvalue. #Show the localvalue of the attribute. print( "LOCALVALUE: %s "%( current_value ) ) else: print( "Unable to find attribute by keyword: %s"%(int_attribute_keyword) ) ``` ``` -------------------------------- ### Export Quicktime MOV Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_handler.html Use this generic Quicktime exporter to create a MOV file. Requires Quicktime to be installed on the system. Configure path, filename, and Quicktime specific parameters. ```python from ToonBoom import harmony scene = harmony.session().project.scene export_handler = harmony.session().project.export_handler quicktime_settings = harmony.ExportQuicktimeSettings( r"C:/myPath/", 'TheQuickTime', True, 1, 1, 25, 1920, 1080, True, True, True, 16, 22050 ) export_handler(scene,quicktime_settings) ``` -------------------------------- ### Export WMV File Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_h_1_1_export_handler.html This example exports a WMV file from the provided node. Set the output path, filename, and WMV specific encoding parameters. ```python from ToonBoom import harmony scene = harmony.session().project.scene export_handler = harmony.session().project.export_handler wmv_settings = harmony.ExportWMVSettings( r"C:/myPath/", 'TheWMV', 90, 30000000, 1, 25, 960, 540, True, True, True, 16, 22050 ) export_handler(scene,wmv_settings) ``` -------------------------------- ### Functions starting with 'l' Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/functions_func_l.html Lists functions available in the Harmony 24 Python interface whose names start with the letter 'l'. Each entry includes the function name and its return type or the classes it operates on. ```APIDOC ## Functions starting with 'l' ### Description Provides a list of functions available in the Harmony 24 Python interface that begin with the letter 'l'. ### Functions * **launch()** : HarmonyModule * **layer()** : OMC::DrawingVectorContour , OMC::DrawingVectorJoint , OMC::DrawingVectorStroke * **left()** : OMC::DrawingVectorJoint * **lineTestFill()** : OMC::DrawingTimingColumn * **link()** : OMC::Attribute , OMC::InPort , OMC::OutPort * **linked_attributes()** : OMC::ColumnList * **linked_nodes()** : OMC::ColumnList * **list()** : OMC::AttributeList , OMC::BackdropList , OMC::Bezier , OMC::BezierPath , OMC::CableList , OMC::ColumnList , OMC::Drawing , OMC::DrawingVectorArtLayer , OMC::DrawingVectorContourList , OMC::DrawingVectorJointList , OMC::DrawingVectorStrokeList , OMC::DrawingVectorThicknessPath , OMC::ElementDrawingList , OMC::FlatCableList , OMC::MetaDataHandler , OMC::NodeList , OMC::Palette , OMC::PaletteColour , OMC::PaletteList , OMC::PaletteListList , OMC::PortList , OMC::Preferences , OMH::Selection , OMH::SelectionBackdropList , OMH::SelectionColumnList , OMH::SelectionNodeList , OMH::SubselectionList * **list_palettes()** : OMC::PaletteListList * **load_file()** : OMC::Javascript * **load_string()** : OMC::Javascript * **localvalue()** : OMC::BoolAttribute , OMC::ColourAttribute , OMC::DoubleAttribute , OMC::EnumAttribute , OMC::IntAttribute , OMC::Position2DAttribute , OMC::Position3DAttribute , OMC::TextAttribute , OMC::TimingAttribute * **lock()** : OMC::Element , OMC::Palette , OMC::PaletteList * **log()** : OMC::Application * **look_at()** : OMC::Matrix ``` -------------------------------- ### Accessing About Information in Harmony Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_about.html This snippet demonstrates how to import the Harmony module, get the session, and access the 'about' object to retrieve application details. Use this to get general information about the current Harmony session. ```python from ToonBoom import harmony sess = harmony.session() about = sess.about print( about.path_application ) ``` -------------------------------- ### Create and List Solid Colors in a Palette Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_palette.html Demonstrates how to create a new color palette, add multiple solid colors with specified RGB values, and then list the names of the colors within that palette. This is useful for programmatically setting up a color scheme. ```python from ToonBoom import harmony palette_list = harmony.session().project.palettes # Clear the palette list of palettes (Optional) palette_list.clear() # Create a new colour palette: new_colour_palette = palette_list.create('Colour','Palette_Name') # Create new colours inside palette: new_colour_palette.create_solid_colour('Colour_A',[255,0,0]) new_colour_palette.create_solid_colour('Colour_B',[255,255,0]) new_colour_palette.create_solid_colour('Colour_C',[255,0,255]) # List palette colours: print(new_colour_palette.colour_names()) ``` -------------------------------- ### type Source: https://docs.toonboom.com/help/harmony-24/scripting/pythonmodule/class_o_m_c_1_1_group_node.html Gets the type of the node. ```APIDOC ## type ### Description Gets the type of the node. ### Method `QString` ### Parameters None ### Response Returns the type of the node as a QString. ```