element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • 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
  • Settings
Autodesk EAGLE
  • Products
  • More
Autodesk EAGLE
EAGLE User Support (English) SOLVED: How do I set an attribute on all parts on a single schematic sheet?
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Autodesk EAGLE to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 6 replies
  • Answers 1 answer
  • Subscribers 172 subscribers
  • Views 1321 views
  • Users 0 members are here
  • bom
  • ulp
  • attributes
Related

SOLVED: How do I set an attribute on all parts on a single schematic sheet?

AnalogNotes
AnalogNotes over 12 years ago

Hiya everybody,

 

I'm trying to figure out if I have missed something obvious...

 

I have a multi-sheet design, and I'm trying to get a separate bill of materials for each sheet of that design.  (It's a DIY project, and I want to say in the instructions, "collect all the parts for the PSU".)  In the past, when there were only a couple sheets, I would delete everything except for the sheet I was working with and use the ULP to output the BOM for what remained.  Now that I have 18 sheets in my project that is a bit less convenient...  image

 

I think I have two options to fix this.  1) Add an attribute to every part and use my BOM spreadsheet to sort them, and 2) Modify the BOM ULP to list parts by schematic sheet.  Are there other options that I should consider?

 

I have tried setting attributes, but so far, I have only been able to add them globally or to each part individually.  I have about 1100 parts, so I'm trying not to have to add attributes to each part one at a time!  I tried the group command, selected everything on a sheet and then tried to use the attribute command line, but when I typed "attr SECTION 'PSU'" that gave me an invalid part or gate error.  I also tried grouping and then "attr * SECTION 'PSU'", but that set a global attribute.  Is it possible to add an attribute to a group of parts or is it only possible to set a global or individual part attribute one at a time?

 

I'm starting to learn how to program a ULP (attended the webinar about ULPs yesterday, thanks Ed) but I haven't gotten very far yet and impatience has started to rear it's ugly head...

 

Thanks,

Doug

  • Sign in to reply
  • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago

    Looks like attrib-add108.ulp is the answer.  Select the group of parts, then run that ULP.

     

    Thanks to George at US tech support for pointing it out and to Bob Starr for writing it...

     

    Regards,

    Doug

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to AnalogNotes

    The attrib-add script does what I needed it to do, but just for grins I kept at it on my own ULP, and I figured I'd throw it up here to see if anybody else could use it as a template.  I certainly don't think it's good enough to waste on an upload to the ftp site.  Just modify the "ATTRIBUTE" line if you want to do something else to each part...

     

    EDIT:  Looks like there are actually a couple problems with this script.  It seems that only the parts on the first sheet get the attributes.  I've played around with adding sprintf(tmp, "edit .s%d;\n", S.number); and Script += tmp; before the commands for each page, but then when I run the script, EAGLE crashes.  Weird!  It's the only time I've ever seen EAGLE crash.  My first guess is that the Script gets too big and overflows some buffer on exit().  I need to learn about the output command so that I can create the script in a text file and then run it...  -DDW 20121129

     

     

    #usage "<b>Adds PAGE number attribute to each part on each page of a schematic.</b>";

     

    string Version = "0.10";

    string tmp = "";

    string Message = "";

    string Script = "";

     

    if (!schematic) {

      dlgMessageBox("Start this ULP from a Schematic...", "OK");

    } else {

      schematic(SCH) {

        sprintf(tmp, "Schematic Name:\n%s\n", SCH.name);

        dlgMessageBox(tmp);

        SCH.sheets(S) {

          sprintf(Message, "Sheet %d\n---------\nParts:\n", S.number);

          S.parts(P) {

            sprintf(tmp, "%s\n", P.name);

            Message += tmp;

            sprintf(tmp, "ATTRIBUTE %s PAGE '%d';\n", P.name, S.number);

            Script += tmp;

          }

        dlgMessageBox(Message);  // Dialog box with list of parts on page

        }

      }

      //dlgMessageBox(Script);  // Debugging - show script before executing

      exit(Script);

    }

     

    I wish each sheet had it's own text name instead of just a number, but that is because I'm still on version 5.  (Looks like version 6 includes both a "headline" and a "description"...)

     

    Regards,

    Doug

     

    Message was edited by: Doug Wellington

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to AnalogNotes

    Doug Wellington wrote:

    >[...]

    >I wish each sheet had it's own text name instead of just a number. 

    >(Maybe that's included in version 6?)  Guess that's not too big of a

    >complaint though...

     

    perhapse you can use an attribute atttached to a frame (if you have

    page frames)

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago in reply to AnalogNotes

    Yep, I modified my script to use output() and wrote all the commands into a file and then I ran the file manually after the ULP finished, and it worked!

     

    I even managed to crash things with Bob's script on a couple pages of my schematic, so I must have enough parts to fill up whatever buffer exit() uses...

     

    Next, I just have to figure out how to get exit() to call my script properly.  The fun continues!

     

    Regards,

    Doug

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dukepro
    0 dukepro over 12 years ago in reply to AnalogNotes

    On 11/28/2012 06:01 PM, Doug Wellington wrote:

     

    ...

    I wish each sheet had it's own text name instead of just a number.  (Maybe that's included in version 6?)  Guess that's not too big of a complaint though...

     

    Sheet names would be nice.  In the mean time, have you tried:

     

        schematic(SCH) {

           SCH.sheets(S) {

              if (S.number == sheetOfInterest) {

                 S.instances() {

                    ...

                 }

              }

           }

        }

     

    or:

     

        schematic(SCH) {

           SCH.parts(P) {

              P.instances(I) {

                 if (I.sheet == sheetOfInterest) {

                    ...

                 }

              }

           }

        }

     

    I think that either of these can filter by sheet.

     

    Take a look at the 6.2 ULP docs for UL_PART.  It talks about the

    instances() loop member in the notes.

     

        /If the part is in a sheet context, the instances() loop member

        loops only through those/

        /instances that are actually used on that sheet. If the part is in a

        schematic context, all instances are/

        /looped through./

     

    Also, look at the example under UL_INSTANCE

     

        Example

        schematic(S) {

          S.parts(P) {

            printf("Part: %s\n", P.name);

            P.instances(I) {

            if (I.sheet != 0)

              printf("\t%s used on sheet %d\n", I.name, I.sheet);

            }

          }

        }

     

    HTH,

        - Chuck

     

     

    Attachments:
    0116.att1.html.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • AnalogNotes
    0 AnalogNotes over 12 years ago

    Thanks Chuck, I was thinking that it would be nice to have names for each sheet in the GUI instead of just sheet numbers.  Version 6 does indeed have that.  In my ULP, it's pretty simple to have an array of names indexed by sheet...

     

    Now, I just ran into something incredibly silly!!!

     

    export partlist

     

    is the command that I needed the whole time!

     

    Regards,

    Doug

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
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 © 2025 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