EAGLE Central Forums
Where the EAGLE community meets. Sponsored by Stratford Digital.

Home » CadSoft Support Forums » eagle.support.eng » How to change text alignment with script (console command)?
How to change text alignment with script (console command)? [message #171491] Mon, 28 August 2017 15:31 Go to next message
Max Kielland
Messages: 13
Registered: October 2010
Junior Member
I'm writing a script (ULP) to smash all Resistors, Capacitors and Inductors and then set the text alignment to "Center" and move it to the origo of the package.
Now I'm stuck on how to change the text alignment, I can't find any command to do that.

Bonus question: How do I un-smash a smashed component in ULP?

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/227848
Re: How to change text alignment with script (console command)? [message #171492 is a reply to message #171491] Mon, 28 August 2017 16:04 Go to previous messageGo to next message
Lorenz
Messages: 650
Registered: December 2006
Senior Member
Max Kielland wrote:
> I'm writing a script (ULP) to smash all Resistors, Capacitors and
> Inductors and then set the text alignment to "Center" and move it to
> the origo of the package.
> Now I'm stuck on how to change the text alignment, I can't find any
> command to do that.

in the ulp use "setgroup" to group all relevant texts (name, value,
attributes?) then exit the ULP with

change align centre (>0 0);

(not tested though, does setgroup work with attributes at all?)


or

change align center (x y) ...

where "x y" are the origin coordinates of a text


> Bonus question: How do I un-smash a smashed component in ULP?

group the relevant parts then run "smash (>S0 0)"

or

smash (S x y)

where "x y" are the origin coordinates ot the part to unsmash
--

Lorenz
Re: How to change text alignment with script (console command)? [message #171495 is a reply to message #171492] Mon, 28 August 2017 17:07 Go to previous messageGo to next message
Max Kielland
Messages: 13
Registered: October 2010
Junior Member
Thank you, now it seems like the coordinates are all strange.

For example:
(snippet from ULP script)

        E.texts(T) {
          sprintf(s,"CHANGE ALIGN CENTER (%d %d) \\\\ %s\n", T.x, T.y, E.name);
        }

Grid units are in mil
My resistor R4 (smashed text) at X: 537.5 Y:650 (when looking at it's info in the PCN editor)

But my ULP script outputs:
CHANGE ALIGN CENTER (4368800 6096000) \\ R4
CHANGE ALIGN CENTER (3413760 5364480) \\ R4

These X,Y values are completely wrong and according to the documentation they should be in the same units as the current grid, in this case mil.

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/227854
Re: How to change text alignment with script (console command)? [message #171496 is a reply to message #171495] Mon, 28 August 2017 17:32 Go to previous messageGo to next message
rachaelp
Messages: 604
Registered: March 2015
Location: UK
Senior Member
Hi Max,

You'll need to use the u2mil() function to convert the integer values you are seeing into the mils you are using.

Best Regards,

Rachael

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/227879
Re: How to change text alignment with script (console command)? [message #171498 is a reply to message #171496] Mon, 28 August 2017 18:57 Go to previous messageGo to next message
Max Kielland
Messages: 13
Registered: October 2010
Junior Member
Thank you but what if the grid changes from mil to mm?
When I changed the grid units I got the same numbers (the old mil). Isn't there a way to get the coordinates right independent of the grid unit settings?

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/227855
Re: How to change text alignment with script (console command)? [message #171502 is a reply to message #171498] Mon, 28 August 2017 21:05 Go to previous messageGo to next message
rachaelp
Messages: 604
Registered: March 2015
Location: UK
Senior Member
> Max Kielland wrote:
>
> Thank you but what if the grid changes from mil to mm?
> When I changed the grid units I got the same numbers (the old mil). Isn't there a way to get the coordinates right independent of the grid unit settings?
{code:modifiedtitle=true|class=jive_macro_code _jivemacro_uid_15039543122177246 jive_text_macro|data-renderedposition=132_8_1382_16|jivemacro_uid=_15039543 122177246}GRID mil; <do stuff...>; GRID last;{code}

Best Regards,

Rachael

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/227886
Re: How to change text alignment with script (console command)? [message #171504 is a reply to message #171498] Tue, 29 August 2017 06:14 Go to previous messageGo to next message
Lorenz
Messages: 650
Registered: December 2006
Senior Member
Max Kielland wrote:

> Thank you but what if the grid changes from mil to mm?
> When I changed the grid units I got the same numbers (the old mil).
> Isn't there a way to get the coordinates right independent of the grid
> unit settings?

use (using microns here, but ich, mil & mm are also possible)

sprintf(s,"ch al ce (%fmic %fmic) %s;",
u2mic(T.x), u2mic(T.y), E.name);

just put the unit explicitly in the command string.


have a look at Help/Editor Commands/Command Syntax for the
coordinate syntax
--

Lorenz
Re: How to change text alignment with script (console command)? [message #171678 is a reply to message #171504] Mon, 18 September 2017 23:55 Go to previous message
Max Kielland
Messages: 13
Registered: October 2010
Junior Member
This did the trick, thank you! In this way we are not pending on the grid setting.

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/228872
Previous Topic: Re: EAGLE PREMIUM SUBSCRIPTION
Next Topic: BMP import to large but within standard size?
Goto Forum:
  


Current Time: Mon Sep 25 11:37:05 GMT 2017