/ HALion Developer Resource / HALion Script / Reference /
insertZone
insertZone(zone, position)
Description
Function to insert a zone at the specified position in the determined layer. The zone to be inserted is determined by its Zone object. You can use getZone or findZones to determine the desired zone. The destination layer is determined by its Layer object. For example, this.parent
determines the parent layer of the script module as destination layer. The position is the number indexing the existing zones in the destination layer. The new zone will be inserted before the specified position. To add the zone at the end, use appendZone instead.
❕ An Element object can only have one parent. It cannot be child of multiple parents. Therefore, an Element object that you retrieved from the running plug-in instance must be removed before it can be inserted again. The Element objects that you retrieve through loadPreset or loadPresetAsync can be inserted freely, because these functions create a copy of the Element objects when reading them.
Available in: Controller.
Arguments
Argument | Description | Value Type |
---|---|---|
zone | The Zone object of the zone that you want to insert. | Zone |
position | The position where the zone is inserted. | number |
Example
To explore the following script:
- Download Program.vstpreset.
- Drag the preset on the MediaBay to import it to the user folder for VST presets.
- Create an empty program and add a script module.
- Paste the script into the text editor of the script module and execute the script.
-- Insert a zone from Program.vstpreset into the current program.
-- Get the file path for user VST presets.
path = getUserPresetPath()
-- Load the VST preset.
loadedProgram = loadPreset(path.."/Program/Program.vstpreset")
-- Get the first zone from the loaded program.
zone = loadedProgram:getZone()
-- Insert the zone.
if zone then
this.program:insertZone(zone, 1)
end
See also: insertBus, insertEffect, insertLayer, insertLayerAsync, insertMidiModule, Zone