Skip to main content
Mar 22, 2013 7:19 PM UTC
Solved

Change color entities in macro

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

    Dutch_MnAnswer
    Apr 8, 2013 12:48 PM UTC

    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

    3 replies

    Mar 28, 2013 12:18 PM UTC

    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_MnAnswer
    Apr 8, 2013 12:48 PM UTC

    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

    Apr 9, 2013 5:25 PM UTC

    Wow it work so well!!!

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