OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-02-2013, 03:13
Harry Harry is offline
Member
 
Join Date: Apr 2007
Location: London UK
Posts: 58
Default ShapeRange.Sort

I'm trying to understand the X6 VBA help file for ShapeRange.Sort

In the example, I see

sr.Sort " @shape1.Top * 100 - @shape1.Left > @shape2.Top * 100 - @shape2.Left"

The example does not define shape1 or shape2, so I presume these are undocumented placeholders for the two values that need to be compared.

So, I try a test ...

Dim sr As ShapeRange
Dim s As Shape
Dim l As Layer

Set sr = ActivePage.Shapes.FindShapes(Type:=cdrGroupShape)


I prove it has found my shapes and that each shape defines a ZOrder:

For Each s In sr
MsgBox Format(s.ZOrder, "###")
Next s


And now I try to sort on it ...

sr.Sort " @shape1.ZOrder < @shape2.ZOrder"


Error: ZOrder is not a method of 'shape'. Very strange, since it was a method of shape when called for the msgbox.

I try a few other expressions.

sr.Sort " @s1.ZOrder < @s2.ZOrder"


Still Error: ZOrder is not a method of 'shape'.

sr.Sort " @sr1.ZOrder < @sr2.ZOrder"


Error: Identifier sr1 is not a method of 'pair'


So, is there something missing from the help example? What is the correct compare expression ?
Reply With Quote
  #2  
Old 21-02-2013, 04:43
Harry Harry is offline
Member
 
Join Date: Apr 2007
Location: London UK
Posts: 58
Default

I did some more work on this. The problem seems to be specific to ZOrder. Other elements of shape can be compared. ZOrder seems to be an exception.

So, I "fixed" it by:

For Each s In sr
s.Name = Format(s.ZOrder, "000")
Next s


and then I could sort on

sr.Sort " @shape1.Name > @shape2.Name"

Last edited by Harry; 21-02-2013 at 04:47.
Reply With Quote
  #3  
Old 22-02-2013, 00:07
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default ZOrder

I am trying to figure out why you want to compare the zOrder, are you trying to reverse it? If so, why not just use:
Code:
sr.ReverseRange
-Shelby
Reply With Quote
  #4  
Old 01-03-2013, 10:51
Harry Harry is offline
Member
 
Join Date: Apr 2007
Location: London UK
Posts: 58
Default

Quote:
Originally Posted by shelbym View Post
are you trying to reverse it? -Shelby
No, but corelQuery returns the matching shapes, in apparently random order. I'm not sure what if any order it takes, perhaps it is the order in which the shapes were created, but it is certainly not ascending ZOrder.

In my case, I was moving several overlapping objects to separate layers. It was therefore important to create the new layers in the same order as the original objects. Simple iterating through a shaperange did not achieve that until the shaperange was pre-sorted in ZOrder.

Last edited by Harry; 01-03-2013 at 10:55.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thumbnailer sort thumbs by date? inkmachine Other Oberon Commercial Products 3 18-04-2012 20:03
X5 shaperange bug? knowbodynow CorelDRAW/Corel DESIGNER VBA 3 20-03-2012 23:08
shaperange.add HeauxmBru Macros/Add-ons 10 30-06-2011 22:15
Sort/Order by position Shaddy CorelDRAW/Corel DESIGNER VBA 6 21-08-2005 13:03
Open File Dialogue box won't sort - v11.0 Anonymous General 0 12-01-2005 19:09


All times are GMT -5. The time now is 11:59.


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