I draw a yellow square (C=0, M=0, Y=100, K=0) in an empty document, how to define only this color into the variable (cyan=false, magenta=false, yellow=true, black=false) ?
C# code, cmyk based color value 0 to 100, argb based color value 0 to 255
Shape s = corelApp.ActiveSelection; Color color = s.Fill.UniformColor; if (color.IsCMYK) { int c = color.CMYKCyan; int m = color.CMYKMagenta; int y = color.CMYKYellow; int k = color.CMYKBlack; System.Windows.MessageBox.Show(y.ToString()); }
Thanks for the answer, but I mean the definition of color separation in the whole document (As well as "File -> Print -> Color -> Print Separations"), let's say I have 5 yellow squares and 4 magenta squares in my document, how can I find what colors are used in the whole document and write finding color into the variables (cyan=false, magenta=true, yellow=true, black=false) without sorting of all shapes?
try use the class "PrintSeparationClass"
I use this code:
for (int i = 1; i <= Corel.ActiveDocument.PrintSettings.Separations.Plates.Count; i++){ bool plates = Corel.ActiveDocument.PrintSettings.Separations.Plates[i].Enabled; MessageBox.Show(Convert.ToString(plates));}
but all plates have a "true" status, regardless of what is drawn on the document.
Maybe there is still some way?
i test your code in API 17 and works fine, true to yellow and false for anothers.
My version CorelDraw is 17.6, and my c# code written on Microsoft Visual Studio Professional 2015.. My code work with CorelDraw X5, but does not work in other versions.. Why your config is working and what wrong with my configuration?
K
maybe you use The namespace to get The plates properties,you Will need use aplication context in thia exemple. Check your "Corel" variable if his is a applivation object or alias namespace
First I add reference to the "CorelDRAW 17.6 Type Library" use Visual Studio interface.
Then I initialized "Corel" variable with this code:
public CorelDRAW.Application Corel;
Corel = new CorelDRAW.Application();
And if I try to write code with "Corel" variable I get a hints:
Did I do it right?
this is your problem, you cannot create a new application object, you need use the object from running instance of coredraw, if you is building a Addon or VSTA macro you can overrride the main entry of your addon or macro passing application object by reference.
For exemple
public partial class ControlUI : UserControl { private Corel.Interop.VGCore.Application corelApp; public ControlUI(Corel.Interop.VGCore.Application app) { this.corelApp = app; InitializeComponent(); }
}
This is my code with namespaces.. I try to use the object from running instance of coredraw, following example above, but i got mistakes of compilations. How do I change the code, according with your advice?
using System;using System.Windows.Forms;
namespace WindowsFormsApplication1{ public partial class Form1 : Form { public CorelDRAW.Application Corel; public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { Corel = new CorelDRAW.Application();
for (int i = 1; i <= Corel.ActiveDocument.PrintSettings.Separations.Plates.Count; i++) { bool plates = Corel.ActiveDocument.PrintSettings.Separations.Plates[i].Enabled; MessageBox.Show(Convert.ToString(plates)); } } }}
For you get the object from running instance is more complicated, you will need use the ROT, running object table, you can take a look in this post http://adndevblog.typepad.com/autocad/2013/12/accessing-com-applications-from-the-running-object-table.html.
In case my code, i use addon model, is more simple, but don't works if you need attach your standalone app in corel com object, in this case you will need use the ROT.