7 Replies Latest reply on Sep 18, 2017 6:56 PM by MaxKielland

    How to change text alignment with script (console command)? [SOLVED]

    MaxKielland

      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?

        • Re: How to change text alignment with script (console command)?
          CadSoft Guest

          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)?
              MaxKielland

              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 PCB 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.

              When trying to use these coordinates I get "Invalid Point: (...)"

               

              [EDIT]

              I realized that the coordinates are real numbers so I changed the sprintf formatting to:

              sprintf(s,"CHANGE ALIGN CENTER (%f %f) \\\\ %s\n", T.x, T.y, E.name);
              But that generated a formatting error when I run it.

               

               

              I then tried a typecast

              sprintf(s,"CHANGE ALIGN CENTER (%f %f) \\\\ %s\n", real(T.x), real(T.y), E.name);
              But that generated the same numbers as before, but with a lot of 0 decimals.


              I calculated the factor to 8128 and when I divided the coordinates with this they became correct.
              I must be doing something wrong here... How is it supposed to be handled?