Community
EAGLE Forum
Welcome to Autodesk’s EAGLE Forums. Share your knowledge, ask questions, and explore popular EAGLE topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to write ULP script to replace all >NAME and >VALUE with my defined font

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
ronovar
1428 Views, 3 Replies

How to write ULP script to replace all >NAME and >VALUE with my defined font

ronovar
Contributor
Contributor

I have finished one project and would like to add my custom font from PCB DOS because it looks more professional and it is more nice that EAGLE have build in.

 

So i need example script that takes in Board Editor names and values of components and replace it with my defined font or wires in my ulp script that i draw manually or to use external .ttf file that generates then font.

 

For example, i have two resistors in Board Editor, when i run font_change.ulp script i need to get R1 and R2 (name of components), and then search in ulp script that names and put from script that names to resistor position like it original was but with different font.

 

Can you please give me example ulp script that do that? I will then update font style with wires in that script manually after that is done correctly.

 

I try to get all name values of components and this is working:

 

board(B) {
    B.elements(E) dlgMessageBox(E.name, "Ok");
}

 

So i got two message box with values R1 and R2. Now i could not know how to add case with custom defined font in that ulp file and replace R1 and R2 on resistor name with my custom font?

 

So i need like this:

 

switch(E.name):

     case "R1":

           LINE 10, 20, 16, 23, 0.254

           LINE 12, 24, 12, 21, 0.254

           break;

     case "R2":

           LINE 11, 26, 17, 22, 0.254

           LINE 13, 25, 13, 29, 0.254

           break;

}

 

Then replace R1 on resistor name with above lines.

0 Likes

How to write ULP script to replace all >NAME and >VALUE with my defined font

I have finished one project and would like to add my custom font from PCB DOS because it looks more professional and it is more nice that EAGLE have build in.

 

So i need example script that takes in Board Editor names and values of components and replace it with my defined font or wires in my ulp script that i draw manually or to use external .ttf file that generates then font.

 

For example, i have two resistors in Board Editor, when i run font_change.ulp script i need to get R1 and R2 (name of components), and then search in ulp script that names and put from script that names to resistor position like it original was but with different font.

 

Can you please give me example ulp script that do that? I will then update font style with wires in that script manually after that is done correctly.

 

I try to get all name values of components and this is working:

 

board(B) {
    B.elements(E) dlgMessageBox(E.name, "Ok");
}

 

So i got two message box with values R1 and R2. Now i could not know how to add case with custom defined font in that ulp file and replace R1 and R2 on resistor name with my custom font?

 

So i need like this:

 

switch(E.name):

     case "R1":

           LINE 10, 20, 16, 23, 0.254

           LINE 12, 24, 12, 21, 0.254

           break;

     case "R2":

           LINE 11, 26, 17, 22, 0.254

           LINE 13, 25, 13, 29, 0.254

           break;

}

 

Then replace R1 on resistor name with above lines.

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: ronovar

Anonymous
Not applicable

I don't think custom fonts are even possible in eagle. I think your only options are Proportional, fixed, Vector new and Vector Old.

Have you tried the old and new vector fonts? I quite like the new ones and they look great on a board.

I don't think custom fonts are even possible in eagle. I think your only options are Proportional, fixed, Vector new and Vector Old.

Have you tried the old and new vector fonts? I quite like the new ones and they look great on a board.

Message 3 of 4
ronovar
in reply to: Anonymous

ronovar
Contributor
Contributor

I made a little progress, i write this little script that run in Board Editor (ULP) and create R with lines (i convert from DOS program to lines and create nice R looking font that i will use on layer 55 tfName).

 

string cmd = "";
board(B) {
B.elements(E) if (E.name == "R1") { cmd = "LINE 25 0.254 (-0.950 0.635) (-0.950 -0.635); LINE 25 0.254 (-0.950 0.635) (-0.320 0.635); LINE 25 0.254 (-0.320 0.635) (-0.090 0.425); LINE 25 0.254 (-0.090 0.425) (-0.090 0.226); LINE 25 0.254 (-0.090 0.226) (-0.320 -0.005); LINE 25 0.254 (-0.320 -0.005) (-0.950 -0.005); LINE 25 0.254 (-0.720 -0.005) (-0.090 -0.635);"; exit(cmd); dlgMessageBox("R1", "Ok"); };
}

 

But i don't know how to get variable into position x and y, so i know how to get R1 resistor position by calling E.x and E.y but i can't + or - with above code so that i can center it inside resistor like tName have.

 

So i want to have this:

 

B.elements(E) if (E.name == "R1") { cmd = "LINE 25 0.254 ((E.x + -0.950) (E.y + 0.635)) ((E.x + -0.950) (E.y + -0.635));"; exit(cmd); dlgMessageBox("R1", "Ok"); };

 

So how to + and - variable ofset E.x and E.y with values that i define above so that i can center my custom font R inside center R?

0 Likes

I made a little progress, i write this little script that run in Board Editor (ULP) and create R with lines (i convert from DOS program to lines and create nice R looking font that i will use on layer 55 tfName).

 

string cmd = "";
board(B) {
B.elements(E) if (E.name == "R1") { cmd = "LINE 25 0.254 (-0.950 0.635) (-0.950 -0.635); LINE 25 0.254 (-0.950 0.635) (-0.320 0.635); LINE 25 0.254 (-0.320 0.635) (-0.090 0.425); LINE 25 0.254 (-0.090 0.425) (-0.090 0.226); LINE 25 0.254 (-0.090 0.226) (-0.320 -0.005); LINE 25 0.254 (-0.320 -0.005) (-0.950 -0.005); LINE 25 0.254 (-0.720 -0.005) (-0.090 -0.635);"; exit(cmd); dlgMessageBox("R1", "Ok"); };
}

 

But i don't know how to get variable into position x and y, so i know how to get R1 resistor position by calling E.x and E.y but i can't + or - with above code so that i can center it inside resistor like tName have.

 

So i want to have this:

 

B.elements(E) if (E.name == "R1") { cmd = "LINE 25 0.254 ((E.x + -0.950) (E.y + 0.635)) ((E.x + -0.950) (E.y + -0.635));"; exit(cmd); dlgMessageBox("R1", "Ok"); };

 

So how to + and - variable ofset E.x and E.y with values that i define above so that i can center my custom font R inside center R?

Message 4 of 4
C.Nicks
in reply to: ronovar

C.Nicks
Advisor
Advisor
Accepted solution
I haven't heard of anyone creating a ulp to add custom fonts. If you get this working I would be very interested in trying it out.

If you look at many of the ULPs included with Eagle you will notice that the output command is built up into a string. That string is what the final ulp will exit and run. So in your code you can add, subtract, multiply, and whatever else you need to do to the coordinates before running the command. I would suggest looking at the help file for sprintf and looking through some stock ulps. Some have different coding styles depending on how old they are.

Best Regards,
Cameron


Eagle Library Resources


Kudos are much appreciated if the information I have shared is helpful to you and/or others.
Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

I haven't heard of anyone creating a ulp to add custom fonts. If you get this working I would be very interested in trying it out.

If you look at many of the ULPs included with Eagle you will notice that the output command is built up into a string. That string is what the final ulp will exit and run. So in your code you can add, subtract, multiply, and whatever else you need to do to the coordinates before running the command. I would suggest looking at the help file for sprintf and looking through some stock ulps. Some have different coding styles depending on how old they are.

Best Regards,
Cameron


Eagle Library Resources


Kudos are much appreciated if the information I have shared is helpful to you and/or others.
Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report