GithubHelp home page GithubHelp logo

erichvk5 / bxl2text Goto Github PK

View Code? Open in Web Editor NEW
21.0 6.0 9.0 121 KB

A utility to convert huffman encoded BXL schematic and footprint files to plain text, gEDA PCB (.fp) and gschem (.sym), and KiCad (.lib) formats

License: GNU General Public License v2.0

Java 96.16% C++ 3.84%

bxl2text's Introduction

BXL2text

Update, July 2020

The open source pcb layout tool pcb-rnd ( repo.hu/projects/pcb-rnd ) now has native support for loading and saving BXL format libraries, mostly eliminating the need for BXL2text for pcb layout purposes. pcb-rnd can also save in Kicad, gEDA PCB, protel autotrax formats, subject to the limitations of these respective formats.


A utility to convert huffman encoded BXL schematic and footprint files to plain text, and undertake further conversion to FOSS EDA compatible formats, which for now is gEDA and Kicad -> preliminary Kicad support has been implemented, with automatic export of eeschmea (.lib) symbols along with gschem (.sym) symbols. Kicad natively supports gEDA PCB .fp footprints, so pcbnew footprint export has not been implemented.

BXL files are a vendor neutral and EDA package neutral file format used by device vendors to distribute schematic symbols and footprints for use in EDA tools such as, but not limited to, gEDA, for PCB and circuit design.

The Huffman decoding portion of this utility is based on vala code originally developed by Geert Jordaens, and uses adaptive Huffman decoding.

Conversion of BXL encoded SMD and through hole footprints into a single file of gEDA PCB footprints has now been achieved, utilising the BXL encoded padstack definitions.

Top layer silkscreen lines and arcs are converted as well.

The issue of BXL files using an inverted y-axis relative to gEDA / kicad has been addressed.

Individual gEDA PCB compatible footprints and gEDA gschem compatible symbols are now extracted, and saved individually with .fp and .sym file endings, respectively. Attribute fields defined in the BXL file are also appended to the symbol.

Compatible footprints are listed in the decoded symbol's "footprint=..." attribute field, and additional compatible footprints are listed in "alt-footprint=..." attribute fields.

The utility can export either Huffman decoded data as plain text, or perform further conversion.

The Huffman decoding portion of the utility has been ported to some quick and dirty C++ and can be found in SourceBuffer.cc for anyone with a need to decode adaptively encoded Huffman files using C++.

This code is now included in the translate2geda utility, which can also convert many other formats to gEDA compatible design elements, such as symdef, LT-Spice (.asc), QUCS (.sch), Eagle XML symbols and footprints, BSDL (.bsd), IBIS (.ibs), and Gerber formats.

To do:

  • add the kicad symbol format export to the translate2geda utility
  • option to translate gschem symbol from 0,0 to bottom left of gschem display area
  • ongoing development work for the component classes is being done mostly in the translate2geda utility, but the improved classes will be put here from time to time

Issues:

  • polygonal copper layer pads are identified and replaced with a small circular copper pad on the top layer at the location of the polygonal pad. Polygonal pads seem to be quite rare, having only been encountered occasionally in Eagle and BXL footprint description.

Licence: GPL2

For example vendor BXL files, see:

Usage:

1) install a git client, a java compiler and java virtual machine for your operating system

2) git clone https://github.com/erichVK5/BXL2text.git

3) cd BXL2text

4) javac *.java

5) java BXLDecoder YOURBXLFILEHERE.bxl -t > YOURBXLFILE.txt

Options:

-t	only output converted text without further conversion

-o      output/directory/path/including/slashes/

Example usage:

java BXLDecoder BXLFILE.bxl -t > BXLFILE.txt

java BXLDecoder BXLFILE.bxl 

bxl2text's People

Contributors

efrane avatar erichvk5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bxl2text's Issues

Float coords and text pin names

This fixes reading TI uC schematics.

The schematics are not properly converted with this patch as one symbol there includes multiple drawings.
But after this patch, at least the last drawing is properly exported.

