Exclude locked segment from analysis programmatically (or putting it in a separated category)

We are currently trying to perform analysis Task in one of our plugin.

The testers pointed out that for some project the locked segments are exclude and for the other not. 

This came from the project settings that are not set the same way 

Screenshot of Analyze Files Settings with options to Report Cross-File repetitions, Report internal fuzzy match leverage, Report locked segments as a separate category, and Exclude locked segments from analysis. The last two options are highlighted.

After searching the api, I found the settings AnalysisTask but it doesn't seems to provide access to the two parameters needed to control the locked segments.

ISettingsBundle settings = project.GetSettings();
AnalysisTaskSettings analyseSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();

Am I doing something wrong or is it not possible to change it programmatically ? 

We are using Trados Studio 2022 SR2 - 17.2.10.19084

thanks for your help



Generated Image Alt-Text
[edited by: RWS Community AI at 2:35 PM (GMT 0) on 30 Jan 2025]
Parents Reply
  • Hi  , update from the development team.  They will expose these properties in the public API with the next >= minor release; I don't have a date for this; it will be announced in due course.

    Until then, I received this workaround from the team:

    The Setting for any SettingGroup can be accessed by string ID too (as long as you know the correct ID)

    The Sdl.ProjectAutomation.Settings.AnalysisTaskSettings is just a wrapper that provides a user friendly access to the settings but does the same thing behind the scenes.

    As a side note, in the Sudio UI. So ExcludeLockedSegments = true will deactivate the ReportLockedSegmentsSeparately and also set it to false

    Checkbox options: 'Report locked segments as a separate category' is unchecked, and 'Exclude locked segments from analysis' is checked.

    ISettingsBundle settings = project.GetSettings();
    AnalysisTaskSettings projectAnalyseSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();
    var excludeLockedSegments = projectAnalyseSettings.GetSetting<bool>("ExcludeLockedSegments");
    excludeLockedSegments.Value = true;
    project.UpdateSettings(settings);
    ISettingsBundle languageSettings = project.GetSettings(new Sdl.Core.Globalization.Language("de-DE"));
    AnalysisTaskSettings targetLanguageAnlysisTaskSettings = languageSettings.GetSettingsGroup<AnalysisTaskSettings>();
    var excludeLockedSegmentsTL = targetLanguageAnlysisTaskSettings.GetSetting<bool>("ExcludeLockedSegments");
    excludeLockedSegmentsTL.Value = false;
    var reportLockedSegmentsSeparatelyTL = targetLanguageAnlysisTaskSettings.GetSetting<bool>("ReportLockedSegmentsSeparately");
    reportLockedSegmentsSeparatelyTL.Value = true;
    project.UpdateSettings(new Sdl.Core.Globalization.Language("de-DE"), languageSettings);

    Patrick Andrew Hartnett | Developer Experience | Team Lead | RWS Group



    Generated Image Alt-Text
    [edited by: RWS Community AI at 7:46 AM (GMT 1) on 17 Oct 2025]
Children
No Data