OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   X5 shaperange bug? (http://forum.oberonplace.com/showthread.php?t=8124)

knowbodynow 19-03-2012 10:02

X5 shaperange bug?
 
Create a couple of rectangles near the top of the page and overlap them. Select both rectangles and run the following code:

Code:

sub ShapeRangeTest()

dim sr as ShapeRange, sd as Shaperange

        Set sr = ActiveSelectionRange
             
        If sr.Shapes.Count > 0 Then
            sr.Group
            MsgBox "GROUPED"
        End If
             
        Set sd = sr.Duplicate
        sd.Group
        sd.AlignToPageCenter cdrAlignHCenter
        sd.AlignToPageCenter cdrAlignVCenter
             
        sd.CreateSelection
       
        MsgBox "Test"
       
        sr.CreateSelection

End Sub

When I run this code Ibget the GROUPED message but the duplicated shapes are centred and the grouping is ignored. Moreover if I click on the desktop and then reselect one of the groups all four objects are selected as one group. If I comment out the line sd.group I still end up with all the objects grouped. What's going on? Please don't tell me there are no bugs!

I guess what I really want to know is how to remember a particular collection of objects so I can reselect it later. I was really comfortable coding with CD12 but find X5 a nightmare. Thanks.

shelbym 19-03-2012 12:00

ShapeRage.Group
 
The issue is when you Group a ShapeRange is returns a Shape, not a ShapeRange. You can look at me previous post on your Save issue, have to fix this.

I would recommend that you use step each line of code with F8, so you can watch what your code is doing. This will help find these types of issues.

-Shelby

knowbodynow 20-03-2012 18:56

Thanks for the reply but I don't get why the objects in the grouped shape end up centred, this defeats the point of grouping them. I do use F8 when testing code, also exit sub to test parts in isolation. Cheers!

shelbym 20-03-2012 23:08

ShapeRange
 
Do this, by hand, not in code. Create say three rectangles and group them. Then hold down CTRL and click one of the rectangles, notice the handles change from rectangles to circles, this is because you are selecting the shape, inside the group.

Another way to look at it, same three rectangles in the group. Open the Object Manager docker. Expand the group, and you will see the three rectangles select one from the Object Manager, and you see the same circle handles, shift select and you can select all three, but again you are selection the shapes in the group, not the group. Press P to align to page, and notice they align as individual shapes.

This is exactly what your code is doing, because you are selecting the ShapeRange, aka a range of shapes, it is selecting the shapes inside the group, and not the group itself, so when you do your align, it aligns them as individual shapes.

Does that make sense? If not, let me know, and I will try to explain another way.

-Shelby


All times are GMT -5. The time now is 19:08.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com