Unable to Edit/Delete Static Linked Records with Streamlined STK

Options
nblum
nblum Member Posts: 4
First Comment

Summary

I was attempting to use the Streamlined layer of the Granta MI STK (version 3.2) to remove all links from a link group for a specific record, however, this does not seem to be possible. I have detailed the issue I'm encountering below. If anyone has any suggestions, or if I'm doing something wrong, please let me know.

This behavior is possible using the Foundation layer, but since it is planned to be deprecated in the future, I would like to use the Streamlined layer if possible.

What I tried

The documentation says to use the Record.set_links function, which accepts an iterable of Records. This is already counter intuitive, because the default behavior is to add any new Record to the link group.

For example, if I wanted to replace the linked records for a record, I would think that this would work:

print(record.links["my_group"])
# {<Record 1>, <Record 2>}

new_links = {record2, record3}
record.set_links("my_group", new_links)
record = mi.update_links([record])[0]

I would expect:

print(record.links["my_group"])
# {<Record 2>, <Record 3>}

Instead, I would get:

print(record.links["my_group"])
# {<Record 1>, <Record 2>, <Record 3>}

Potential Workarounds

I can, however, work around that by doing:

print(record.links["my_group"])
# {<Record 1>, <Record 2>}

new_links = {record3, record4}

### Have to empty the set object prior ###
record.links["my_group"] = set()

# record.set_links("my_group", new_links)
record = mi.update_links([record])[0]

### Correct Output ###
print(record.links["my_group"])
# {<Record 3>, <Record 4>}

Limitation 1

But, this only works if I supply at least one record to the set_links function, and only if I do not include any items that were already linked.

Limitation 2

As well, if I supply an empty set, it will not remove ANY of the links from the link group, making it impossible to delete all links from a link group using the Streamlined STK.

print(record.links["my_group"])
# {<Record 1>, <Record 2>}

new_links = set()
record.set_links("my_group", new_links)

record = mi.update_links([record])[0]

### Incorrect Output ###
print(record.links["my_group"])
# {<Record 1>, <Record 2>}

Expected Behavior & Conclusion

I would expect that Record.set_links would override the existing links with the new links I provide, but currently it's just adding the new links to the existing links. There is a potential workaround, but that only works if you are willing to add at least one new link to the link group.

Again, if I'm missing something completely I would be more than happy to hear about it! Otherwise, I would like to know if there are any plans to support this behavior in the future.

Comments

  • Daniel Manocchio
    Daniel Manocchio Member Posts: 17
    5 Likes First Comment Photogenic
    Options

    Hi nblum,

    I encountered the same when trying to set a link group to zero links. That behavior is already assessed as bug and will be fixed (hopefully) in 2024 R2. Andy posted a Foundation Layer snippet, I added to my personal functions as interim's workaround.

    See here: https://discuss.ansys.com/discussion/2911/how-to-remove-all-linked-records-from-a-link-group#latest

    Hope that helps & bests,
    Daniel

  • nblum
    nblum Member Posts: 4
    First Comment
    Options

    Hi Daniel, you're absolutely right. I tried searching to see if anyone else had that issue, but must not have been broad enough!

    Thanks for sharing!

    Best,
    Noah

  • Daniel Manocchio
    Daniel Manocchio Member Posts: 17
    5 Likes First Comment Photogenic
    Options

    Hey Noah,
    No prob & you're welcome :smile:

  • Andy_Grigg
    Andy_Grigg Member, Employee Posts: 23
    First Answer First Comment First Anniversary 5 Likes
    Options

    Thanks Daniel!

    Just to confirm, this behavior will be fixed with the 2024 R2 release of Scripting Toolkit.

  • Daniel Manocchio
    Daniel Manocchio Member Posts: 17
    5 Likes First Comment Photogenic
    Options

    Hi Andy,
    great, thanks for double checking! :smile:

    Bests,
    Daniel