0

I am trying to determine the value of the black in each text item in an illustrator document. I have managed to successfully run the count words script and alter it to apply a tint and a new color to each bit of text. Now I need to alter the tint based on its existing black value. Here is my attempt so far.

Set appRef = CreateObject("Illustrator.Application")

If (appRef.Documents.Count = 0) Then
    Set docRef = appRef.Documents.Add
Else
    Set docRef = appRef.ActiveDocument
End If

If (docRef.TextFrames.Count = 0) Then
    Set textArt = docRef.TextFrames.Add
    textArt.Position = Array(100, 425)
    textArt.Contents = "Illustrator Scripting"
    textArt.TextRange.CharacterAttributes.Size = 48
End If

spotName = "CreateSpotSwatch"

' Create CMYKColor
Set cmykColor = CreateObject("Illustrator.CMYKColor")
cmykColor.Cyan = 0
cmykColor.Magenta = 0
cmykColor.Yellow = 0
cmykColor.Black = 100

' Create Spot
Set Spot = docRef.Spots.Add
Spot.Color = cmykColor
Spot.ColorType = 2 ' aiSpot
Spot.Name = spotName

For Each textArt In docRef.TextFrames

    Set spotColor = CreateObject("Illustrator.SpotColor")
    Set textArtRange = textArt.TextRange

    Set color = textArtRange.CharacterAttributes.strokeColor.Black  
    spotColor.Tint = color ' This should be the value of the black
    spotColor.Spot = Spot

    textArtRange.CharacterAttributes.strokeColor = spotColor
Next

Also happy to do this in Java if need be.

1

Ok so I have worked it out, it was a matter of actually using the fill color I think.

Set Color = textArtRange.CharacterAttributes.FillColor spotColor.Tint = Color.Black

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.