< All Topics
List and modify Motor Names
PostedNovember 4, 2021
UpdatedNovember 4, 2021
ByKasper Vestrup
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?