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]
  • Hi  , thank you for this feedback.  It seems that these settings were never extended to the project automation integration.  It seems to be the same for 2024 :-( 
    I'll create an API change proposal request and followup with the dev team.  good catch (y)

    + 

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

  • Hi  ,

    thanks for your answer. That means that as long the change is not accepted  and developed this cannot be done in any way except user changing it manually ?

  • Thank you for bringing this to our attention. Our development team will review it in the context of our ongoing projects and priorities. Your understanding and patience as we assess this matter is appreciated. We have recorded the issue in our tracking system under the reference number CRQ-41259
  • Hi  , I don't have any work arounds for this as it depends on extending these settings from the project automation api.  However, there is nothing stopping you for attempting to access these settings from the internal project via reflection.  I don't recommend this btw and won't provide any support on this, but here is a snippet to get you started if you decide to go down that road. 

    Fullscreen
    1
    2
    3
    4
    var project = new FileBasedProject(projectInfo);
    var internalProjectType = typeof(FileBasedProject).GetProperty("InternalProject",
    BindingFlags.NonPublic | BindingFlags.Instance);
    var projectInstance = internalProjectType?.GetValue(project);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

  • 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.

    Fullscreen
    1
    2
    3
    4
    5
    ISettingsBundle settings = project.GetSettings();
    AnalysisTaskSettings projectAnalyseSettings = settings.GetSettingsGroup<AnalysisTaskSettings>();
    var excludeLockedSegments = projectAnalyseSettings.GetSetting<bool>("ExcludeLockedSegments");
    excludeLockedSegments.Value = true;
    project.UpdateSettings(settings);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    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);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    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]