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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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) EAGLE 7.7: ULP: How to access attributes of parts with multiple gates correctly?
  • 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
  • Replies 10 replies
  • Subscribers 178 subscribers
  • Views 1555 views
  • Users 0 members are here
Related

EAGLE 7.7: ULP: How to access attributes of parts with multiple gates correctly?

autodeskguest
autodeskguest over 6 years ago

I wrote an ULP that "retrofits" user attributes for BOM management like

ORDERCODE, COMMENT, SUPPLIER etc.

 

It iterates through all schematic sheets, all instances on the sheet and

checks if the instance has a package (to exclude mainly power supply

symbols from getting attributes as well)

 

It tries to read the attribute (to check if the attribute is already

there, and to not overwrite it in case it's already defined and set to a

value).

 

If the attribute is not found, the ULP is adding a line to an output

script that can be run later to "retrofit" all the needed attributes.

 

In general it works quite well, the problem starts when there is any

part that consists of multiple gates, like TTL logic with seperate power

gates.

 

From the debug output in the generated script I see that attributes are

only found on the "first" gate of the multi gate part.

 

The second+ gate returns no valid attribute even though if i check

manually with a right click in the schematic all attributes are there,

even on all "sub-gates" of a part.

 

My script then assumes there must be the attribute missing and

overwrites the attribute with an empty one, which also deletes the

attributes' values of the first gate of a part.

 

As result I lose any attribute values that existed before running my

script in any multigate part.

 

There is no iterator for gates of an instance so i have no idea how to

memorize or recognize that I'm accessing not the first gate of a part

but the second one so i could skip those entirely (obviously the data is

attached internally to the the first gate of an instance, so i could

skip any other gates)

 

I'm kinda stuck here. Maybe someone from the good old eagle times or

former CadSoft employees can have a look at this and make suggestions?

 

I attach the script as reference (the V6 stems from it was written

originally for V6 but it has the same problem there)

 

Cheers,

 

