Skip to content
< All Topics

List and modify Motor Names

Changing part of Motor name for all Motors which name contains “UC2”

int startindex = 5;
string changefrom = "MC02";
string changeto = "MC01";
foreach (var motor in Experior.Core.Motors.Motor.Items.Values)
{
    if (motor.Name.Contains("UC2"))
    {
        int lenght = motor.Name.Length - startindex;
        Log.Write("Assembly name = " + motor.Name);
        Log.Write("Assembly name = " + motor.Name.Substring(startindex, lenght));
        Log.Write("Assembly name = " + motor.Name.Replace(changefrom, changeto));
        motor.Name = motor.Name.Replace(changefrom, changeto);
        motor.Name = "=" + motor.Name;
    }
}
Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.