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 28-11-2007, 21:32
mitchellhu mitchellhu is offline
Junior Member
 
Join Date: Nov 2007
Posts: 17
Default How to get or setup a shape's RGB /CMYK Values

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
Reply With Quote
  #2  
Old 29-11-2007, 00:34
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
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 RGBtoCMYK

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
Good luck,

-Shelby
Reply With Quote
  #3  
Old 29-11-2007, 21:33
mitchellhu mitchellhu is offline
Junior Member
 
Join Date: Nov 2007
Posts: 17
Default

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
Reply With Quote
  #4  
Old 30-11-2007, 09:48
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

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
Reply With Quote
  #5  
Old 30-11-2007, 10:48
kliv
Guest
 
Posts: n/a
Default

Just wondering: why would you use Delphi? you want to create a *.gms or a plug-in?
Reply With Quote
  #6  
Old 30-11-2007, 11:54
Harry Harry is offline
Member
 
Join Date: Apr 2007
Location: London UK
Posts: 58
Default Changing colours

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).
Reply With Quote
  #7  
Old 30-11-2007, 12:24
Harry Harry is offline
Member
 
Join Date: Apr 2007
Location: London UK
Posts: 58
Default

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
Reply With Quote
  #8  
Old 03-12-2007, 20:31
mitchellhu mitchellhu is offline
Junior Member
 
Join Date: Nov 2007
Posts: 17
Default

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.
Reply With Quote
  #9  
Old 04-12-2007, 09:22
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default

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:
Originally Posted by mitchellhu View Post
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.
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
  #10  
Old 04-12-2007, 09:34
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

@jemmyell: I wonder if a famous DLL in-process injection technique may cancel this out-of-process marshalling speed degrade..
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
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


All times are GMT -5. The time now is 18:09.


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