From 90832d30f30bc4cbc928de03da6d2908f27454eb Mon Sep 17 00:00:00 2001
From: mefistotelis 
Date: Thu, 3 Aug 2017 02:23:33 +0200
Subject: [PATCH] BXL: Loading files with float coords.

The patch enables reading BXL files which include float
coordinates. It also fixes conversion of pin numbers
in case pins have text name prefix or postfix.
---
 PinList.java        |  2 +-
 SymbolPolyline.java | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/PinList.java b/PinList.java
index 12f41b5..ee2c474 100644
--- a/PinList.java
+++ b/PinList.java
@@ -379,7 +379,7 @@ public class PinList {
     //System.out.println("PinDesc:" + pinDesc); 
     pinDesc = pinDesc.replaceAll("\"", "");
     pinDesc = pinDesc.replaceAll(" ", "");
-    int BXLPinNum = Integer.parseInt(pinDesc);
+    int BXLPinNum = Integer.parseInt(pinDesc.replaceAll("\\D+",""));
     //System.out.println("Pin num:" + BXLPinNum);
     indexOne = BXLCompPinDef.indexOf("(PinType");
     indexTwo = BXLCompPinDef.indexOf(")", indexOne);
diff --git a/SymbolPolyline.java b/SymbolPolyline.java
index 3928f11..e3b7d4f 100644
--- a/SymbolPolyline.java
+++ b/SymbolPolyline.java
@@ -67,15 +67,15 @@ public class SymbolPolyline extends SymbolElement
     String [] tokens = BXLLine.split(" ");
     for (int index = 0; index < tokens.length; index++) {
       if (tokens[index].equals("Origin")) {
-        xCoords[0] = Integer.parseInt(tokens[++index]);
-        yCoords[0] = Integer.parseInt(tokens[++index]);
+        xCoords[0] = Math.round(Float.parseFloat(tokens[++index]));
+        yCoords[0] = Math.round(Float.parseFloat(tokens[++index]));
         updateCoords(0);
       } else if (tokens[index].equals("EndPoint")) {
-        xCoords[1] = Integer.parseInt(tokens[++index]);
-        yCoords[1] = Integer.parseInt(tokens[++index]);
+        xCoords[1] = Math.round(Float.parseFloat(tokens[++index]));
+        yCoords[1] = Math.round(Float.parseFloat(tokens[++index]));
         updateCoords(1);
       } else if (tokens[index].equals("Width")) {
-        lineThickness = Integer.parseInt(tokens[++index]);
+        lineThickness = Math.round(Float.parseFloat(tokens[++index]));
       }
     }
     vertices = 2;
-- 
2.7.4

Compilation Issue 0

I get many of these errors while compiling:

SymbolText.java:36: error: unmappable character for encoding ASCII
//??? type = always 0.

Problem is that in the header of some files "a bulleted list" is used and they are not translated correctly, at least not on my terminals. After removing them, these issues are solved.

Example:

//• orientation = horizontal orientation (=0) or vertical (=1).
//• type = always 0.
//• unit = 0 if common to the parts. If not, the number of the part (1. .n).
//• convert = 0 if common to the representations, if not 1 or 2.

It is present in the following files:

SymbolPin.java
SymbolPolyline.java
SymbolRectangle.java
SymbolText.java

Also there is an empty else if that java on OSX does not seem to like:

Footprint.java:253: error: illegal start of expression
        else if () {
                 ^

After removing it, compilation proceeds correctly.

simple improve for effeciency and dramatic speed increase

It takes three lines of code to improve the performance dramatically. In SourceBuffer.java, change the declaration "String sb = new String()" in the decode() routine to the declaration:

    StringBuffer sb = new StringBuffer(out_file_length);

Then use the method call "sb.append( (char)node.symbol)" method of StringBuffer insteand of "sb = sb + ((char)node;".symbol & 0xff))".

Lastly, the return line of decode should be changed from "return sb;" to "return sb.toString();".

Most of the time in this routine is spent allocating, copying and freeing new String() objects. Performance probably degrades exponentially with the size of the BXL file. This method removes that bottleneck by using a single pre-allocated string buffer.

