Generating complex plot graph By using TCL\TK

Vikas Kumar_22189
Vikas Kumar_22189 Altair Community Member
edited October 2020 in Community Q&A

Hi all,

 

I have to generate complex plot type graph bu using .PCH file and tcl\tk script. Can any one help me out for this.

I have developed one TCL\TK script but in this culve is showing empty.

The code is:-

 

set t [clock seconds]
hwi OpenStack
hwi GetSessionHandle sess$t;
sess$t New
sess$t GetClientManagerHandle mgr$t plot;
mgr$t GetBuildPlotsCtrlHandle build$t;
build$t SelectDataFile 'd:/abc/def.pch'; false;
sess$t GetDataFileHandle dataFileHandle$t $::CPMReportGenerationToolMain::PCHFilePath;

# dataFileHandle$t SetFilename $::CPMReportGenerationToolMain::PCHFilePath
set dataFileName [dataFileHandle$t GetFilename]
set typeList [dataFileHandle$t GetDataTypeList]
set subCaseList [dataFileHandle$t GetSubcaseList]
set subCaseName [lindex $subCaseList 0]
dataFileHandle$t SetSubcase $subCaseName
set nsub [llength $typeList];
# puts 'subCaseList: $subCaseList \n nsub:$nsub \n typeList: $typeList '
set xType [lindex $typeList 0];
set yType [lindex $typeList 1];

# set xVectCrv$i [Xcrv$i GetValuesList]
# set yVectCrv$i [Ycrv$i GetValuesList]

set yPointReqs [dataFileHandle$t GetRequestList $yType];
# puts 'xType $xType \n yPointReqs: $yPointReqs'
set headertext $yPointReqs;
append headertext '';
set nreq [llength $yPointReqs];
#puts $nreq
set components [dataFileHandle$t GetComponentList $yType];
sess$t GetProjectHandle proj$t
proj$t AddPage    
proj$t RemovePage 1                
proj$t GetPageHandle page$t [proj$t GetActivePage]
set pageId [proj$t GetActivePage]
page$t SetLayout 0    
page$t Draw
# to display at top of window
page$t SetTitle 'Phase Amplitude Graph';
page$t SetTitleDisplayed true;
page$t SetActiveWindow $currentWindowID
page$t GetWindowHandle win$t [page$t GetActiveWindow]    
set reqItem [lindex $yPointReqs $counterForPoint]
win$t SetClientType 'Plot';
win$t GetClientHandle ploth$t
ploth$t SetChartType 'complex';
ploth$t SetComplexMode pm
ploth$t GetHeaderHandle header$t;
header$t SetVisibility true;
header$t SetText 'Point';
set curvName 'X';    
ploth$t AddCurve;
set ncurve [ploth$t GetNumberOfCurves];
ploth$t GetCurveHandle curv$t$dir $ncurve;
curv$t$dir SetName $pointNameForCurve
# set X - axis label and limit (limit value if asked) 
ploth$t GetHorizontalAxisHandle xAxis$t 1;
xAxis$t SetVisibility true;
xAxis$t SetAutoFit true;
# xAxis$i SetFitToRange true
xAxis$t SetScale 'linear';
# xAxis$t SetMin 0;
# xAxis$t SetMax 500;
set xLabel 'Frequency (Hz)';
xAxis$t SetLabel $xLabel;
# set Y - axis label and limit (limit value if asked) 
ploth$t GetVerticalAxisHandle yAxis$t 1;
yAxis$t SetVisibility true;
yAxis$t SetAutoFit true;
yAxis$t SetScale 'linear';
yAxis$t SetMin 0.001;
# yAxis$t SetMax 10000;
yAxis$t SetLabel 'Acceleration \[mm/s2\]';
            
# display curve
curv$t$dir GetVectorHandle vectorX$t x;
set vectY [curv$t$dir GetVectorHandle vectorY$t y];
vectorX$t SetType 'file';
vectorX$t SetFilename 'd:\abc\def.pch';
# puts '1st: $::CPMReportGenerationToolMain::PCHFilePath';
set xType 'Frequency'
set yType 'Accelerations'
vectorX$t SetDataType $xType;
vectorY$t SetType 'file';
vectorY$t SetFilename 'd:\abc\def.pch'
vectorY$t SetDataType $yType;
 # puts '2nd $xType $yType'
vectorY$t SetRequest $pointNameID ;
vectorY$t SetComponent $dir;
vectorY$t SetScaleFactor 1;    
set xmax [xAxis$t GetMax];
set xmin [xAxis$t GetMin];
set ymax [yAxis$t GetMax];
set ymin [yAxis$t GetMin];
curv$t$dir SetVisibility true;
ploth$t Recalculate;
ploth$t Autoscale;
ploth$t Draw;
##Modify Plots######################
curv$t$dir Trim 0 500 horizontal false
ploth$t Recalculate
ploth$t Draw
# xAxis$t SetMin 50
# xAxis$t SetMax 500
xAxis$t SetAutoFit true
xAxis$t SetFitToRange true
# reset values to fit
xAxis$t SetVisibility true;
xAxis$t SetAutoFit true;
xAxis$t SetFitToRange true
ploth$t Recalculate;
ploth$t Autoscale;
ploth$t Draw;
curv$t$dir ReleaseHandle
xAxis$t ReleaseHandle
yAxis$t ReleaseHandle
vectorY$t ReleaseHandle
vectorX$t ReleaseHandle
# iNote$t ReleaseHandle
page$t Draw

 

But this code showing empty curve

 

Thanks,

Vikas Kumar

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited April 2018

    Hi Vikas,

     

    In order to draw a curve on complex plot, you have to set fields of both three vectors: x, ym (magnitude) and yp (phase).

    Get handles of these vectors with

     pltICurveComplex_handle GetVectorHandle iVector which

    and set file and data type to each of them appropriately.

     

    Regards,