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 15-08-2008, 22:32
sy168
Guest
 
Posts: n/a
Default How to select the black lines, fill in random colors?

How to select the black lines, fill in random colors?
Attached Images
 
Reply With Quote
  #2  
Old 16-08-2008, 00:34
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 Randomize me...

Here is a little code that does just that, basically it checks to make sure your shape has an outline, then makes sure it is black, then randomly picks a color from the ActivePalette to fill the black outline. Enjoy!
Code:
Sub RandomizeOutlineColor()
    Dim n As Long, num As Long
    Dim s As Shape
    
    num = ActivePalette.ColorCount 'Get the number of colors in our palette
    
    Optimization = True
    
        For Each s In ActivePage.Shapes
            If s.Outline.Type = cdrOutline Then
                n = CLng(Fix(Rnd() * num)) + 1 'Get a random color from the palette
                If s.Outline.Color.Name = "Black" Then s.Outline.Color = ActivePalette.Color(n)
            End If
        Next s
        
    Optimization = False
    ActiveWindow.Refresh
End Sub
If you have CorelDRAW X4 you can easily find the black outline shapes with a little CQL. Code would look like this:
Code:
Sub RandomizeOutlineColorX4()
    Dim n As Long, num As Long
    Dim s As Shape
    
    num = ActivePalette.ColorCount 'Get the number of colors in our palette
    
    Optimization = True
    
        For Each s In ActivePage.Shapes.FindShapes(Query:="@outline.color = 'black'")
            n = CLng(Fix(Rnd() * num)) + 1 'Get a random color from the palette
            s.Outline.Color = ActivePalette.Color(n)
        Next s
        
    Optimization = False
    ActiveWindow.Refresh
End Sub
Best of luck!

-Shelby
Reply With Quote
  #3  
Old 16-08-2008, 04:23
sy168
Guest
 
Posts: n/a
Default

Thank you very much, Shelby
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 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
Random Outlines TTerrell General 2 18-06-2007 09:06
How To Select Similar Colors In Corel X3 SIGNTIST2004 CorelDRAW/Corel DESIGNER VBA 2 27-12-2006 17:19
I created 3 lines to form a triangle, but I can't fill it Alex FAQ 1 25-05-2005 10:50
Relace all colors but black... ddonnahoe CorelDRAW/Corel DESIGNER VBA 7 22-11-2004 19:09
How can I change middle colors in a custom Fountain Fill Steve CorelDRAW/Corel DESIGNER VBA 3 13-12-2002 20:11


All times are GMT -5. The time now is 13:30.


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