#regionnamespace imports// 一 命名空间usingSystem;usingSystem.Collections;usingSystem.Drawing;usingSystem.IO;usingSystem.Windows.Forms;usingCognex.VisionPro;usingCognex.VisionPro.ToolBlock;usingCognex.VisionPro3D;usingCognex.VisionPro.ImageProcessing;#endregionpublicclassCogToolBlockAdvancedScript:CogToolBlockAdvancedScriptBase{// 二 全局变量#regionPrivate Member VariablesprivateCognex.VisionPro.ToolBlock.CogToolBlockmToolBlock;#endregion// toolblock的运行方法publicoverrideboolGroupRun(refstringmessage,refCogToolResultConstantsresult){// To let the execution stop in this script when a debugger is attached, uncomment the following lines.// #if DEBUG// if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break();// #endif// 运行所有的工具模块foreach(ICogTooltoolinmToolBlock.Tools)mToolBlock.RunTool(tool,refmessage,refresult);returnfalse;}#regionWhen the Current Run Record is Created/// <summary>/// Called when the current record may have changed and is being reconstructed/// </summary>/// <param name="currentRecord">/// The new currentRecord is available to be initialized or customized.</param>publicoverridevoidModifyCurrentRunRecord(Cognex.VisionPro.ICogRecordcurrentRecord){}#endregion#regionWhen the Last Run Record is Created// 在GroupRun运行之后运行,进行渲染publicoverridevoidModifyLastRunRecord(Cognex.VisionPro.ICogRecordlastRecord){}#endregion#regionWhen the Script is Initialized// 初始化方法,在GroupRun运行之前运行publicoverridevoidInitialize(Cognex.VisionPro.ToolGroup.CogToolGrouphost){// DO NOT REMOVE - Call the base class implementation first - DO NOT REMOVEbase.Initialize(host);// Store a local copy of the script hostthis.mToolBlock=((Cognex.VisionPro.ToolBlock.CogToolBlock)(host));}#endregion}