I am trying to figure out how to find if there are any spot colors in the CDR file using CQL
I am able to find Fountains by during thisActivePage.Shapes.FindShapes(Query:="@fill.type = 'fountain'")
But how do I write the query to see if there are any spot colors, pantones, cmyk, rgb, lab, etc.So tried this and it does not workActivePage.Shapes.FindShapes(Query:="@colors.find('cmyk')")Any ideas?
Thanks ,
Tom
I have an idea or two. :-) If you want to find Spot Colors you can do something like this:
Sub FindSpotColors() Dim srSpotFill As ShapeRange Dim srSpotOutline As ShapeRange Set srSpotFill = ActivePage.Shapes.FindShapes(Query:="@fill.color.IsSpot = true") Set srSpotOutline = ActivePage.Shapes.FindShapes(Query:="@outline.color.IsSpot = true") MsgBox "Fill: " & srSpotFill.Count & " Outline: " & srSpotOutline.Count End Sub
Or you could combine them like this:
Sub FindSpotColors2() Dim srSpot As ShapeRange Set srSpot = ActivePage.Shapes.FindShapes(Query:="@fill.color.IsSpot = true or @outline.color.IsSpot = true") MsgBox srSpot.Count End Sub
You can also do the same for CMYK as there is a IsCMYK:
Sub FindCMYKColors() Dim srCMYK As ShapeRange Set srCMYK = ActivePage.Shapes.FindShapes(Query:="@fill.color.IsCMYK = true or @outline.color.IsCMYK = true") MsgBox srCMYK.Count End Sub
There is no IsRGB or IsLAB so you will want to use the color.type to find these, which of course will also still work for Spot and CMYK:
Sub FindColorsByType() Dim srSpot As ShapeRange, srPantoneHex As ShapeRange Dim srCMYK As ShapeRange, srLAB As ShapeRange Set srSpot = ActivePage.Shapes.FindShapes(Query:="@fill.color.type = 'spot' or @outline.color.type = 'spot'") Set srPantoneHex = ActivePage.Shapes.FindShapes(Query:="@fill.color.type = 'pantone hex' or @outline.color.type = 'pantone hex'") Set srCMYK = ActivePage.Shapes.FindShapes(Query:="@fill.color.type = 'cmyk' or @outline.color.type = 'cmyk'") Set srLAB = ActivePage.Shapes.FindShapes(Query:="@fill.color.type = 'lab' or @outline.color.type = 'lab'") MsgBox "Spot: " & srSpot.Count & vbNewLine & _ "Pantone Hex: " & srPantoneHex.Count & vbNewLine & _ "CMYK: " & srCMYK.Count & vbNewLine & _ "LAB: " & srLAB.Count End Sub
Pantone are tricky as sometimes they will be spot, pantone hex, etc... If you want to see what CQL reports the color type as you can select your shape and type this into the immediate window:
?ActiveShape.Evaluate("@fill.color.type")
You should get a result like this:
lab
Or if you really want to get crazy. Draw several shapes, fill them with different color types, GROUP them, make sure the new group is selected and type this into the immediate window:
?ActiveShape.Evaluate("@children.foreach(array(), $lasteval.addarray($item.colors)).unique.convert($item.type).join(',')")
pantone hex,cmyk,lab,spot,spot
Hope that helps,
-Shelby
Shelby,
This is perfect!!!!
I have also done this to get any shapes that are MeshDim sr6 As ShapeRangeSet sr6 = ActivePage.Shapes.FindShapes(Query:="@type = 'Mesh'")
But I am having trouble getting Overprint Fill.
I have tried...Dim sr6 As ShapeRangeSet sr6 = ActivePage.Shapes.FindShapes(Query:="@type = 'overprint'")
and
Dim sr6 As ShapeRangeSet sr6 = ActivePage.Shapes.FindShapes(Query:="@fill.type = 'overprint'")
They both can not find the shape.
Any ideas?
Tom,
Depending on what you are doing you really shouldn't need the If Then, CQL will find just the specific Lens Type. But again, that depends on your end goal. :-) Second, if I was using the If I wouldn't search the entire page again I would only search your already found ShapeRange. :-) Finally, instead of using cdrLensFishEye you need just just use the number. So cdrLensFishEye is equal to 1. I will include the list.
Sub Lenses() Dim effectsLensShapes As ShapeRange Dim effectsLensTypes As ShapeRange Set effectsLensShapes = ActivePage.Shapes.FindShapes(Query:="!@com.Effects.LensEffect.IsNull") If (effectsLensShapes.Count > 0) Then Set effectsLensTypes = effectsLensShapes.Shapes.FindShapes(Query:="@com.Effects.LensEffect.Lens.Type = 1") End If End Sub
Here are the number values:
GREAT!!!!
The list was perfect.
I have 2 other requests that can up in our designer meeting. Can these also be done in CQL?
1) Check for Powerclips and then get the shapes that are in a Powerclip.
2) The other is to check the nodes of a shapes to see if they are over 10,000 nodes or more.
Thanks,
Were you able to figure out #1 and #2? Been trying to figure it out but have difficulties.
Any help would be appreciated.
Here is a little example of how to find all shapes in powerclips:
Sub TestFindAllShapes() Dim s As Shape, sr As ShapeRange Set sr = FindAllShapes.Shapes.FindShapes(Type:=cdrBitmapShape) For Each s In sr.Shapes s.Bitmap.ConvertToBW cdrRenderLineArt Next s End Sub Function FindAllShapes() As ShapeRange Dim s As Shape Dim sr As ShapeRange Dim srAll As New ShapeRange, srPowerClipped As New ShapeRange If ActiveSelection.Shapes.count > 0 Then Set sr = ActiveSelection.Shapes.FindShapes() Else Set sr = ActivePage.Shapes.FindShapes() End If Do For Each s In sr.Shapes.FindShapes(Query:="!@com.powerclip.IsNull") srPowerClipped.AddRange s.PowerClip.Shapes.FindShapes() Next s srAll.AddRange sr sr.RemoveAll sr.AddRange srPowerClipped srPowerClipped.RemoveAll Loop Until sr.count = 0 Set FindAllShapes = srAll End Function
Anyway to do it without looping through the Powerclips/Shapes?
Also whenI run this on macro
ActivePage.Shapes.FindShapes(Query:="!@com.curve.IsNull")I get this error. From Doc Info: 70752 points, 2569 objects, 2567 Curves
If I run it on a smaller file it has no problem.( 59285 points, 706 Objects, 706 Curves)
For Shapes in Powerclips...
Something like this maybe so we won't have to loop????
Dim powerClips As ShapeRangeDim pcBitmaps As ShapeRange
powerClips = s.FindShapes(Query: "!@com.Powerclip.IsNull")If (powerClips.Count > 0) Then pcBitmaps = powerClips.Shapes.FindShapes(Type:= VGCore.cdrShapeType.cdrBitmapShape) If (pcBitmaps.Count > 0) Then
End IfEnd If
You need to loop through them to find all the shapes. You might be able to do another FindShapes, but I would have to think about it. ;-) Powerclips make my head hurt.
As for your error message that means you hit a shape in your document that was not a curve. Easy enough to reproduce, just have one curve and one line of text run, and you will get the error message.
Hi Shelby,
I fixed the error, you were right there was a text object that caused the error.
As for finding the shapes in the Powerclips...I tried this... But I get an error "Object Required"
Set powerClipShapes = ActivePage.Shapes.FindShapes(Query:="@com.Powerclip.Shapes.Count > 0")
Set powerClipShapes2 = powerClipShapes.Shapes.FindShapes(PowerClip.Shapes.FindShapes(Query:="@type = 'Bitmap'"))Tried this... But I get an error "Syntax Error
Set powerClipShapes = ActivePage.Shapes.FindShapes(Query:="@com.Powerclip.Shapes.Count > 0 and @com.Powerclip.Shapes.Findshapes(Query:="@type = 'Bitmap'")")
Tried this... But I get an error "Invalid Character" - the 2nd @ sign
Set powerClipShapes = ActivePage.Shapes.FindShapes(Query:="@com.Powerclip.Shapes.Count > 0")Set powerClipShapes = powerClipShapes.Shapes.FindShapes(Query:="@com.Powerclip.Shapes.Count > 0 and @com.Powerclip.Shapes.Findshapes(Query:="@type = 'Bitmap'")")
I need to be able to find the bitmap objects/shapes within a powerclip(s) without looping.I am not sure what I am doing wrong. When I drill down through the powerClipShapes, I can see under shapes (item1) powerclip and then under shapes (item1) I can see the type as cdrBitmapShape.
Why can't you loop?
Some files that we get can have several Powerclips and hundreds of shapes within the powerclips.
So it then becomes a performance issue.
Besides figuring out the shape inside of a powerclip I also have to determine if it is CMYK, Spot, RGB, etc.
This is the last obstacle I am facing.