Mail Archives: geda-user/2012/07/12/12:50:34
On Thu, Jul 12, 2012 at 6:46 AM, Ed Simmons <ed AT estechnical DOT co DOT uk> wrote:
> On 12/07/12 05:18, Andrew Poelstra wrote:
>>
>> On Thu, Jul 12, 2012 at 12:13:52AM +0100, Ed Simmons wrote:
>>>
>>> Sorry for the noise, I've figured it out. Dividing from the base
>>> unit and printing an integer works fine for my purposes.
>>>
>>>     pcb_fprintf(fp, "3  : 230: 1: 3: 0:F 1X %iY %iA %iR %s %s %s\n",
>>>             x/10000 , y/10000 , theta * 10, name, value, FRONT
>>> (element) == 1 ? "top" : "bot");
>>>
>> Please don't use base units -- %i won't work on 64-bit systems, and
>> isn't guaranteed to work on any systems in the future. Instead use
>> the %mn specifier to output coordinates as nanometers. (Then you can
>> use /10000 as you have.)
>>
>
>
> Thanks, that's looking much better now. I did think it was a bit ugly to use
> the base unit, considering there's obviously been plenty of work to avoid
> using the base units directly.
>
> I'm now finding another issue... I've made a fiducial symbol and footprint,
> and I'm successfully identifying fiducial 1 in the exporter, then trying to
> get it's location to use as the bias offset for all the location data that
> is subsequently output.
>
> Using the same element loop and pin/pad loops to find the location of the
> fiducial seems to not work properly for me yet. I always get X axis location
> as 0, but Y looks as though it is working.
>
> This is what I have:
>
>   ELEMENT_LOOP (PCB->Data);
>   {
>
>       if (NSTRCMP ( NAMEONPCB_NAME (element), "FID1") == 0)
>       { // hooray! fiducial 1 has been found
>          pcb_fprintf (fp, "# Found fiducial 1\n");
>          int count = 0;
>
>           PAD_LOOP (element);
>           {
>             sumx += (pad->Point1.X + pad->Point2.X) / 2.0;
>             sumy += (pad->Point1.Y + pad->Point2.Y) / 2.0;
>             pcb_fprintf (fp, "# Sum X = %.2mm Sum y = %.2mm\n", sumx,sumy);
> //seems here that X is never getting a value other than 0
>             count++;
What type are sumx and sumy? I see you are dividing by 2.0 instead of
2, are they float?
>           }
>           END_LOOP;
>           pcb_fprintf (fp, "# Found %i pads\n", count);
>           if(count > 0 && count <= 2){ // the fiducial can have pads top and
> bottom!!
>             offsetX = sumx;
>             offsetY = sumy;
>           }
>
>       }
>
>   }
>   END_LOOP;
>
> Any bright ideas would be greatly appreciated.
>
> Thanks again.
> Ed
- Raw text -