Skip to Main Content
Cognex Support Hub
LogoLogo

How To - Set the Profiler Scan Length programmatically in VisionPro/Cognex Designer (DS head, In-Sight 3D-L4000 head, In-Sight L38 head)

How To - Set the Profiler Scan Length programmatically in VisionPro/Cognex Designer (DS head, In-Sight 3D-L4000 head, In-Sight L38 head)

14.11.2024

Question

While developing your VisionPro/Cognex Designer application, you might need to programmatically change the device Scan Length from script based on the application need.

Answer

It has to be done using the acqFifo.OwnedROIParams.SetROIXYWidthHeight() method replacing the new Height.

Please note it is recommended to add the script at the application startup or after the Task Inspection/in a step of the application when the device is not busy acquiring, otherwise it won't be accessible to be read/written.

Below a sample code for Cognex Designer - please note: Cognex.VisionPro has to be added as a Using to the script
For Cognex Designer scripting details (like where-to-find the Using box) see also: Cognex Designer - Script Editor - Documentation | Cognex

ICogAcqFifo acqFifo = (ICogAcqFifo)$System.GetInternalObject("Devices.DeviceName") //The DeviceName has to be replaced, for example with DS1101R

int x, y, width, currentHeight, newHeight = 0;

//retrieving the existing current values
acqFifo.OwnedROIParams.GetROIXYWidthHeight(out x, out y, out width, out currentHeight);
if (currentHeight !!= height)
{
   //set with existing x, y, width and new height
  acqFifo.OwnedROIParams.SetROIXYWidthHeight(x,y,width,height);
  acqFifo.Prepare();
  acqFifo.OwnedROIPArams.GetROIXYWidthHeight(out x, out y, out width, out newHeight);
}
else
{
newHeight = currentHeight;
}

return newHeight;

Verwandte Materialien