Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup deduplication #4

Open
BradyAJohnston opened this issue Dec 31, 2024 · 0 comments
Open

Cleanup deduplication #4

BradyAJohnston opened this issue Dec 31, 2024 · 0 comments

Comments

@BradyAJohnston
Copy link
Owner

Moving issue from MN here: BradyAJohnston/MolecularNodes#656

Code for deduplication can be cleaned up, similar to this example:

import bpy
import re
   
def remove_duplicate_groups():
    node_groups = bpy.data.node_groups

    for group in node_groups:
        unduped_name, *_ = re.split("\.\d+$", group.name)

        if unduped_name in node_groups:
            group.user_remap(node_groups[unduped_name])
        else:
            group.name = unduped_name
    
    for group in node_groups:
        split_name, *_ = re.split("\.\d+$", group.name)
    
        if len(_) > 0 and split_name in node_groups:
            node_groups.remove(group)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant