Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

[SOLVED] Fixing of my Renamer Script

Discussion in 'Programming Questions and Suggestions' started by razzun, Sep 17, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. razzun Trainee Engineer

    Messages:
    52
    I need a bit of help. I know what the error is, but I don't seem to be fixing it correctly. Here is the code:
    Code:
    void Main(string argument)
    {
        var args = argument.Split(';');
    
        string groupName = args[0]; //Group name to search for 
        string namePrefix = args[1]; //Prefix to name blocks in group with 
        var group = this.GridTerminalSystem.GetBlockGroupWithName(groupName);
        if(group == null)
        {
            this.Echo("No group found");
            return;
        }
    
        var groupBlocks = new List<IMyTerminalBlock>();
        group.GetBlocks(groupBlocks);
        for(int i = 0; i < groupBlocks.Count; i++)
        {
            var block = groupBlocks[i];
            block.SetCustomName(namePrefix + " " + (i + 1).ToString("000"));
        }
    }
    
    There issue is with SetCustomName, but when I try and change it to CustomName, it errors out. Any ideas?
     
  2. Pingger Trainee Engineer

    Messages:
    53
    Have you tried casting the block to a Terminal Block? Like so:
    Code:
    (block as IMyTerminalBlock).CustomName = namePrefix + " " + (i + 1).ToString("000");
    Edit CustomName is an Attirubte, not a method ...
     
    • Agree Agree x 1
  3. razzun Trainee Engineer

    Messages:
    52
    Perfect. Thanks. I am not the best programmer (I usually copy and paste pieces to make something do what I want). So thank you very much for the help.
     
Thread Status:
This last post in this thread was made more than 31 days old.