• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - Skill
  3. Set layer color with RGB than index using skill

Stats

  • Replies 3
  • Subscribers 19
  • Views 8952
  • Members are here 0
More Content

Set layer color with RGB than index using skill

ENEGUE
ENEGUE over 5 years ago

Hello everyone,

is there a way to set new added layer color by using RGB than index? as every user might define the index color differently.

Eugene

  • Cancel
  • Sign in to reply
  • steve
    steve over 5 years ago

    Yes - If you click the blank color you get the following which will allow you to define the color you want.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ENEGUE
    ENEGUE over 5 years ago in reply to steve

    Nice!, it is possible implement it using skill code?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DavidJHutchins
    DavidJHutchins over 5 years ago

    I wrote the code below this morning, it's almost working correctly...

    It will look for a color that matches the input rgb values & report it if found, otherwise it will find an unused color & set it to the input rgb values

    procedure((set_rgb_color @optional (Red -1) (Green -1) (Blue -1))
    let((Fail Colors ColorArr ColorUsed ColorList Layer Ptr String)
    (Fail = nil)
    (Ptr = nil)
    (Red = atoi(Red))
    (Green = atoi(Green))
    (Blue = atoi(Blue))
    printf("Red %L Green %L Blue %L\n" Red Green Blue)
    or(minusp(Red) minusp(Green) minusp(Blue) not(fixp(Red)) not(fixp(Green)) not(fixp(Blue))
    axlMsgPut("Red Green Blue values not positive integers; requires 3 int values between 0 to 255")
    (Fail = t)
    )
    unless(Fail
    declare(ColorArr[193])
    (ColorList = axlColorGet('all))
    for(i 1 192
    (Colors = car(ColorList))
    (ColorArr[i] = Colors);
    (ColorList = cdr(ColorList))
    unless(Ptr
    when(eq(nth(0 Colors) Red) && eq(nth(1 Colors) Green) && eq(nth(2 Colors) Blue)
    (Ptr = i)
    axlMsgPut("color %d matches input RGB values %d %d %d" Ptr nth(0 Colors) nth(1 Colors) nth(2 Colors))
    )
    )
    )
    unless(Ptr
    ; declare array & initialize to 0 values
    declare(ColorUsed[193])
    for(i 1 192
    ColorUsed[i] = 0;
    )
    foreach(Class ((axlGetParam "paramLayerGroup")->groupMembers)
    foreach(SubClass ((axlGetParam sprintf(String "paramLayerGroup:%s/paramLayer" Class))->groupMembers)
    (Layer = (axlGetParam sprintf(String "paramLayerGroup:%s/paramLayer:%s" Class SubClass)))
    ColorUsed[Layer->color] = 1;
    )
    )
    for(i 25 192
    unless(Ptr
    when(eq(ColorUsed[i] 0)
    (Ptr = i)
    (Fail = axlColorSet(Ptr list(Red Green Blue)))
    if(Fail then
    axlMsgPut("color %d set to RGB values %d %d %d" Ptr Red Green Blue)
    else
    axlMsgPut("axlColorSet() failed")
    )
    )
    )
    )
    )
    )
    )
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information