<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need Help with ULP/Eagle Script: Drawn Squares Have Incorrect Dimensions in Fusion Electronics Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-electronics-forum/need-help-with-ulp-eagle-script-drawn-squares-have-incorrect/m-p/13225747#M1032</link>
    <description>&lt;P&gt;Hi all! I found the solution!&lt;BR /&gt;QR codes are now created at the exact size requested.&lt;BR /&gt;Enjoy!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Blaise&lt;/P&gt;</description>
    <pubDate>Sun, 22 Dec 2024 20:26:52 GMT</pubDate>
    <dc:creator>blaisebarrette</dc:creator>
    <dc:date>2024-12-22T20:26:52Z</dc:date>
    <item>
      <title>Need Help with ULP/Eagle Script: Drawn Squares Have Incorrect Dimensions</title>
      <link>https://forums.autodesk.com/t5/fusion-electronics-forum/need-help-with-ulp-eagle-script-drawn-squares-have-incorrect/m-p/13224349#M1031</link>
      <description>&lt;P class=""&gt;&lt;STRONG&gt;Hi everyone!&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I’m currently developing a ULP that generates QR codes directly in Fusion Electronics. It’s working quite well overall, but I’ve noticed a consistent issue: the QR codes generated are always slightly smaller than the requested size. Additionally, the size of the QR code seems to vary depending on whether the URL passed to it is short or long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran, le 2024-12-21 à 14.01.23.png" style="width: 542px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1448358i3DEE5ACE5A14FD2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran, le 2024-12-21 à 14.01.23.png" alt="Capture d’écran, le 2024-12-21 à 14.01.23.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;Here’s the function responsible for drawing the squares:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;output(scriptFile, "wt") {
        int qrSize = nLines;
        
        // Adjust the requested size to be divisible by the number of modules
        int adjustedSize = Size;
        while (adjustedSize % qrSize != 0) {
            adjustedSize++;
        }
        int moduleSize = adjustedSize / qrSize;
        
        printf("# QR Code Generator Script\n");
        printf("# Generated by QR Code ULP v%s\n", VERSION);
        printf("# QR Code Size: %d x %d modules\n", qrSize, qrSize);
        printf("# Original Size: %d mils\n", Size);
        printf("# Adjusted Size: %d mils\n", adjustedSize);
        printf("# Module Size: %d mils\n", moduleSize);
        printf("# Position: (%d, %d)\n", PosX, PosY);
        printf("\n");
        
        printf("GRID MIL 0.1;\n");
        printf("CHANGE LAYER %d;\n", LayerNumbers[SelectedLayer]);
        printf("SET WIRE_BEND 2;\n");
        
        // Create rectangles for QR code
        int isBottomLayer = (LayerNumbers[SelectedLayer] == 22 || LayerNumbers[SelectedLayer] == 52);
        
        // Calculate the starting point to center the QR code
        int startX = PosX - (Size / 2);  // Starting point based on the requested size
        int startY = PosY - (Size / 2);
        
        for (int row = 0; row &amp;lt; nLines; row++) {
            string line = lines[row];
            for (int col = 0; col &amp;lt; strlen(line); col++) {
                if (line[col] == '1') {
                    // Calculate the positions relative to the starting point
                    int x1 = startX + (col * moduleSize);
                    int y1 = startY + (row * moduleSize);
                    int x2 = x1 + moduleSize;
                    int y2 = y1 + moduleSize;
    
                    // Mirror X coordinates if bottom layer
                    if (isBottomLayer) {
                        int temp_x1 = x1;
                        x1 = -x2;
                        x2 = -temp_x1;
                    }
                    
                    printf("RECT (%d %d) (%d %d);\n", x1, y1, x2, y2);
                }
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;You can find the complete ULP on my GitHub:&amp;nbsp;&lt;A href="https://github.com/blaisebarrette/QRCode-ULP-for-Fusion-electronics/tree/V1.0.2-developpment" target="_blank" rel="noopener"&gt;https://github.com/blaisebarrette/QRCode-ULP-for-Fusion-electronics/tree/V1.0.2-developpment&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;If you have experience with this type of issue or any suggestions to improve the implementation, your input would be greatly appreciated!&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;— Blaise&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2024 19:29:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-electronics-forum/need-help-with-ulp-eagle-script-drawn-squares-have-incorrect/m-p/13224349#M1031</guid>
      <dc:creator>blaisebarrette</dc:creator>
      <dc:date>2024-12-21T19:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with ULP/Eagle Script: Drawn Squares Have Incorrect Dimensions</title>
      <link>https://forums.autodesk.com/t5/fusion-electronics-forum/need-help-with-ulp-eagle-script-drawn-squares-have-incorrect/m-p/13225747#M1032</link>
      <description>&lt;P&gt;Hi all! I found the solution!&lt;BR /&gt;QR codes are now created at the exact size requested.&lt;BR /&gt;Enjoy!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Blaise&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2024 20:26:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-electronics-forum/need-help-with-ulp-eagle-script-drawn-squares-have-incorrect/m-p/13225747#M1032</guid>
      <dc:creator>blaisebarrette</dc:creator>
      <dc:date>2024-12-22T20:26:52Z</dc:date>
    </item>
  </channel>
</rss>

