Skip to main content
1-Visitor
March 22, 2013
Solved

Change color entities in macro

  • March 22, 2013
  • 2 replies
  • 1691 views

Hi everybody,

I'm stuck with this one...

I try create macro to select everything countaining color fill exept for the Black, White, and no fill, and apply to a pre define color called Shaded Area who is a black 45%. If somebody could help with that one it will be much appreciated!

Thanks a lot!!!


Macro Shaded Area

Add color "Shaded Area"
activeDoc.colors["Shaded Area"].kind = "CMYK_color"
activeDoc.colors["Shaded Area"].color.type = "cmykValues"
activeDoc.colors["Shaded Area"].color.CMYK = "{CMYK 0 0 0 0.45}"

Select if Color is not equal to '$ISO_NOFILL'
Subselect if Color is not equal to 'Black'
Subselect if Color is not equal to '$ISO_WHITE'

Color "Shaded Area"
Select none

End Macro

    Best answer by Dutch_Mn

    This may not be the best way, but it works

    Macro Shaded_Area

    Define i as Integer
    Define Count as Integer
    Define el as Element


    Add color "Shaded_Area"
    activeDoc.colors["Shaded_Area"].kind = "CMYK_color"
    activeDoc.colors["Shaded_Area"].color.type = "cmykValues"
    activeDoc.colors["Shaded_Area"].color.CMYK = "{CMYK 0 0 0 0.45}"


    Select if Color is not equal to '$ISO_NOFILL'
    Subselect if Color is not equal to 'Black'
    Subselect if Color is not equal to '$ISO_WHITE'


    Count = activeDoc.selectedElements

    el = activeDoc.firstSelectedElement

    Define myFill as Fill
    myFill.type = "color"
    myFill.colSpec.type = "colorRef"
    myFill.colSpec.color = "Shaded_Area"

    for i = 1 to Count

    el.fill = myFill

    el = el.nextSelectedElement

    End for
    Select none

    End Macro

    2 replies

    1-Visitor
    March 28, 2013

    I've had a go at it myself, but can't find a way to change the color. When you use record macro, the resulting file is blank when at the bit where you change the color, making me think they've not put in an facility to change fill colours. Hope someone proves me wrong

    Dutch_Mn1-VisitorAnswer
    1-Visitor
    April 8, 2013

    This may not be the best way, but it works

    Macro Shaded_Area

    Define i as Integer
    Define Count as Integer
    Define el as Element


    Add color "Shaded_Area"
    activeDoc.colors["Shaded_Area"].kind = "CMYK_color"
    activeDoc.colors["Shaded_Area"].color.type = "cmykValues"
    activeDoc.colors["Shaded_Area"].color.CMYK = "{CMYK 0 0 0 0.45}"


    Select if Color is not equal to '$ISO_NOFILL'
    Subselect if Color is not equal to 'Black'
    Subselect if Color is not equal to '$ISO_WHITE'


    Count = activeDoc.selectedElements

    el = activeDoc.firstSelectedElement

    Define myFill as Fill
    myFill.type = "color"
    myFill.colSpec.type = "colorRef"
    myFill.colSpec.color = "Shaded_Area"

    for i = 1 to Count

    el.fill = myFill

    el = el.nextSelectedElement

    End for
    Select none

    End Macro

    1-Visitor
    April 9, 2013

    Wow it work so well!!!

    Big thanks to you, it is much appreciated!!!!