Macro for grouping objects located in a specific area of the page

Hello, wondering if it is possible to get some help creating a macro that groups objects based on where they are located on the page.

My document size is 24 inches wide X 18 inches high and I need to make 4 groups of objects:

The first group with all the objects/shapes found on the left 6.5 inches of the page. 

Second Group with all the objects/shapes found on the section between 6.5 and 12 inches of the page. 

Third Group with all the objects/shapes found on the section between 12 and 17.5 inches of the page. 

and a 4th group with all the objects/shapes found between 17.5 and 24 inches of the page. 

This is for laser engraving, we use CorelDraw X6 and have to do this process manually every time going trough more than 100 pages each time. Very time consuming.

This macro ideally should run through all the pages in the document.

Help with this will be greatly appreciated.

Jose

Parents
  • This is one of the possible solutions to your problem, use the logic to implement it in VBA if applicable, in this example it is written in C#, but I used Corel x8, I don't have x6, there may be something that doesn't work, like here community.coreldraw.com/.../api the minimum version for consultation is X7, you or someone needs to test on X6

    [CgsAddInMacro]
         public void GroupByRegion()
         {
             double[] increments = { 6.55.55.56.5 };
             double increment;
             corelApp.EventsEnabled = false;
             corelApp.Optimization = true;
             corelApp.ActiveDocument.BeginCommandGroup("group");
             for (int i = 1; i <= corelApp.ActiveDocument.Pages.Count; i++)
             {
                 increment = 0;
                 for (int j = 0; j <increments.Length; j++) {
     
                     corelApp.ActiveDocument.Pages[i].SelectShapesFromRectangle(
                         corelApp.ActiveDocument.Pages[i].LeftX + increment,
                         corelApp.ActiveDocument.Pages[i].TopY,
                         corelApp.ActiveDocument.Pages[i].LeftX + (increment += increments[j]),
                         corelApp.ActiveDocument.Pages[i].BottomY,
                         false).Group();
                 }
             }
             corelApp.ActiveDocument.EndCommandGroup();
             corelApp.EventsEnabled = true;
             corelApp.Optimization = false;
             corelApp.Refresh();
         }
Reply Children
No Data