DSBGA not properly recognized

I am trying to read a bxl file from TI for the DSBGA package, but the footprint is recognized properly. The silkscreen and soldier mask are all messed up. See comparisson with UltraLibrarian Reader

image

BXL to kicad for BGA exporting wrong pin pad numbers

I tried converting AM3352_ZCE_298.bxl to kicad lib but the pin numbering is not retained. Pin pad numbers became numbers. These should be letters followed by numbers.

X AIN0 1 0 0 300 R 50 50 1 1 P
X AIN1 2 0 -100 300 R 50 50 1 1 P
X AIN2 3 0 -200 300 R 50 50 1 1 P
X AIN3 4 0 -300 300 R 50 50 1 1 P
X AIN4 5 0 -400 300 R 50 50 1 1 P
X AIN5 6 0 -500 300 R 50 50 1 1 P
X AIN6 7 0 -600 300 R 50 50 1 1 P

Instead these should be like

X AIN0 B8 0 0 300 R 100 100 2 0 U 
X AIN1 A11 0 -100 300 R 100 100 2 0 U 
X AIN2 A8 0 -200 300 R 100 100 2 0 U 
X AIN3 B11 0 -300 300 R 100 100 2 0 U 
X AIN4 C8 0 -400 300 R 100 100 2 0 U 
X AIN5 B12 0 -500 300 R 100 100 2 0 U 
X AIN6 A10 0 -600 300 R 100 100 2 0 U 
X AIN7 A12 0 -700 300 R 100 100 2 0 U 

I am attaching the bxl file and the converted lib file.

AM3352ZCE.zip

Compilation issue (cannot find symbol)

Seem to have an issue compiling on OSX

macbook:BXL2text max$ javac *.java

Footprint.java:43: error: cannot find symbol
  FootprintHeader[] moduleTextDescriptors = new FootprintHeader[200];
  ^
  symbol:   class FootprintHeader
  location: class Footprint
Footprint.java:43: error: cannot find symbol
  FootprintHeader[] moduleTextDescriptors = new FootprintHeader[200];
                                                ^
  symbol:   class FootprintHeader
  location: class Footprint
Footprint.java:151: error: cannot find symbol
                    moduleTextDescriptors[textDescriptorCount] = new FootprintHeader();
                                                                     ^
  symbol:   class FootprintHeader
  location: class Footprint
Footprint.java:158: error: cannot find symbol
                    footprintElements[FPFeatureCount] = new FootprintText();
                                                            ^
  symbol:   class FootprintText
  location: class Footprint
Footprint.java:164: error: cannot find symbol
                    moduleTextDescriptors[textDescriptorCount] = new FootprintHeader();
                                                                     ^
  symbol:   class FootprintHeader
  location: class Footprint
Footprint.java:186: error: cannot find symbol
                    footprintElements[FPFeatureCount] = new Circle();
                                                            ^
  symbol:   class Circle
  location: class Footprint
Footprint.java:194: error: cannot find symbol
                    footprintElements[FPFeatureCount] = new Circle();
                                                            ^
  symbol:   class Circle
  location: class Footprint
PinList.java:372: error: cannot find symbol
          slotArrays[index][index2].setPinType(pinType);
                                   ^
  symbol:   method setPinType(String)
  location: class SymbolPin
8 errors

Errors out on this bxl file from Analog Devices

I've used this converter successfully with several bxl files from different vendors.
But on occasion I get one that errors out.
Maybe it is an error in the bxl file, but the -t text dump seems to work, while without that flag the translation to .sym,.lib, & .fp errors out with a message like this :

About to use filneame: ADP7118AUJZ.bxl
Created new buffer: ADP7118AUJZ.bxl
Exception in thread "main" java.lang.NumberFormatException: For input string: "234.3147"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at Arc.populateBXLElement(Arc.java:94)
	at BXLDecoder.main(BXLDecoder.java:116)

I've attached the bxl file downloaded from Analog Devices

ADP7118AUJZ.bxl.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.