% function hfssCylinder(fid, HName, HAxis, HCenter, HRadius, HHeight, HUnits)
% 
% Datum vytvoreni :
% -----------------
% 11.12.2008
%
% Popis :
% -------------
%Funkce pro vytvoreni cylindru, zapis do souboru temp a prime vytvoreni v
%programu HFSS
%
% Parametery :
% ------------
% fid      - soubor identifikujici HFSS script.
% HName    - jmeno cylindru (v HFSS).
% HCenter  - stred cylindru (specifikovane jako [x, y, z]). Je to startovni
%            bod cylindru.
% HAxis    - osa otoceni cylindru (specifikovane jako 'X', 'Y', nebo 'Z').
% HRadius  - radius cylindru (scalar).
% HHeight  - vyska cylidnru (od bodu specifikovaneho jako HCenter).
% HUnits   - pouzite jako 'in', 'mm', 'meter' nebo nejake definovane v HFSS.
% 
% Priklad :
% ---------
% fid = fopen('projekt.m', 'wt');
% ... 
% hfssCylinder(fid,'Cyl1','Z',[0, 0, 0],0.1,10,'mm'); 
%--------------------------------------------------------------------------
function HfssCylinder(fid, HName, HAxis, HCenter, HRadius, HHeight, HUnits,HMaterial)
global Editor

%zapis do souboru temp
fprintf(fid,'%% Vytvoreni cylindru\n');
fprintf(fid,'invoke(Editor,''CreateCylinder'',...\n');
fprintf(fid,'{''NAME:CylinderParameters'',...\n');
fprintf(fid,['''XCenter:='',''',num2str(HCenter(1)),HUnits,''',...\n']);
fprintf(fid,['''YCenter:='',''',[num2str(HCenter(2)),HUnits],''',...\n']);
fprintf(fid,['''ZCenter:='',''',[num2str(HCenter(3)),HUnits],''',...\n']);
fprintf(fid,['''Radius:='',''',[num2str(HRadius),HUnits],''',...\n']);
fprintf(fid,['''Height:='',''',[num2str(HHeight),HUnits],''',...\n']);
fprintf(fid,['''WhichAxis:='',''',upper(HAxis),'''},...\n']);
fprintf(fid,'{''NAME:Attributes'',...\n');
fprintf(fid,['''Name:='',''',HName,''',...\n']);
fprintf(fid,'''Flags:='','''',...\n');
fprintf(fid,'''Color:='',''(132 132 193)'',...\n');
fprintf(fid,'''Transparency:='',0,...\n');
fprintf(fid,'''PartCoordinateSystem:='',''Global'',...\n');
fprintf(fid,['''MaterialName:='',''',HMaterial,''',...\n']);
fprintf(fid,'''SolveInside:='',true})\n\n');

%prime vykonani v programu HFSS
invoke(Editor,'CreateCylinder',...
    {'NAME:CylinderParameters',...
    'XCenter:=',[num2str(HCenter(1)),HUnits],...
    'YCenter:=',[num2str(HCenter(2)),HUnits],...
    'ZCenter:=',[num2str(HCenter(3)),HUnits],...
    'Radius:=',[num2str(HRadius),HUnits],...
    'Height:=',[num2str(HHeight),HUnits],...
    'WhichAxis:=',upper(HAxis)},...
    {'NAME:Attributes',...
    'Name:=',HName,...
    'Flags:=', '',...
    'Color:=','(132 132 193)',...
    'Transparency:=', 0,...
    'PartCoordinateSystem:=','Global',...
    'MaterialName:=',HMaterial,...
    'SolveInside:=', true})

end