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 14-12-2007, 13:26
kliv
Guest
 
Posts: n/a
Default Array of colors?

I need to make a calibration bar like this:
So I made a shaperange named bar.
Bar(1) would be a cmyk 100, 0, 0, 0
Bar(2) would be a cmyk 66, 0, 0, 0
Bar(3) would be a cmyk 33, 0, 0, 0
and so on.
The index of bar depends on the lenght of the calibration bar (the height of document). From bar(13) the colors begin again with CMYKAssign 100, 0, 0, 0, CMYKAssign 66, 0, 0, 0 etc.
For the moment I did what I want manually, like this:
Code:
If k + 1 > 1 Then bar(1).Fill.UniformColor.CMYKAssign 100, 0, 0, 0
If k + 1 > 2 Then bar(2).Fill.UniformColor.CMYKAssign 66, 0, 0, 0
If k + 1 > 3 Then bar(3).Fill.UniformColor.CMYKAssign 33, 0, 0, 0
If k + 1 > 4 Then bar(4).Fill.UniformColor.CMYKAssign 0, 100, 0, 0
If k + 1 > 5 Then bar(5).Fill.UniformColor.CMYKAssign 0, 66, 0, 0
If k + 1 > 6 Then bar(6).Fill.UniformColor.CMYKAssign 0, 33, 0, 0
If k + 1 > 7 Then bar(7).Fill.UniformColor.CMYKAssign 0, 0, 100, 0
If k + 1 > 8 Then bar(8).Fill.UniformColor.CMYKAssign 0, 0, 66, 0
If k + 1 > 9 Then bar(9).Fill.UniformColor.CMYKAssign 0, 0, 33, 0
If k + 1 > 10 Then bar(10).Fill.UniformColor.CMYKAssign 0, 0, 0, 100
If k + 1 > 11 Then bar(11).Fill.UniformColor.CMYKAssign 0, 0, 0, 66
If k + 1 > 12 Then bar(12).Fill.UniformColor.CMYKAssign 0, 0, 0, 33
If k + 1 > 13 Then bar(13).Fill.UniformColor.CMYKAssign 100, 0, 0, 0
If k + 1 > 14 Then bar(14).Fill.UniformColor.CMYKAssign 66, 0, 0, 0
If k + 1 > 15 Then bar(15).Fill.UniformColor.CMYKAssign 33, 0, 0, 0
If k + 1 > 16 Then bar(16).Fill.UniformColor.CMYKAssign 0, 100, 0, 0
If k + 1 > 17 Then bar(17).Fill.UniformColor.CMYKAssign 0, 66, 0, 0
If k + 1 > 18 Then bar(18).Fill.UniformColor.CMYKAssign 0, 33, 0, 0
etc
and writing lines like that until I got bored...
I was thinking of an array of colors so my code would look like this
Code:
for i = 1 to k
bar(i).Fill.UniformColor. ??? color(i)
next i
Stuck there...
There must be a simpler way to do this - just can't see it right now...
Reply With Quote
  #2  
Old 14-12-2007, 15:35
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

I have an old macro that does a similar, yet a little simpler scale, see the attached zip for GMS file

the code in question is near the bottom:
Code:
   Do While x < maxX
      i = (i Mod 8) + 1
      Set sh = ActiveLayer.CreateRectangle(x, y, x + 8, y - 8)
      sh.Outline.Type = cdrNoOutline
      clr.StringAssign Choose(i, _
         "CMYK,USER,100,0,0,0,0", "CMYK,USER,80,0,0,0,0", "CMYK,USER,0,100,0,0,0", "CMYK,USER,0,80,0,0,0", _
         "CMYK,USER,0,0,100,0,0", "CMYK,USER,0,0,80,0,0", "CMYK,USER,0,0,0,100,0", "CMYK,USER,0,0,0,80,0")
      sh.Fill.ApplyUniformFill clr
      tmp.Add sh: x = x + 8
      Loop
I hope you'll be able to decipher the macro's logic by commenting out the 2 calls to boostStart and boostFinish, and then pressing F8 in VBAEditor (execute line-by-line) to see what part of code is responsible for.
Attached Files
File Type: zip wx_DomingoCutMarks.zip (12.9 KB, 417 views)
Reply With Quote
  #3  
Old 14-12-2007, 17:20
kliv
Guest
 
Posts: n/a
Default

Thank you so much. I've learn a few thing from your macro (macros in general to be honest...
The lines for color don't work - at least not in corel 11. There is no "StringAssign" method for color. I will try it at work, with x3.
Even so, I think I can now reduce my code to 12 lines. It's amazing how much you can learn by studying someoneelse's code, especially if that code is well written...
Reply With Quote
  #4  
Old 14-12-2007, 17:30
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

oh, nice you've found it useful. I guess you could use a workaround for v11 like this:
Code:
    Do While x < maxX
      i = (i Mod 8) + 1
      Set sh = ActiveLayer.CreateRectangle(x, y, x + 8, y - 8)
      sh.Outline.Type = cdrNoOutline
      dim clrStr$()
      clrStr=split( _
        Choose(i, _
         "100,0,0,0", "80,0,0,0", "0,100,0,0", "0,80,0,0", _
         "0,0,100,0", "0,0,80,0", "0,0,0,100", "0,0,0,80"), _
        ",")
      sh.Fill.ApplyUniformFill CreateCMYKColor(clrStr(0), clrStr(1), clrStr(2), clrStr(3))
      tmp.Add sh: x = x + 8
    Loop
Reply With Quote
  #5  
Old 14-12-2007, 18:11
kliv
Guest
 
Posts: n/a
Default

yes - works perfect. Exactly what I needed.
So in x3 your original code works... I think it's time to install x3 at home...
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
Getting a list of all colors in a Document CORNMEN CorelDRAW/Corel DESIGNER VBA 5 15-11-2008 05:14
256 colors Nico General 0 26-04-2007 02:10
Minimizing the number of colors used in a document Alex FAQ 1 24-05-2005 10:46
Palette (or Colors array) property in VBA class in CDR12 zlatev CorelDRAW/Corel DESIGNER VBA 7 22-02-2005 11:28
Wish to Convert Named Colors to Shape Color D_Green CorelDRAW/Corel DESIGNER VBA 1 12-09-2004 11:08


All times are GMT -5. The time now is 10:29.


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