Option Explicit Sub Align_by_Fiduciary() Dim DocID As Integer Dim FiduciaryID As Integer DocID = IpDocActive() ' Draw a power of 2 AOI around the fiduciary mark ret = IpFftShow(1) ret = IpAoiShow(FRAME_NONE) ret = IpMacroStop("Please draw an AOI around the Fiduciary mark. Once the AOI is drawn, adjust it's position to enclose the Fiduciary mark on all planes and as little other texture as possible. The FFT tool has been displayed to constrain the AOI to sizes and shapes best suited to alignment processing.", 0) ret = IpFftShow(0) ' Make a working copy of the fiduciary mark FiduciaryID = IpWsDuplicate() ret = IpDocMove(604, 57) ' Configure the Alignment module for this exercise ret = IpAlignShow(ALGN_IMAGETAB, 1) ret = IpAlignRemove(DOCSEL_ALL, -1) ret = IpAlignAdd(FiduciaryID, -1) ret = IpAlignSetInt(ALGN_ALGORITHM, 0, ALGN_FFT) ret = IpAlignSetInt(ALGN_OPTIONS, ALGN_ROTATE, 0) ret = IpAlignSetInt(ALGN_OPTIONS, ALGN_SCALE, 0) ret = IpAlignSetInt(ALGN_ALG_OPTION, ALGN_METHOD, ALGN_FFTFULL) ret = IpAlignSetInt(ALGN_ALWAYSRECALC, 0, 0) ret = IpAlignShow(ALGN_OPTIONTAB, 1) ' Generate the alignment parameters on the fiduciary mark alone. ret = IpAlignCalculate() ' Save the alignment parameters ret = IpAlignSave(MacroDir + "\AlgnByFid.ipa") ' Close the working copy of the fiduciary mark ret = IpAppSelectDoc(FiduciaryID) ret = IpDocClose() ' Clean the workspace and get reday to align the original image ret = IpAppSelectDoc(DocID) ret = IpAoiShow(FRAME_NONE) ret = IpAlignRemove(DOCSEL_ALL, -1) ret = IpAlignShow(ALGN_IMAGETAB, 1) ret = IpAlignAdd(DocID, -1) ret = IpAlignShow(ALGN_OPTIONTAB, 1) ' Apply the alignment based on the fiduciary marke to the original image ret = IpSeqPlay(-6) ret = IpAlignOpen(MacroDir + "\AlgnByFid.ipa") ret = IpAlignApply() ' Clean up scratch file Kill MacroDir + "\AlgnByFid.ipa" ' Clean the workspace ret = IpAppArrange(DOCS_TILE) ret = IpAlignShow(1, 0) End Sub