• 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 PCB Editor
  3. What's the best method for setting new subclass color?

Stats

  • Replies 4
  • Subscribers 159
  • Views 2194
  • Members are here 0
More Content

What's the best method for setting new subclass color?

EvanShultz
EvanShultz over 15 years ago

 I've been using the following code to successfully create new subclasses and set a color for them:

axlLayerCreateNonConductor("MANUFACTURING/TOP_SMT")
axlShell("scriptmode +i +n;color192;setwindow cvf.dialog;cvf layers_color manufacturing/top_smt 9;cvf okay;setwindow pcb")

 

I create a layer, then I run a script to open a form, select that newly created layer, then pick a number from the palette for the color I want. I have to manage the layer name in two places when editing or copying this code. And the color number means nothing whatsoever to me. Plus it could vary from one DB to another.

 

This seems so kludgey. Is there a better way? Perhaps in a single function I can create a layer and pick the color with human readable code (like the color symbols on pages 63-64 of algroskill.pdf from 16.3)?

  • Cancel
  • Sign in to reply
  • fxffxf
    fxffxf over 15 years ago

     you can replace the axlShell with

        lyr = axlLayerGet( "MANUFACTURING/TOP_SMT")

        lyr->color = 9

        axlLayerSet(lyr)  ; can also control visibility

     and finally after creating and assigning colors to all layers

        axlVisibleUpdate(t)

    You can get the rgb values of the current color numbers by

        rgb = axlColorGet(9)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • EvanShultz
    EvanShultz over 15 years ago

     Hi fxf,

    Of course, I see it now. On pages 171 and 111-113 of algroskill for 16.3. Thanks!

    It seems to me that pre-defined color symbols would be much easier for humans to manage, plus it would be DB-independent. 192 colors is a bit outragoues, but even the basic 24 colors would be quite helpful. In Concept, for instance, colors are assigned by human-readable names. I assume that there's no way to specify a color except by the abstract number, since if there was you'd know about it.

    On a similar subject, it is just me or is it batty that the number relating to the blue swatch (blue in my DB) in the axlShell function above is 9, but if I put "scriptmode +echo" in the command window and click on the blue swatch, I see that it is 8. So scripts are 0-based and the Allegro environment is 1-based!?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • fxffxf
    fxffxf over 15 years ago

    This may be due to the difference between 0 and 1 based indexing. Color 0 (axlColorGet(0)) is reserved for the background color which can never be assigned (if you tried assigning 0 axlLayerSet will return an error) to a layer. So the 1st color item in the color dialog is actually the RGB value of db color number 1. Since non-Pascal programmers normally use 0 as the start of an array, the difference is probably due to the color dialog array number appearing in the script which is <dialog array #> = <db color #> -1

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • EvanShultz
    EvanShultz over 15 years ago

    axlLayerCreateNonConductor("MANUFACTURING/TOP_SMT")
    lyr = axlLayerGet("MANUFACTURING/TOP_SMT")
    lyr->color = 9
    axlLayerSet(lyr)

    is awfully wordy. It's too bad there's no way to compact these statements, such as being able to pick a color during subclass creation. I've submitted an SR.

     

    Also, this method is predictably much faster than the script method I was using. Using the coarse timing available from getCurrentTime() and compareTime(), the time to create and color 8 subclasses went from 4 secs to 0 secs. Basically, it went from a noticeable delay to instantaneous.

    • 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