How can I rename remote points based on some of their properties?

Tasos
Tasos Member, Employee Posts: 9
Name Dropper 5 Likes First Comment Photogenic
✭✭✭

I would like to rename remote point objects in my model in such way that the name contains some useful info for further postprocessing.

Best Answer

  • Tasos
    Tasos Member, Employee Posts: 9
    Name Dropper 5 Likes First Comment Photogenic
    ✭✭✭
    edited October 7 Answer ✓

    Let’s assume you want to rename remote points based on some property e.g. “Type 1” and “Type 2”.
    You can group the remote point objects in the model tree based on a selection logic around this property. Then, name those groups after the “tag” you want to have appended on the name. In our example let’s name the groups “Type 1” and “Type 2”. We will, also, use this tag as input to look for the groups to rename.

    The following script takes as input a list of the names of the groups to rename. Then appends the group name to the remote point’s name for those objects under the corresponding group. In addition, it adds the remote point’s object ID property in the name as a unique identifier.

    # Input list of groups to rename
    rename_groups = ['Type 1','Type 2']
    
    # Get objects under Remote Points in a list
    all_rp_list = ExtAPI.DataModel.Project.Model.RemotePoints.Children
    group_list = []
    
    # Iterate the list and pick the Groups of interest.
    for rpg in all_rp_list:
        # Keep only the groups
        if str(rpg.DataModelObjectCategory) == 'TreeGroupingFolder':
            group_list.append(rpg)
        #end if
    #end for
    
    for rpg in group_list:
        # Check if group is listed as a group to rename
        if rpg.Name in rename_groups:
            # List the Remote Points in the goup
            rp_list = rpg.Children
            for rp in rp_list:
                # Check if it is a Remote Point (could be a subgroup)
                if str(rp.DataModelObjectCategory) == 'RemotePoint':
                    # Rename accordingly (adding object ID as unique identifier)
                    rp.Name = 'RP ' + str(rp.ObjectId) + ' of ' + str(rpg.Name)
                #end if
            #end for
        #end if
    #end for
    

    In our example, this would result in: