
function autoblkTogglePlantModel(block)

TopModel=bdroot(block);

VehicleType=regexp(TopModel,'Configured(.*?)VirtualVehicle','tokens');
VehicleType=VehicleType{1,1}{1,1};

PlantVariantSubsystem=[TopModel '/' 'Vehicle'];
set_param(PlantVariantSubsystem,'VariantChoicesSpecifier','{}');
save_system(TopModel);

if strcmp(get_param(PlantVariantSubsystem,'LabelModeActiveChoice'),'ConfiguredSimulinkPlantModel')
    set_param(block,'MaskDisplay','disp(getString(message(''autoblks:autoblkVehMask:ToggleToSimulinkPlant'')))');
    %change variant to Simscape
    PlantModelType='Simscape';

elseif strcmp(get_param(PlantVariantSubsystem,'LabelModeActiveChoice'),'ConfiguredSimscapePlantModel')
    set_param(block,'MaskDisplay','disp(getString(message(''autoblks:autoblkVehMask:ToggleToSimScapePlant'')))');
    %change variant to Simulink
    PlantModelType='Simlink';
else
    set_param(block,'MaskDisplay','disp(getString(message(''autoblks:autoblkVehMask:ToggleToSimScapePlant'')))');
    PlantModelType='Simlink';
end

if strcmp(VehicleType,'Ev1Em')
    VehArct='Electric Vehicle 1EM';
elseif strcmp(VehicleType,'Conventional')
    VehArct='Conventional Vehicle';
elseif strcmp(VehicleType,'HevMm')
    VehArct='Hybrid Electric Vehicle MM';
elseif strcmp(VehicleType,'HevIps')
    VehArct='Hybrid Electric Vehicle IPS';
elseif strcmp(VehicleType,'HevP0')
    VehArct='Hybrid Electric Vehicle P0';
elseif strcmp(VehicleType,'HevP1')
    VehArct='Hybrid Electric Vehicle P1';
elseif strcmp(VehicleType,'HevP2')
    VehArct='Hybrid Electric Vehicle P2';
elseif strcmp(VehicleType,'HevP3')
    VehArct='Hybrid Electric Vehicle P3';
elseif strcmp(VehicleType,'HevP4')
    VehArct='Hybrid Electric Vehicle P4';
end


VirtualAssembly.VirtualApi('ConfigFile','',...
    'VehArct',VehArct,...
    'VehClass','Passenger Vehicle',...
    'VehDyn',0,...
    'PlantModelType',PlantModelType,...
    'ConfigModel',TopModel,...
    'Toggle',true);

end
