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 29-08-2003, 07:19
jwknight
Guest
 
Posts: n/a
Default speeding up object property changes

I'm currently using a loop that looks at each individual object in a document, checks its width and color and then either deletes it or moves it to a new layer. Some documents contain 20,000 objects. Using this type of loop is very slow. Does anyone have an ideas on how i could speed it up. The code i'm using is shown below. Many Thanks

For Each t In ActivePage.Shapes
ProgressBar1.Value = counter
counter = counter + 1
t.Outline.Color.ConvertToCMYK
If t.Outline.Width < 0.003 Then
t.Delete
ElseIf t.Outline.Color.CMYKBlack <> 100 Then
t.Outline.Width = 0.003
t.Layer = lyr
ElseIf t.Outline.Color.CMYKBlack = 100 Then
t.Outline.Width = 0.003
End If
Next
Reply With Quote
  #2  
Old 01-09-2003, 02:49
Lev
Guest
 
Posts: n/a
Default Re: speeding up object property changes

Read in Help about Optimization command, or seek for messages with this word in forum.

Now about your macro:

Code:
For Each t In ActivePage.Shapes
            ProgressBar1.Value = counter
            counter = counter + 1
            If t.Outline.Width < 0.003 Then t.Delete
'Delete objects before converting them to CMYK, you can save 19999 conversions in your 20000 objects :)
           t.Outline.Width = 0.003
'You are setting width = 0.003 to all undeleted objects, why not to make it here           
           t.Outline.Color.ConvertToCMYK      
           If t.Outline.Color.CMYKBlack <> 100 Then  t.Layer = lyr
        Next
HTH, Lev
Reply With Quote
  #3  
Old 01-09-2003, 15:03
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: speeding up object property changes

I believe that the following code will run even faster:

Code:
Dim srDelete As New ShapeRange
Dim srMove As New ShapeRange
Dim t As Shape
Dim c As Color

For Each t In ActivePage.Shapes
    ProgressBar1.Value = counter
    counter = counter + 1
    If t.Outline.Width < 0.003 Then
        srDelete.Add t
    Else
        t.Outline.Width = 0.003
        Set c = t.Outline.Color
        c.ConvertToCMYK
        If c.CMYKBlack <> 100 Then srMove.Add t
    End If
    
    srDelete.Delete
    srMove.CreateSelection
    ActiveSelection.Layer = lyr
Next t
The idea is that instead of changing each individual shape, you instead just store them in a shape range and then after all processing is done, just delete and move all the shape in one shot.

You can also update outlines in similar way if you just need to convert the outline color model just to see if it is black.
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
Palette (or Colors array) property in VBA class in CDR12 zlatev CorelDRAW/Corel DESIGNER VBA 7 22-02-2005 11:28
object lost it's linear fountain fill property after metalickaah CorelDRAW/Corel DESIGNER VBA 5 02-01-2005 22:36
Sorting entries in the object manager dan CorelDRAW/Corel DESIGNER VBA 1 18-08-2004 22:16
Font Substitution Upon Import RobC CorelDRAW/Corel DESIGNER VBA 4 10-03-2003 23:06
VB6, GMS questions bbolte CorelDRAW/Corel DESIGNER VBA 12 06-12-2002 15:32


All times are GMT -5. The time now is 00:24.


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