% Popis funkce :
% -------------
% Vlozeni HFSS designu do projektu a nastaveni jako aktivni design.
%
% Parametery :
% ------------
% fid        - soubor identifikujici HFSS script.
% designName - jmeno noveho vlozeneho designu.
% designType - (promena String) vyber z nasledujiciho seznamu:
%              1. 'driven modal' (vlastni)
%			   2. 'driven terminal'
%			   3. 'eigenmode'
% 
% Poznamka :
% ------
% Tato funkce se pouzije nejdrive po funkci hfssNewProject() nebo
% hfssOpenProject(), ale neni nutna.
%
% Priklad pouziti :
% ---------
% fid = fopen('pokus.m', 'wt');
% ...
% hfssInsertDesign(fid,'Dipole_SingleElement');
% -------------------------------------------------------------------------
function HfssInsertDesign(fid, HdesignName, HdesignType)
global Design HProject Editor

% arguments processor.
if (nargin < 2)
	error('Insufficient number of arguments !');
elseif (nargin < 3)
	HdesignType = [];
end;

% vlastni argumenty.
if isempty(HdesignType)
	HdesignType = 'driven modal';
end;
% create the necessary script.

switch (lower(HdesignType))
	case 'driven terminal', 
		HdesignType='DrivenTerminal';
	case 'driven modal'
		HdesignType='DrivenModal';
	case 'eigenmode'
		HdesignType='Eigenmode';
end;
fprintf(fid,'%% Vytvoreni InsertDesign\n');
fprintf(fid, ['invoke(HProject,''InsertDesign'',''HFSS'',''',HdesignName,''',''',HdesignType,''','''');\n']);
fprintf(fid, ['Design = HProject.invoke(''SetActiveDesign'',''',HdesignName,''');\n']);
fprintf(fid, 'Editor = Design.invoke(''SetActiveEditor'',''3D Modeler'');\n\n');

invoke(HProject,'InsertDesign','HFSS',HdesignName,HdesignType,'');
Design = HProject.invoke('SetActiveDesign',HdesignName);
Editor = Design.invoke('SetActiveEditor','3D Modeler');

end