Markus

 

  • Sign in to reply
  • Cancel
  • autodeskguest
    autodeskguest over 6 years ago

    On 06/05/2019 16:02, Markus Rudolf wrote:

     

    In general it works quite well, the problem starts when there is any

    part that consists of multiple gates, like TTL logic with seperate power

    gates.

     

    From the debug output in the generated script I see that attributes are

    only found on the "first" gate of the multi gate part.

     

    The second+ gate returns no valid attribute even though if i check

    manually with a right click in the schematic all attributes are there,

    even on all "sub-gates" of a part.

     

    My script then assumes there must be the attribute missing and

    overwrites the attribute with an empty one, which also deletes the

    attributes' values of the first gate of a part.

     

    I haven't tried this but...

     

    I see you're checking the attributes() member of the instance. Have you

    tried using the equivalent member of the part, instead? So instead of:

     

                             

                             I.attributes(attr)

                             {

     

    use:

     

                             

                             I.part.attributes(attr)

                             {

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    Rob Pearce wrote:

    On 06/05/2019 16:02, Markus Rudolf wrote:

     

    In general it works quite well, the problem starts when there is any

    part that consists of multiple gates, like TTL logic with seperate power

    gates.

     

    From the debug output in the generated script I see that attributes are

    only found on the "first" gate of the multi gate part.

     

    that would be the gate used to asssign the attributes in the first

    place.

    Using the part name without gate index (IC1 vs. IC1A for instance)

    with the attribute command defaults to the 'first' gate of a multi

    gated part.

     

    The second+ gate returns no valid attribute even though if i check

    manually with a right click in the schematic all attributes are there,

    even on all "sub-gates" of a part.

     

    the properties dialog shows all attributes of a part, regardless which

    gate you used to invoke it.

     

    My script then assumes there must be the attribute missing and

    overwrites the attribute with an empty one, which also deletes the

    attributes' values of the first gate of a part.

     

    I haven't tried this but...

     

    I see you're checking the attributes() member of the instance. Have you

    tried using the equivalent member of the part, instead? So instead of:

     

    >                         

    >                         I.attributes(attr)

    >                         {

     

    use:

     

    >                         

    >                         I.part.attributes(attr)

    >                         {

     

    if you only need attributes on a part and not on a gate level

     

    |   schematic(SCH) SCH.parts(PAR) PAR.attributes(ATT) {...}

     

    is the way to go. Using

     

    |   schematic(SCH) SCH.sheets(SHE) SHE.instances(INS) INS.attributes(ATT) {...}

     

    is only required if you need to know which of the attributes of a part

    are assigned to special gate(s).

    This variant also lists attributes that are visible for the gate (an

    attribute can be display at more then one gate).

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    On 07.05.2019 08:15, Lorenz wrote:

     

    if you only need attributes on a part and not on a gate level

     

    |   schematic(SCH) SCH.parts(PAR) PAR.attributes(ATT) {...}

     

    is the way to go. Using

     

    |   schematic(SCH) SCH.sheets(SHE) SHE.instances(INS) INS.attributes(ATT) {...}

     

    is only required if you need to know which of the attributes of a part

    are assigned to special gate(s).

    This variant also lists attributes that are visible for the gate (an

    attribute can be display at more then one gate).

     

     

    I think the problem was (the script I wrote some years ago, but still it

    shot me in the foot yesterday again so I try to fix it once and for all)

    that the generated script needs to know also the X and Y position of the

    part to apply the attributes (it even checks which measurement system is

    in use (mm/mil/inch) and adopts the commands accordingly.

     

    Maybe this whole approach was stupid back then but I think it was the

    only way getting it running at all.

     

    I'll try your suggestion and see if it improves things or breaks it

    completely image

     

    Markus

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    Markus Rudolf wrote:

    On 07.05.2019 08:15, Lorenz wrote:

     

    if you only need attributes on a part and not on a gate level

     

    |   schematic(SCH) SCH.parts(PAR) PAR.attributes(ATT) {...}

     

    is the way to go. Using

     

    |   schematic(SCH) SCH.sheets(SHE) SHE.instances(INS) INS.attributes(ATT) {...}

     

    is only required if you need to know which of the attributes of a part

    are assigned to special gate(s).

    This variant also lists attributes that are visible for the gate (an

    attribute can be display at more then one gate).

     

     

    I think the problem was (the script I wrote some years ago, but still it

    shot me in the foot yesterday again so I try to fix it once and for all)

    that the generated script needs to know also the X and Y position of the

    part to apply the attributes (it even checks which measurement system is

    in use (mm/mil/inch) and adopts the commands accordingly.

     

    Maybe this whole approach was stupid back then but I think it was the

    only way getting it running at all.

     

    I'll try your suggestion and see if it improves things or breaks it

    completely image

     

    you don't need coordinates for the most task.

     

         attribute PARTNAME ATTRIBUTENAME 'ATTRIBUTEVALUE';

     

    does the trick nicely. If you don't want to display the attributes in

    the schematic too, you need

     

         change display off;

     

    before adding new attributes. Otherwise the show up in the schematic.

     

     

    You can even pick up visible attributes using

     

         move PARTNAME>ATTRIBUTENAME (...);

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    On 07.05.2019 08:15, Lorenz wrote:

     

    if you only need attributes on a part and not on a gate level

     

    |   schematic(SCH) SCH.parts(PAR) PAR.attributes(ATT) {...}

     

    is the way to go.

     

    I tried that. It in principle works, the problem is, the generated

    script fails on setting the attributes when the part is not on the

    visible sheet.

     

    Is there any way to address a part from a script by it's name when it's

    on a different sheet?

     

    I could in theory switch to the sheet for each part, but how do I find

    out which sheet a part is on just in the SCH context?

     

    Markus

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    On 07.05.2019 11:29, Lorenz wrote:

     

    > you don't need coordinates for the most task.

    >

    > attribute PARTNAME ATTRIBUTENAME 'ATTRIBUTEVALUE';

    >

    > does the trick nicely. If you don't want to display the attributes in

    > the schematic too, you need

    >

    > change display off;

     

    Yeah there was some old dead code in that tricked me. My script actually

    does that. Problem is accessing parts not on the current sheet. I just

    did a quick test on an old project without attributes at all (from V5)

    consisting of 4 sheets and C1-C18 on .S1 and C19++ on .S2

     

    Now I get an error when trying to set attributes for C19 as it is not on

    the sheet (somehow its stupid one cannot reference a part by its unique

    name in a command by just calling it by its name...)

     

    Markus

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    On 07.05.2019 11:29, Lorenz wrote:

     

    > you don't need coordinates for the most task.

    >

    > attribute PARTNAME ATTRIBUTENAME 'ATTRIBUTEVALUE';

    >

    > does the trick nicely. If you don't want to display the attributes in

    > the schematic too, you need

    >

    > change display off;

     

    Yeah there was some old dead code in that tricked me. My script actually

    does that. Problem is accessing parts not on the current sheet. I just

    did a quick test on an old project without attributes at all (from V5)

    consisting of 4 sheets and C1-C18 on .S1 and C19++ on .S2

     

    Now I get an error when trying to set attributes for C19 as it is not on

    the sheet (somehow its stupid one cannot reference a part by its unique

    name in a command by just calling it by its name...)

     

    Markus

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    The problem boils down to this, I guess thats why I ended up using the

    instance loop in the first place:

     

    https://www.element14.com/community/thread/32565/l/attribute-command-for-parts-in-another-sheet?displayFullThread=true

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    Markus Rudolf wrote:

     

    On 07.05.2019 08:15, Lorenz wrote:

     

    if you only need attributes on a part and not on a gate level

     

    |   schematic(SCH) SCH.parts(PAR) PAR.attributes(ATT) {...}

     

    is the way to go.

     

    I tried that. It in principle works, the problem is, the generated

    script fails on setting the attributes when the part is not on the

    visible sheet.

     

    Is there any way to address a part from a script by it's name when it's

    on a different sheet?

     

    I could in theory switch to the sheet for each part, but how do I find

    out which sheet a part is on just in the SCH context?

     

       schematic(SCH) SCH.parts(PAR) PAR.instances(INS) INS.sheet

    --

     

    Lorenz

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • autodeskguest
    autodeskguest over 6 years ago in reply to autodeskguest

    On 08.05.2019 07:40, Lorenz wrote:

     

     

        schematic(SCH) SCH.parts(PAR) PAR.instances(INS) INS.sheet

     

     

    Yeah got it, it works now. Thx a lot!

     

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