function replaceConfigSetRefWithCopy(modelH, enableAllProps)
% replaceConfigSetRefWithCopy : Get final configuration set referenced by configset reference.
% Create copy of configuration set, attach it to model and set it as active configset.
% If optional parameter passed is true, enable all props on the copied configset , which makes all prop writable.
%     

%   Copyright 2009-2021 The MathWorks, Inc.
    if (nargin < 2)
        enableAllProps =  false;
    end
    srcCS = sldvshareprivate('mdl_get_configset', modelH);
    newCS = attachConfigSetCopy(modelH, srcCS, true);
    if (enableAllProps) 
        % enable all properties on copied configset
        newCS.reenableAllProps();
    end         
    setActiveConfigSet(modelH, newCS.Name);   
end
