macros:function:timelines.importmarkersfromstring

This is an old revision of the document!


Function

Timelines.ImportMarkersFromString

Void Timelines.ImportMarkersFromString(
  Int32 timelineId, 
  String importMappingVersion, 
  String csvFilePath, 
  AcwFrameRate frameRate
)
API https://api.avolites.com/16.0/api/Timelines.ImportMarkersFromString.html
description Imports markers into the timeline.
namespace Timelines
parameter timelineId ( Int32 ): The timeline ID.
importMappingVersion ( String ): The XML node for the version of the mapping to use.
csvFilePath ( String ): The csv file path.
frameRate ( AcwFrameRate ): The framerate to import.
return value Void

This article was written with massive help from Gregory Haynes; I couldn't have figured this out myself.

There is also the function Timelines.ImportMarkers, however that would expect an XML object as importMappingVersion while this fuction here parses a string which is much easier to handle.

Arguments
  • timelineId is the identifier or the timeline you want to import the markers into. Unlike for other functions which expect a handle this one expects a titanId. You may retrieve this e.g. from Web API, or you use e.g. Handles.GetTitanIdFromHandle to get the titanId for a specific handle by its usernumber:
    • Timelines.ImportMarkersFromString(1819, …) – example with hardcoded titanId
    • Timelines.ImportMarkersFromString(Handles.GetTitanIdFromHandle(“timelineHandleUN=1”), …) – example to get the titanId from a usernumber
  • importMappingVersion is a string to be parsed as XML that can define what all the columns are and how to read them.
Example CSV File:
externalId,legend,time 
0,Test,00:00:01.00
blah,Marker 2,00:01:23.00
999,Another Marker,00:12:34.56


By default it will assume that the CSV file contains headers and it will attempt to use those to figure out which column is which. If it cannot figure out the column headers it will assume the order specified above i.e. “externalId”, “legend” then “time”. The external ID can be whatever you want and is used within Titan to detect duplicates i.e. if you import more than once a matching external ID will replace an existing one.

The smallest possible string as importMappingVersion is “&lt;Version /&gt;” which essentially is “<Version />” with the angled brackets written as entities (otherwise they'd be interpreted as XML which would break the macro XML)

There is also an XML file included with the personality library (e.g. C:\Program Files\Avolites\Titan\FixtureLibrary\MarkerImportMapping.xml) which includes multiple options that can be selected in the UI in the context menu. There is also the provision for a similar file to be in the user fixture library directory.
<MarkerImportMappings schemaVersion="1.0" xmlns="http://avolites.com/MakerImportMapping.xsd"> 
  <MarkerImportMapping id="reaper" name="Reaper">
    <Version id="1" name="2020" headerRow="true">
      <externalId name="#" index="0" />
      <legend name="Name" index="1" />
      <time name="Start" index="2" format="h':'mm':'ss':'ff" />
    </Version>
  </MarkerImportMapping>
</MarkerImportMappings>
You should recognise the Version section as the bit being passed into the function. Perhaps if the string contained “Reaper”, “Reaper:2020” or “reaper:1” it ought to be able to lookup the appropriate mapping from the library.
Example in

Timeline: Import Markers:

<step>Timelines.ImportMarkersFromString(
  Handles.GetTitanIdFromHandle("timelineHandleUN=1"), 
  "&lt;Version /&gt;", 
  "C:\Users\sb\Documents\Titan\Markers\test.csv", 
  Timecode.ParseFrameRate(100))
</step>
Also used in
Remarks
You could leave a comment if you were logged in.
macros/function/timelines.importmarkersfromstring.1680521052.txt.gz · Last modified: 2023/04/03 11:24 by icke_siegen

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki