grandMA3 User Manual Publication
Import(handle, file_path, file_name)

grandMA3 User Manual » Plugins » Lua Functions - Object API » Import(handle, file_path, file_name)
Version 2.0

Description

The object version of the Import Lua function is used to import an object written in XML format.

Restriction:
The files need to already exist to be imported.
Important:
The Lua import will merge the content of the XML file into the object without any confirmation pop-up.

Arguments

  • Handle:
    The function takes a handle of the type "light_userdata" as an argument. It can be omitted when using the colon notation on an object. See the examples below.
  • File_path:
    This is a string with the path to the file location.
  • File_name:
    This is a string containing the file name of the desired file.

Return

The function does not return anything. It does import the object.

Example

These two examples import the content of the XML file into the selected sequence. The file is called "MySelectedSequence", and it is located at "../gma3_library/datapools/sequences". It is two examples of how to achieve the same outcome.

First example using the colon operator:

Lua
return function()
--SelectedSequence() creates a handle to the selected sequence.
local selectedSequence = SelectedSequence()
--The path is stored in a variable.
local path = GetPath(Enums.PathType.UserSequences)
--The actual import function.
selectedSequence:Import(path, "mySelectedSequence.xml")
--Print some feedback.
Printf("The sequence is imported from: " .. path)
end

The second example uses a handle as an argument with the same result:

Lua
return function()
--SelectedSequence() creates a handle to the selected sequence.
local selectedSequence = SelectedSequence()
--The path is stored in a variable.
local path = GetPath(Enums.PathType.UserSequences)
--The actual import function.
selectedSequence.Import(selectedSequence, path, "mySelectedSequence.xml")
--Print some feedback.
Printf("The sequence is imported from: " .. path)
end