ULP access to dynamic string value

ULP access to dynamic string value

Anonymous
Not applicable
1,914 Views
8 Replies
Message 1 of 9

ULP access to dynamic string value

Anonymous
Not applicable

I use a global attribute "VERSION" which is set for example to "1.0" (in the board file), and dynamically insert it as text in a specific layer in the board file using ">VERSION". This is working as expected.

 

Now i want to write a check routine to test if the user has set the dynamical text in the board file. But while trying to access all texts in the board file by

project.board(B){

  B.texts(T){

   // access to T.value

  }

}

i only get the replaced/evaluated string (now "1.0") and not the string ">VERSION" for T.value.

I also tried accessing the text from a board context (replaced "project.board" by "board") and started the ulp from the board editor window with no success.

 

How can I access the ">VERSION" entry of the text in the board file?

Reply
Reply
0 Likes
Accepted solutions (1)
1,915 Views
8 Replies
Replies (8)
Message 2 of 9

mtl_asm
Collaborator
Collaborator

you need to use the attributes() loop member of board, not texts. 

 

the name of the attribute will be VERSION, its value will be 1.0.

 

mtlasm_0-1638981291640.png

 

 

mtlasm_1-1638981345436.png

 

Reply
Reply
0 Likes
Message 3 of 9

Anonymous
Not applicable

Thank you for your answer. Maybe my question was a bit unclear. 

With "attributes(A)" i will get the global attribute list from the board file.

 

For our quality management i want to check wether there is the text ">VERSION" set in the board file. When i loop through all texts(T) the return value of the text element depends wether the global attribute "VERSION" is set or not. 

Is there a way to check if the text value comes from a dynamic replacement or from the set value itself.

 

To make my concern clearer I made a screenshot:

In the "Eigenschaften" window i get ">VERSION" as Text value. Reading the text value within the texts() loop i get "1.0" as Text value as shown also in the Board editor.  But how can i get the string ">VERSION" back from the text element within the ulp if the global attribute is set.

 

 

Reply
Reply
0 Likes
Message 4 of 9

eng_dpt_2
Contributor
Contributor

Here an example how to read the global attributes

This program will check if a global attribute named "Version" exists and if exists it will show his value in a MSG box

string cmd;
string A_value;
int found = 0;
if(schematic)
{
  schematic(S)
  {
    S.attributes(A)
    {
      if(A.name == "VERSION")
      {
        dlgMessageBox(A.value);
        found = 1;
        exit(0);
      }
    }
  }
  if(found == 0)
  {
    dlgMessageBox("No attribute VERSION found");
  }
}
else
{
  dlgMessageBox("Run this ULP in a Schematic");
}
exit(0);


 Have a nice day!

jltharin

Reply
Reply
0 Likes
Message 5 of 9

one-of-the-robs
Advisor
Advisor

No, no, no, no. Read Martin's reply to mtl. Or even just re-read his original question more carefully. This is not what he wants to do! He's not asking about whether the attribute exists, nor what its value is, nor anything else about the attribute. He wants to know how to find whether a text object has a value that references the attribute.

I'm not sure whether that's possible from a ULP. I don't see anything in the help.

Reply
Reply
0 Likes
Message 6 of 9

mtl_asm
Collaborator
Collaborator

Yes I misunderstood his first post but there is no way to do what he is asking. 

 

To see if a text is getting its content from an attribute you do have to first look at the attribute, then the text data member, there isn't a method to go the other way to my knowledge. Global attribute objects do not have text data members though so in this case you cannot even do that.

 

I can think of some work arounds but none are exactly what you want.

 

For instance you could make the text value ">VERSION=", then if the global attribute VERSION has value 1.0 the text will contain "VERSION = 1.0", not just "1.0". Then you can assume that text is the one you want, however it obviously does not prevent someone just typing "VERSION =" into any other text which is not dynamically getting its content from the global attribute, and then getting an incorrect match.

 

What is the end goal? Maybe it will be easier to think of a solution knowing that.

 

 

Reply
Reply
0 Likes
Message 7 of 9

one-of-the-robs
Advisor
Advisor

@mtl_asm wrote:

What is the end goal? Maybe it will be easier to think of a solution knowing that.


He said he wants to write a "checker tool" for QA purposes. It would, as you say, help if the full requirements were given, instead of the gap in a proposed solution (isn't that so often the way!)

As it's the board that needs checking, and there's only a need for one instance, the check could probably be done by parsing the XML outside of Eagle, but that's a bit ugly.

Reply
Reply
0 Likes
Message 8 of 9

mtl_asm
Collaborator
Collaborator

thanks Rob, i can read what he wrote though.

Reply
Reply
0 Likes
Message 9 of 9

Anonymous
Not applicable
Accepted solution

Hi all

Thank you for all your suggestions. Parsing the XML outside would be a bit ugly as you already said. As mentioned this feature would be part of a bigger QA tool which we already wrote (including database matching with component part database, correct board marking, logo included, drc/erc successful, ...).  The goal is to have a tool which could indicate if all requirements (including that the version is set correctly in the layout) are fulfilled and show a big checkmark at the end.

My approach will be now that i would read out the global attribute "VERSION" and compare it against the texts in the board. Then i could find out whether the version is set correctly but i cannot find out if it is set dynamically or manually. This is an acceptable compromise for me now. Parsing the xml would be an option if we see that this approach is not sufficient. 

 

Have a nice day!

 

 

Reply
Reply
0 Likes