Is it possible to find out where my spreadsheet aliases are being used via a search?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
bassamanator
Posts: 29
Joined: Wed May 05, 2021 1:35 am

Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by bassamanator »

Hi,

My part is mostly completed, and I want to do some cleanup.

I want to delete all the useless aliases that I created in the spreadsheet. I want to find out where a particular alias is being used.

Is it possible to search for aliases in Freecad?

Thanks!
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by chrisb »

You can unpack the FreeCAD file and search through the File Document.xml. Unpacking can be done with a common unzip or with the tool available via menu->Tools->Project utility.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
alexu
Posts: 30
Joined: Tue Nov 26, 2019 2:14 pm

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by alexu »

bassamanator wrote: Sun Jun 13, 2021 4:21 am
Is it possible to search for aliases in Freecad?
Perhaps you could modify Macro TreeToAscii to show this information?
(or petition the macro author to add it)
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by Chris_G »

Hi,
You can run this little function to list all the objects of the active document that use the given string in expressions :

Code: Select all

def search_alias_connection(name=""):
    """Search all the objects of current document that contain
    the given string in an expression"""
    doc = App.ActiveDocument
    for o in doc.Objects:
        if hasattr(o, "ExpressionEngine"):
            for exp in o.ExpressionEngine:
                if name in exp[1] or name is None:
                    print("{} used in property {} of object {}".format(exp[1], exp[0], o.Label))

search_alias_connection("Alias_1")
you can then perform new searches by simply repeating the last command with other string :

Code: Select all

search_alias_connection("Alias_2")
cadcam
Posts: 276
Joined: Thu Apr 02, 2020 10:39 am

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by cadcam »

search_alias_connection("Alias_2")
Really useful, thank you. Generating a macro for this

[Should this be part of FC - Spreadsheet -> Select cell -> Alias .. Where used ...?
bassamanator
Posts: 29
Joined: Wed May 05, 2021 1:35 am

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by bassamanator »

Chris_G wrote: Mon Jun 14, 2021 1:35 pm Hi,
You can run this little function to list all the objects of the active document that use the given string in expressions :
This works wonderfully. Thanks!
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Is it possible to find out where my spreadsheet aliases are being used via a search?

Post by chrisb »

cadcam wrote: Mon Jun 14, 2021 3:35 pm Should this be part of FC - Spreadsheet -> Select cell -> Alias .. Where used ...?
+1
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply