Bonsai | 2D Annotation TEXT Literal , change in bulk.

edited August 2025 in General

Hi all ,
How can we easily change the selected TEXT annotation literal to 'FINAL TEXT' all at once. Is there a way?

Comments

  • Not yet, unfortuately
    https://github.com/IfcOpenShell/IfcOpenShell/issues/5220
    I would imagine this would be a relatively easy pull request, if anyone wants to work on their python chops. :)

    arunarchitect
  • edited August 2025

    @theoryshaw said:
    Not yet, unfortuately

    Just found a temporary solution, using a Python script generated from ChatGPT, and it works fine. Experts, please do point out if there are any potential issues that might harm the IFC file.

    import ifcopenshell
    
    # Load IFC
    ifc_file = ifcopenshell.open(r"path_to_your_file.ifc")
    
    # Paste your comma-separated GlobalIds here
    raw_ids = "1NFV_k$NjB8xf2Yipi5bvg,1CaYpQ63jCm9kpuHGtOfIy,3ytHwKPqnF1ey1hczXp1dF"
    
    # Convert into a list of trimmed strings
    target_ids = [gid.strip() for gid in raw_ids.split(",")]
    
    # New literal for all; type your literal to be pasted in bulk
    new_text = "TESTED TEXT"
    
    for guid in target_ids:
        element = ifc_file.by_guid(guid)
        if element and element.Representation:
            for rep in element.Representation.Representations:
                for item in rep.Items:
                    if item.is_a("IfcTextLiteral") or item.is_a("IfcTextLiteralWithExtent"):
                        print(f"[{guid}] Old text: {item.Literal}")
                        item.Literal = new_text
                        print(f"[{guid}] New text: {item.Literal}")
        else:
            print(f"[{guid}] Element not found or has no text literal.")
    
    # Save updated file after changing the text literals
    ifc_file.write(r"path_to_save_the_newfile.ifc")
    print("Updated IFC saved.")
    

    :)

  • @theoryshaw said:
    Not yet, unfortuately
    https://github.com/IfcOpenShell/IfcOpenShell/issues/5220
    I would imagine this would be a relatively easy pull request, if anyone wants to work on their python chops. :)

    oh, I see @falken10vdl self-assigned himself a couple days ago. Cool.

    arunarchitect
  • @theoryshaw Yes, I saw this a few days ago and thought it would be a good feature. @arunarchitect cool you already have some working inspiration. Please let me take a look to try to inplement it in a PR.
    Thanks!

    theoryshawarunarchitect
  • @falken10vdl said:

    @arunarchitect cool you already have some working inspiration.

    Thank you @falken10vdl :)

  • edited August 2025

    Please take a look to this proposed PR: Bulk annotation text edition #7028
    It provides some toggles that allow you to either propagate that property to the selected text annotations or not. If it is clicked then it will be propagated.

    Cheers!

    Massimoarunarchitect
  • Little note. The changes done to the properties are changed inmediately for the last selected text annotation (the one whose data is shown in the "Object Information" TAB). The rest is updated when the "Edit Text" is clicked and you return back to "Enable Editing Text"
    See an example below:

    Cheers!

  • Added possibility to select objects with the same attribute value (or remove with shift+click). Thanks @theoryshaw for the suggestion!

    Cheers!

  • @theoryshaw the suggestion to click on values to get similar objects selected is really a hidden gem! :) I have seen that you reference to it in chapter 059000_20250224_1655 - Type psets and Qto's of the tutorial series. Nice!

    Thanks!

  • @theoryshaw the suggestion to click on values to get similar objects selected is really a hidden gem! :)

    Indeed, I have seen that video yesterday too.
    And I remember a similar "looks like a text but it opens the Dropdown" in a previous video.

    On the other side - this is quite a heavy Graphical User Interface Crime though :)

  • On the other side - this is quite a heavy Graphical User Interface Crime though :)

    When i was first submitted a 'select_similar' UI, i did something like this...

    I can't find the exact conversation, but @Moult thought it was a little cluttered, which i kinda agreed with.
    So that's why I went back to hiding the operator behind the 'value'.
    Either way, i use this stuff all the time. :)

    zoomer
  • Maybe an option is what I have proposed in the PR :) To show the operator with a "select" icon when one is in edit mode and hide it in the value otherwise ;)

  • Yeah, that seems to make sense. @Moult?

Sign In or Register to comment.