![]() |
#1
|
|||
|
|||
![]()
Hi, I'm newbie in CorelDraw VBA. Our client has a requirement about checking shape's RGB values, if R=0, G=0, B=0 then change color mode form RGB to CMYK
and set C=0, M=0, Y=0 and K=100. I've checked out all the CDRX13's ojects method and properties , there is no directly way to set or get RGB/CMYK Values. Any one could show me a little hint. thanks. Regards Mitchell Hu |
#2
|
||||
|
||||
![]()
I can think of several ways to do this. Here is a little help to get you started. I have included how to find the RGB color and then you can either just convert that to CMYK or use CMYKAssign to give it the color of you choice.
Code:
Sub RGBblacktoCMYKblack() Dim s As Shape For Each s In ActivePage.Shapes If s.Fill.Type = cdrUniformFill Then If s.Fill.UniformColor.Type = cdrColorRGB Then If s.Fill.UniformColor.RGBRed = 0 And s.Fill.UniformColor.RGBGreen = 0 And s.Fill.UniformColor.RGBBlue = 0 Then 's.Fill.UniformColor.ConvertToCMYK 'Simply Convert the color s.Fill.UniformColor.CMYKAssign 0, 0, 0, 100 'or actually assign a CMYK color to the shape End If End If End If Next s End Sub -Shelby |
#3
|
|||
|
|||
![]()
Thaks a lot !!!
I will try your code later. Cause I use Delphi to generate code, I have to check out of CDRX3 Object Model Reference data to find proper object, property or method. It's cost me a lot time. Mitchell Hu ![]() |
#4
|
||||
|
||||
![]()
hard to believe that Delphi's Object Class Browser can't search for 'CMYK' for example. And if it's so, then you'll spare you a ton of time by using CorelDRAW's built-in VBA Editor's Object Class Browser
|
#5
|
|||
|
|||
![]()
Just wondering: why would you use Delphi? you want to create a *.gms or a plug-in?
|
#6
|
|||
|
|||
![]()
Don't know if it helps you, but Corel already has a feature to do that.
Edit : Find and Replace : Replace Objects : Replace a colour Choose the "Find" colour (you will need to select "Other", the model RGB and the values 0,0,0 Choose the "Replace" clour (ditto using CMYK model) Then select either "fills" or "outlines" -- you can't do both in one go, for reasons best known to Corel (Corel, please its time we had a "fills and outlines" option!) In a multipage document, you also have to do every page separately (Corel, a multipage option would be sensible too). |
#7
|
|||
|
|||
![]()
And then I saw this, which I haven't had time to investigate but looks like it probably does the job better.
http://forum.oberonplace.com/showthread.php?t=1053 |
#8
|
|||
|
|||
![]()
Hi, Shelby:
Your code works, ha! ha! I change it in Delphi code as below, IT all work fine. Thanks a lot ---------------------------------------------------------------- procedure TForm3.RGBtoCMYK(Shape_ID: integer); begin bsCDShape := bsCDDoc.ActiveLayer.Shapes.Item[Shape_ID]; if (bsCDShape.Fill.UniformColor.RGBRed = 0) //RGB R=0; or (bsCDShape.Fill.UniformColor.RGBGreen = 0) //RGB G=0; or (bsCDShape.Fill.UniformColor.RGBBlue = 0) //RGB B=0; then bsCDShape.Fill.UniformColor.CMYKAssign(0, 0, 0, 100) else bsCDShape.Fill.UniformColor.ConvertToCMYK; end; ------------------------------------------------------------------ bytheway, Delphi is my only code tool and New Delphi CodeGear 2007 Delphi for Win32 is a very powerful tool, In Coreldraw automaion, We can use COM interface to handle all actions as VBA does. tanks all your reply and suggestions, this a very good forum for Coreldraw user. |
#9
|
|||
|
|||
![]()
VBA is built in to CorelDRAW so Delphi is definitely not the only tool available to you. If you run some benchmarks you will see a dramatic speed difference. The VBA engine runs in-process to the CorelDRAW object model, and anything done in Delphi (or C#, etc.) is running out-of-process so it incurs the marshalling overhead which can be quite large.
-James Quote:
|
#10
|
||||
|
||||
![]()
@jemmyell: I wonder if a famous DLL in-process injection technique may cancel this out-of-process marshalling speed degrade..
|
![]() |
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 |
CorelDRAW X3 VBA Code - Shape & Color LIster | JudyHNM | Code Critique | 2 | 05-04-2007 14:02 |
Find only shapes with compound path | zlatev | CorelDRAW/Corel DESIGNER VBA | 1 | 15-02-2005 07:05 |
Deleting Shapes on the Guides Layer | Rick Randall | CorelDRAW/Corel DESIGNER VBA | 2 | 28-09-2004 11:07 |
Transfer shapes from Draw to Paint; Using CorelScript in VB6 | DWGraphics | Corel Photo-Paint VBA | 1 | 18-08-2004 20:49 |
Generic code to process all shapes in a document | glennwilton | CorelDRAW/Corel DESIGNER VBA | 0 | 05-09-2003 03:13 |