element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Or choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Autodesk EAGLE
  • Products
  • More
Autodesk EAGLE
EAGLE User Chat (English) How to detect a 'usable' layer?
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Autodesk EAGLE requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 7 replies
  • Answers 3 answers
  • Subscribers 147 subscribers
  • Views 718 views
  • Users 0 members are here
Related

How to detect a 'usable' layer?

fatbeard
fatbeard over 3 years ago

running 5.12.0

Inside an ULP I want to know what layers in a board are available.

When I loop through the layers in a board with an ULP (like: board(B) B.layers(L) {some code using L} ) I get all signal layers; the layer list in the board editor only shows the ones defined in the DRC.The ones not defined in the DRC are reported as hidden to the ULP.

When a script tries to access one of the layers not listed in the editor, an error pops up stating that that layer is not available (which is IMO correct) and continues to use the next available layer.

 

Is there a way for an ULP to detect if a hidden layer is just hidden or not available at all, to prevent this from happening in a generated script?

  • Sign in to reply
  • Cancel
Parents
  • WarrenBrayshaw
    0 WarrenBrayshaw over 3 years ago

    What are you trying to achieve with this ULP?. What's the problem it will solve for you? I suspect there may be a different approach possible.

     

    You cannot determine the layers available by cycling through the Board object. As you have noticed, they are all listed there. You can only report if a layer is unused (dirty) and if it is being displayed (visible) or not.

    Which layers you can you can write to depends on the Eagle Edition you have.

     

    Which layers are shown with a ulp by cycling through the Board object. depends on the Edition and the source of the board file. In the Light version , a board started there only returns layers 1 and 16. But I can load a 2 layer board made in a 16 layer edition and it returns 16 layers.

     

    Note that you can open a 16 layer board in the Light (2 layers) version. You see the full design (16 layers in the layer drop down) but in the Light version you can only edit layers 1 and 16.of that design.

     

    Even reading the layer setup in the DRC does not help because that can be for a 2 layer board in a 16 layer capable edition. and visa versa.

     

    So for a script that must run on different editions, it must determine which layers are valid for that edition.

     

    Are you are saying that a 'usable layer' must be a layer quoted in the DRC layer setup ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • fatbeard
    0 fatbeard over 3 years ago in reply to WarrenBrayshaw

    Well, I bit the bullet so to speak and hacked a bit into the binary (after all, the board file is the only thing I'm certain of when the ULP is running)...

     

    In short, it turns out that the binary is structured into records of 24 bytes; the first byte being the record type: type 0x13 is a layer definition where byte 3 is the layer number.

    Byte 2 contains flags: bit 0 tells if the layer is valid for this editor and bit 1 tells if the layer is editable (active).

    The layer name is only inside the record if it is 9 characters or shorter (and not easy to extract otherwise), but a layers() loop will get the name easy enough.

    This functions well, although this may not work as expected if the Eagle license does not allow all layers listed in the board's DRC (I have currently no way of testing this).

     

    From what I see in later versions that use the easier to parse XML format, the critical layer parameter there is "active" (albeit that I do not have much to compare here).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • fatbeard
    0 fatbeard over 3 years ago in reply to WarrenBrayshaw

    Well, I bit the bullet so to speak and hacked a bit into the binary (after all, the board file is the only thing I'm certain of when the ULP is running)...

     

    In short, it turns out that the binary is structured into records of 24 bytes; the first byte being the record type: type 0x13 is a layer definition where byte 3 is the layer number.

    Byte 2 contains flags: bit 0 tells if the layer is valid for this editor and bit 1 tells if the layer is editable (active).

    The layer name is only inside the record if it is 9 characters or shorter (and not easy to extract otherwise), but a layers() loop will get the name easy enough.

    This functions well, although this may not work as expected if the Eagle license does not allow all layers listed in the board's DRC (I have currently no way of testing this).

     

    From what I see in later versions that use the easier to parse XML format, the critical layer parameter there is "active" (albeit that I do not have much to compare here).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube