% -------------------------------------------------------------------------
% function HfssAssignMaterial(fid, HObject, HMaterial)
% 
% Popis funkce :
% -------------
% Funkce nastavi material na zadany, existujici v HFSS.
%
% Parametery :
% ------------
% fid      - file identifier of the HFSS script file.
% HObject   - jmeno nastaveneho objektu.
% HMaterial - material nastaveneho objektu. 
% 
% Note :    
% ------
% Nastaveni objektu na dany material muze byt pouzito v pripade, jeli uz 
% dany material definovan v HFSS nebo pouzitim funkce HfssAddMaterial(...)
%             
% Priklad pouziti funkce :
% ---------
% fid = fopen('antenna.m', 'wt');
% ... 
% hfssAssignMaterial(fid, 'FR4Mount', 'FR4epoxy'); 
% -------------------------------------------------------------------------

function HfssAssignMaterial(fid, HName, HMaterial)
global Editor

HTF='false';
% if the material is copper, we should set solve inside to be false and for
% other materials (in general) is should be true.
if (strcmp(HMaterial, 'copper') || strcmp(HMaterial, 'pec'))
	HTF='false';
else	
	HTF='true';
end

% Zapsani do souboru temp
fprintf(fid, 'invoke(Editor,''AssignMaterial'',...\n');
fprintf(fid, '{''NAME:Selections'',...\n');
fprintf(fid, ['''Selections:='',''',HName,'''},...\n']);  
fprintf(fid, '{''NAME:Attributes'',...\n');
fprintf(fid, ['''MaterialName:='',''',HMaterial,''',...\n']);
fprintf(fid, ['''SolveInside:='',',HTF,'});\n\n']);


% Prime vykonani funkce v programu HFSS
invoke(Editor,'AssignMaterial',...
{'NAME:Selections',...
'Selections:=',HName},...  
{'NAME:Attributes',...
'MaterialName:=',HMaterial,...
'SolveInside:=', HTF});

end 