foreach (var itemResult in sim.Session.Current.Results)
{
if (itemResult.Entity.Name.Contains(itemFlag))
{
DataSet.Add(itemResult);
}
}
using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using System.Collections.Generic;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;
namespace Scripts
{
public class DsTest : CustomStandingsDataSet
{
protected override IEnumerable<IEntitySessionResult> FilterResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results)
{
// Filter all results to return only a subset
return results.Where(r => r.Entity.Name.ToLower().Contains("d"));
}
protected override IEnumerable<IEntitySessionResult> OrderResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results,
IDataOrder order)
{
// Optional: change the order of the results
return results.OrderBy(r => r.Entity.Name);
// Use the 'order' parameter to order by the selected Data Order
// This is the default implementation; can leave this out
return order.Sort(results);
}
protected override ISessionResult GetSession(ISimulation sim)
{
// Optional: change the session from which you want to pull the results
return sim.Session.Current;
}
}
}
Nick Thissen wrote:
Would it help if I were to allow you to create a custom dataset in a script and select that dataset in the usual Select Data Set window?
The script would need to have a class that overrides 'CustomStandingsDataSet'. You can override at least three important functions and return your own results:
- FilterResults: receives all results as input, you can apply your own filtering and output only a subset
- OrderResults: receives all results as input, you can sort the results according to your own sorting rule
- GetSession: change the session from which you want to pull results
There are more functions to override but I highly recommend staying away from those.
Important: it only supports "results" datasets, meaning a dataset similar to "followed", "standings", "warmup", etc.
An example implementation would be this. It would create a dataset that only returns drivers with a "b" in their name, and sorted by name:
using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using System.Collections.Generic;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;
namespace Scripts
{
public class DsTest : CustomStandingsDataSet
{
protected override IEnumerable<IEntitySessionResult> FilterResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results)
{
// Filter all results to return only a subset
return results.Where(r => r.Entity.Name.ToLower().Contains("d"));
}
protected override IEnumerable<IEntitySessionResult> OrderResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results,
IDataOrder order)
{
// Optional: change the order of the results
return results.OrderBy(r => r.Entity.Name);
// Use the 'order' parameter to order by the selected Data Order
// This is the default implementation; can leave this out
return order.Sort(results);
}
protected override ISessionResult GetSession(ISimulation sim)
{
// Optional: change the session from which you want to pull the results
return sim.Session.Current;
}
}
}
I think I can make this work, but I have to make some changes to make the editor accept this as a data set.
Please let me know if this would work for you or if you need even more control.
Nick Thissen wrote:
This update is now released on the alpha channel.
Nick Thissen wrote:
No it is not similar. You just create a script with the Dataset template, or copy it from what I posted here earlier. Add your logic at least to the FilterResults part (the rest is optional). Then save and make sure it compiled OK. After that, it should become availabl as a dataset in the regular "Select dataset" window for any widget. It works just the same as the normal standings dataset, except with your own filtering logic.