DISTANCE

Hello,
I have this question:
On picture below You see page with labels. Each label has ellipse for cutting in layer cut and inellipse contents for printing. Distance between each label/ellipse in horizontal and vertical order is 2 mm. All ellipses are in layer CUT. All inellipse contents are in layer TEXT.

Now i will change distance between labels from 2 mm to 1 mm.

The easiest way, i thing, is to delete all ellipses and inellipse contents except one. Then redraw this label horizontal with distance 1 mm and with vertical distance 1 mm

This is not ideal solution, because i may change distance again and i make it to 0.5 mm 

Please for your advice for solution!

Greetings!

Parents
No Data
Reply
  • Maybe this can give you some idea, I don't know if it works on the x5

    [CgsAddInMacro]
    public void MagicSpacingChanger(double newSpace = 1)
    {
        try
        {
            //future implementation
            double areaVariantion = 2d;
            //Use optimization stuffs if prefer
            //repositioning the columns
            ShapeRange pageShapes = corelApp.ActivePage.Shapes.All();
     
            //order by big boundingbox
            //pageShapes.Sort("(@shape1.width * @shape1.height) > (@shape2.width * @shape2.height)");
            //order left to right
            pageShapes.Sort("@shape1.com.positionx < @shape2.com.positionx");
            ShapeRange tempRange = corelApp.CreateShapeRange();
           //Get the firt column
            FillColumnRange(pageShapes, tempRange);
            pageShapes.RemoveRange(tempRange);
            double columnRightX = tempRange.RightX;
            tempRange.RemoveAll();
     
            //Change the spaces from anothers
            while (pageShapes.Count > 0)
            {
                FillColumnRange(pageShapes, tempRange);
                pageShapes.RemoveRange(tempRange);
                tempRange.LeftX = columnRightX + newSpace;
                columnRightX = tempRange.RightX;
                tempRange.RemoveAll();
            }
     
            //Restarting in rows, sorry by ctrl+c ctrl+v
            pageShapes = corelApp.ActivePage.Shapes.All();
     
            //order by big boundingbox
            //pageShapes.Sort("(@shape1.width * @shape1.height) > (@shape2.width * @shape2.height)");
            //order top to bottom
            pageShapes.Sort("@shape1.com.positiony > @shape2.com.positiony");
            tempRange.RemoveAll();
            FillRowRange(pageShapes, tempRange);
            pageShapes.RemoveRange(tempRange);
     
            double rowBottomY = tempRange.BottomY;
            tempRange.RemoveAll();
     
           
            while (pageShapes.Count > 0)
            {
                FillRowRange(pageShapes, tempRange);
                pageShapes.RemoveRange(tempRange);
                tempRange.TopY = rowBottomY - newSpace;
                rowBottomY = tempRange.BottomY;
                tempRange.RemoveAll();
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
    }
    private void FillColumnRange(ShapeRange pageShapes, ShapeRange tempRange)
    {
        int i = 1;
        do
        {
            tempRange.Add(pageShapes[i]);
            i++;
     
        }
        while (i <= pageShapes.Count && pageShapes[i - 1].RightX > pageShapes[i].LeftX);
    }
    private void FillRowRange(ShapeRange pageShapes, ShapeRange tempRange)
    {
        int i = 1;
        do
        {
            tempRange.Add(pageShapes[i]);
            i++;
     
        }
        while (i <= pageShapes.Count && pageShapes[i - 1].BottomY < pageShapes[i].TopY);
    }