Display Driver Initials and Car Logo

Posts: 9
Happy new year!


I would need a short support please.
I wanted to display the drivers' initials in the standigs. If I select via data bindings "initials", these are unfortunately only 2 digits. Am I doing something wrong here?

I then tried to use a script with the Data Converter and use the following code.
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class Initialen_Fahrer : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Get databinding value as string:
string frist_name = value.ToString();
string last_name = value.ToString();

// Take char 1 - 3
string fristpart = frist_name.Substring(0, 1);
string secondpart = last_name.Substring(0, 2);

// Return that to display
return fristpart + secondpart.ToUpper();
}
}
}

But unfortunately the output is not correct. It will display the first letter of the first name, which would be correct. But why does it show me by last_name again 2 letters of the first name?

Output for my name: CCH
But should be: CPR

Unfortunately, I am not a C # expert, so I would be very happy to receive support.

Next I would like to integrate the respective vehicle emblems. How must the code be constructed so that, for example, instead of "Ferrari 488 GTE" the Ferrari logo is displayed?

Many thanks for your help.
Christian
Edited (1 time)
You are writing "value.ToString()" twice, which accesses the value (your first name) twice. Both firstName and lastName have the same value in your case.
The issue your are describing above is actually a bug in the description. The initials should only have two letters. But there is another way you could access the data you want. You just have to bind to the "driver_object" which is of type IDriver. Then you could return "driver.ThreeLetterCode". The script would look like this:
public class Initialen_Fahrer : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var driver = (IDriver) value;
return driver.ThreeLetterCode;
}
}

I guess we should add this binding as well. No idea why we acutally didn't add it right from the beginning.
Posts: 9
Thank you for your reply.
I have now tried your code, but I get the error message "Compilation failed".
"the type or namespace name 'IDriver' could not be found".

Or how do I change the code from above so I can query 2 variables.
Posts: 785
The problem is that the script needs to know the full "path" to the IDriver type (which is ATVO.ThemesSDK.Data.Entity.IDriver). You can replace IDriver with this full path, or add the path to the "using" statements at the top of the script:
using ATVO.ThemesSDK.Data.Entity;


To help you with these errors, you can double-click them and it will show a popup with all available references to "IDriver". Typically there is only one (the one I mentioned here). If you select it from the list, the textbox at the bottom will include this "using" statement and you can copy it to your script directly.

I wrote an explanation here: https://atvo.appgineering.com/Forum/Thread/94
Edited (3 times)
Posts: 9
Thank you for your help and explanation in a separate thread. Works perfect now.