Hello,

I want to do the following:
1) Select various regions of the image with mouse (some gray blocks are created)
2) Store the gray blocks (via Layout.VisualBlocks)
3) Use imgViewer.Commands.DoCommand(MenuItemEnum.MI_ReadBlock, true); for recognising the selected area/region of image (gray blocks are removed as a result)
4) Create the gray blocks again (using the stored ones)

But when I do the 4th step, I get an exception (Arguments check failed. Expected: isValidBlockType) What am I doing wrong?

This is the code:


for (var i = 0; i < FrDocument.Pages[0].Layout.VisualBlocks.Count; i++)
          lstRegionesAgregar.Add(FrDocument.Pages[0].Layout.VisualBlocks[i].Region);//I assume that the block is BlockTypeEnum.BT_AutoAnalysis
imgViewer.Commands.DoCommand(MenuItemEnum.MI_ReadBlock, true);
foreach (var regionAgregar in lstRegionesAgregar)
{
    var regBloque = AbbyyEngineLoader.Engine.CreateRegion();
    regBloque.AddRect(regionAgregar.Left[0], regionAgregar.Top[0], regionAgregar.Right[0], regionAgregar.Bottom[0]);
     FrDocument
        .Pages[0]
        .Layout
        .VisualBlocks
        .AddNew(BlockTypeEnum.BT_AutoAnalysis, regBloque);// <==== ArgumentException is thrown here 
}
imgViewer.Invalidate(true); 

asked 10 Dec '15, 00:28

Andres%20Mu%C3%B1oz's gravatar image

Andres Muñoz
215

edited 10 Dec '15, 00:28

Hi Andres,

The ArgumentException is thrown because the AddNew method of the LayoutBlocks object cannot contain the following block types: BT_AutoAnalysis, BT_Separator, BT_SeparatorGroup. Please see the description of this method in Developer’s Help for more details. As soon as you change the block type to any of the allowed values, the code will work.

(10 Dec '15, 17:22) Oksana Serdyuk ♦♦

Thanks, I though I could create a "BlockTypeEnum.BT_AutoAnalysis" block.

(10 Dec '15, 19:23) Andres Muñoz
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7
×4
×4
×2

Asked: 10 Dec '15, 00:28

Seen: 1,385 times

Last updated: 10 Dec '15, 19:23

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal