Idea

Tom S4 avatar image
2 Likes"
Tom S4 suggested Tom S4 commented

Regex support for model tree searches

Not sure if this has been suggested before - I was unable to find it.

Are there any plans to add regular expression support to the search function in the model tree? Search results can get fairly clunky in larger models, but this would allow for more refined searches.

I have attached an example for a way I would like to use this. I'm looking for all references to column 8 of "Material_Table". Without regex, and because I don't have a specific row to look for, it would seem my only options are to search for Material_Table and sift through a few thousand results, or search for "8" which would be even worse.

1654094478157.png


model treeregex
1654094478157.png (3.6 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Comment

·
Jordan Johnson avatar image
2 Likes"
Jordan Johnson commented

This seems like a fine idea. In the meantime, you can actually write some FlexScript that will help. The following script finds all text with at least one regex match. It prints the node and line number to the console. It doesn't find all matches within a node, though. But it should narrow down your search considerably:

treenode root = model();
int searchNames = 1;
int searchText = 1;

Array toSearch = [root];
while (toSearch.length) {
    treenode target = toSearch.pop();
    
    toSearch.append(target.subnodes.toArray());
    treenode attr = target.find(">1");
    while (attr) {
        toSearch.push(attr);
        attr = attr.next;
    }
    
    if (searchNames) {
        int index = target.name.search(/MaterialTable\[\d\]\[8\]/g);
        if (index >= 1) {
            print(target);
            continue;
        }
    }
    
    if (target.dataType == DATATYPE_STRING && searchText) {
        int index = target.value.search(/MaterialTable\[\d\]\[8\]/g);
        if (index >= 1) {
            int line = 1;
            for (int i = 1; i <= index; i++) {
                if (target.value.charAt(i) == "\n") {
                    line++;
                }
            }
            print(target, ", line ", line);
        }
    }
}

RegexSearchDemo.fsm

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Tom S4 avatar image Tom S4 commented ·
Very interesting solution. Thank you for sharing.
0 Likes 0 ·

Write a Comment

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.

Related Ideas