![]() |
#1
|
|||
|
|||
![]()
I need to know how to refer to groups of objects. For example, if I have selected two groups of objects and I wanted to resize the first group to match the size of the second group how would I reference the objects? Does this make sense?
Thanks, Chris (Hunt) |
#3
|
|||
|
|||
![]()
Thanks Alex, I did a search as you suggested but I still don't see how to use shaperange in the way I am thinking. Imagine I have a piece of clip art (a group of objects) and a square. I select the clipart and then one square. I want to centre the clipart to the square and resize it to 85% of the squares size. I can't figure out how Coreldraw is referencing the objects. Here is some code I amended from recording a macro.
Code:
Sub sizetoobject() Dim px As Double, py As Double Dim sx As Double, sy As Double ActiveDocument.ReferencePoint = cdrCenter ActiveDocument.Unit = cdrMillimeter If ActiveDocument Is Nothing Then End If ActiveShape Is Nothing Then End ActiveLayer.Shapes(1).AlignToShape cdrAlignHCenter, ActiveLayer.Shapes(2), cdrTextAlignBoundingBox ActiveLayer.Shapes(1).AlignToShape cdrAlignVCenter, ActiveLayer.Shapes(2), cdrTextAlignBoundingBox px = ActiveLayer.Shapes(2).SizeWidth * 0.85 py = ActiveLayer.Shapes(2).SizeHeight * 0.85 sx = ActiveLayer.Shapes(1).SizeWidth sy = ActiveLayer.Shapes(1).SizeHeight ActiveLayer.Shapes(1).Stretch (px / sx), (py / sy) End Sub How can I name an item if I don't know how Coreldraw is referencing them? I'm obviously missing something and not understanding how it works. Chris |
#4
|
||||
|
||||
![]()
Chris,
If you use Layer.Shapes, then the indexing will be the Z-order of shapes on that layer. The topmost shape will be #1, the one directly below it is #2 and so on. That is basically the order as shapes appear in the Object Manager tree. However if you use ActiveDocument.Selection.Shapes (or ActiveSelection.Shapes) then the selected objects go in the order of selection of the shape. The last selected object will be shape #1, the one before it will be #2 and so on. That is, if you Shift-Click a bunch of objects one after another, the selection list will be built in the reverse order of your selection. So, to your problem, if you want to select many objects of a clipart and then select a rectangle, you should select the rectangle the last (e.g. marquee-select all your clipart objects and then shift-click the rectangle). This way you will know that your reference rectangle will be the first object in the Selection shape collection and the rest of the object will follow. Then you can separate them like this: Code:
Dim sRect As Shape Dim sRestOfObjects As ShapeRange Set sRect = ActiveSelection.Shapes(1) Set sRestOfObjects = ActiveSelection.Shapes.AllExcluding(1) Code:
Sub FitObjects() Dim sRect As Shape Dim sRestOfObjects As ShapeRange Dim x As Double, y As Double Dim w As Double, h As Double Dim w1 As Double, h1 As Double Set sRect = ActiveSelection.Shapes(1) Set sRestOfObjects = ActiveSelection.Shapes.AllExcluding(1) sRect.GetBoundingBox x, y, w, h w1 = w * 0.85 h1 = h * 0.85 x = x + (w - w1) / 2 y = y + (h - h1) / 2 sRestOfObjects.SetBoundingBox x, y, w1, h1, True, cdrCenter End Sub |
#5
|
|||
|
|||
![]()
Thanks Alex,
That was the exact help I needed. Your explanation was very clear. I'd realised I needed to use ActiveSelection.Shapes but I couldn't get that the last object selected would be shape #1, this seems backwards to me but is straightforward once realised. I've got what I wanted working now but would have got nowhere further without your help. Best wishes, Chris |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trimming multiple objects in one swoop? | jahmer | General | 1 | 17-11-2006 09:10 |
Stepping through objects, identifying attributes, storing data for later use | Mitsu1 | CorelDRAW/Corel DESIGNER VBA | 6 | 08-11-2006 12:09 |
Glitches with Names of Objects | Granite Golem | CorelDRAW/Corel DESIGNER VBA | 14 | 01-06-2005 04:38 |
I need to update objects visibility faster | NEHovis | Corel Photo-Paint VBA | 0 | 18-07-2003 08:54 |
How do I reference ArtisticText objects? "Shape Index o | andyb | CorelDRAW/Corel DESIGNER VBA | 1 | 10-07-2003 15:59 |