tcl API - How to remove object

Anne
Anne Member Posts: 3
Name Dropper First Comment
**
edited August 22 in General Language Questions

Hello everyone,

I am working with SCADE Suite 2022 R2, developing a toolbar with additional functionality in tcl.

After many hours of searching the documentation (localpath/scade/help/SCADE Online Help), I managed to find a command to create a new item. In case anybody is also searching, it is:
set itemHandle [Create $parentItemId "ClassName"]
AddRole $parentItemId "RoleName" $itemHandle

Now I would also like to be able to remove items, but I absolutely can not find anything on this. Does anybody have any hints for me? The lack of documentation is really frustrating.

Thank you!

Tagged:

Best Answer

  • Aubanel
    Aubanel Member, Employee Posts: 1
    First Answer First Comment
    ✭✭✭
    Answer ✓

    Hi Anne.

    If I understand you properly, you are trying to modify a Scade model with a TCL script from within the IDE itself. While not impossible, we discourage this, as the IDE robustness does not take this usecase in account. There is a risk of crash and loss of data upon certain manipulations (typically undo/redo commands). However, you can safely run model transforming scripts from the command line scade.exe -script instead.

    Editing a model with a script is a complex task that requires a deep understanding of the Scade internal structures. That's why these features are undocumented. We recommend you to contact your local ACE member to talk about it. We have dedicated libraries to facilitate the task, and can also train you on the topic.

    Unless you have a lot of legacy TCL scripts, we recommend our users to use the python API whenever possible. The library linked above is in python.

    Now that all precautions are made and advisories shown, the TCL command to remove items is RemoveRole. It does not delete the item but removes the link from a parent. If the item is disconnected from all its parents, it will be discarded when the model is saved.

    Thanks for using Scade !