tcl code not capturing images
I wrote the below code to capture 6 windows in all the pages [I have 2 pages now] separately.
I was using:
sess$t CaptureActiveWindow png ${namemodelwin}.png pixels 1000 1000
to capture the images and it worked. but I came across this code that would help capture image in high resolution but it uses post handle not session handle to capture images. I am not familiar with post handle. Below code is a trial I did with post handle. It didn't work. Files are all loading, but the images are not created. no errors shown.
Any advices?
proc BatchMain { } { set inputdeck [lindex $::argv 6] set resultfile [lindex $::argv 7] puts $inputdeck puts $resultfile set t [::post::GetT] hwi GetSessionHandle sess$t sess$t GetProjectHandle proj$t hwi OpenStack sess$t LoadReport Pressure_and_wear.tpl sess$t ApplyReport Pressure_and_wear replace true false 2 $inputdeck $resultfile set numpages [proj$t GetNumberOfPages]; for {set i 1} {$i <= $numpages} {incr i} { proj$t SetActivePage $i proj$t GetPageHandle pg$i $i set numwindows [pg$i GetNumberOfWindows]; for {set j 1} {$j <= $numwindows} {incr j} { pg$i GetWindowHandle wn$j $j; wn$j GetViewControlHandle vc; vc Fit; #vc Zoom 0.95; vc ReleaseHandle; pg$i SetActiveWindow wn$j set x [clock clicks] ::post::GetPostHandle p$x; set namemodelwin [puts "image_${i}_${j}"] puts $namemodelwin #sess$t CaptureActiveWindow png ${namemodelwin}.png pixels 1000 1000 p$x Draw p$x CaptureImage $namemodelwin png 4 p$x ReleaseHandle wn$j Draw wn$j ReleaseHandle } pg$i Draw pg$i ReleaseHandle #sess$t CaptureScreen png image_$i.png } hwi CloseStack proj$t ReleaseHandle sess$t Close } BatchMain
Best Answer
-
Hi,
Please change below command:
set namemodelwin [puts "image_${i}_${j}"]
to:
set namemodelwin "image_${i}_${j}"
and try it again (your command makes emptied file name so it may crash silently).
0
Answers
-
Hi,
Please change below command:
set namemodelwin [puts "image_${i}_${j}"]
to:
set namemodelwin "image_${i}_${j}"
and try it again (your command makes emptied file name so it may crash silently).
0 -
tinh said:
Hi,
Please change below command:
set namemodelwin [puts "image_${i}_${j}"]
to:
set namemodelwin "image_${i}_${j}"
and try it again (your command makes emptied file name so it may crash silently).
Thank you! That helped.
0 -
tinh said:
Hi,
Please change below command:
set namemodelwin [puts "image_${i}_${j}"]
to:
set namemodelwin "image_${i}_${j}"
and try it again (your command makes emptied file name so it may crash silently).
Hello,
The code is only capturing the first window of the first page. Could you please check and let me know what I am doing wrong here?
proc BatchMain { } { set inputdeck [lindex $::argv 6] set resultfile [lindex $::argv 7] #set inputdeck OS_6600rpm_PIMO3D_PIS.out #set resultfile RP_6000rpm_PIMO3D_PIS_phi3pp_hm.res puts $inputdeck puts $resultfile set t [::post::GetT] hwi GetSessionHandle sess$t sess$t GetProjectHandle proj$t hwi OpenStack sess$t LoadReport Pressure_and_wear.tpl sess$t ApplyReport Pressure_and_wear replace true false 2 $inputdeck $resultfile set numpages [proj$t GetNumberOfPages]; for {set i 1} {$i <= $numpages} {incr i} { proj$t SetActivePage $i proj$t GetPageHandle pg$i $i set numwindows [pg$i GetNumberOfWindows]; for {set j 1} {$j <= $numwindows} {incr j} { pg$i GetWindowHandle wn$j $j; wn$j GetViewControlHandle vc; vc Fit; vc ReleaseHandle; pg$i SetActiveWindow wn$j set x [clock clicks] ::post::GetPostHandle p$x; set namemodelwin "image_${i}_${j}.png" if {$i == 3} { set res 2 } else { set res 4 } p$x Draw p$x CaptureImage $namemodelwin png ${res} p$x ReleaseHandle wn$j Draw wn$j ReleaseHandle } pg$i Draw pg$i ReleaseHandle } hwi CloseStack proj$t ReleaseHandle sess$t Close } BatchMain
0