Git Product home page Git Product logo

exportjson's Introduction

JSON export for Allegro PCB designs

Skill script for Allegro PCB Designer to generate a JSON file representing the design.

The generated json file complies to the schema, that is needed to generate the InteractiveHtmlBom.

A demo is worth a thousand words.

Prerequisites

To make the skill script available for use, you need to copy the exportJson.il file to your local skill directory ( usually your installation path + \share\pcb\etc ) or the skill directory in the $CDS_SITE path. Append it to the allegro.ilinit file ( add load( "path/exportJson.il" ) ) or load it manually via the skill load command ( type set telskill into the command line and then type load("exportJson.il" ).

Usage

Once the script is loaded successfully, you can start exporting the json file by typing exportJson + enter in the command line. A directory named json is created in your project folder containing the .json.

The script uses the "project name" ( optional: + "_" + "variant" ) as the file name and asks for the optional arguments revision and company. By passing ?rev "xyz" and ?company "name" as arguments to the exportJson function, the input prompt is suppressed and these values are used for file generation. This is can be useful to customize the function to your needs.

Optional arguments

argument description type
?exportInnerLayers default: nil, exports the inner layers bool
?renderViaHoles default: nil, render via holes bool
?textAsSvgPaths default: t, uses font-data otherwise bool
?excludeDNP default: nil, all fabrication and silkscreen data of an unplaced component are ignored bool
?pcbLineWidth override value float
?fabricationLayerLinewidth override value float
?silkscreenLayerLinewidth override value float
?margin extra spacing for displaying list / float
?rev revision string
?company company name string

Linewidths

Without appending any additional arguments to the exportJson function, the linewidth of every segment is assigned to its original value. However, in some cases you may want to use a different and consistent linewidth as used in the pcb design. In this case three optional arguments can be passed to override the linewidth of pcb outline (?pcbLinewidth), the fabrication layer (?fabricationLayerLinewidth) and the silkscreen layer (silkscreenLayerLinewidth). For example:

    exportJson( ?pcbLinewidth 0.1 ?fabricationLayerLinewidth 0.2 ?silkscreenLayerLinewidth 0.2 )

uses a 0.1 unit linewidth for the pcb outline and a linewidth of 0.2 unit for the fabrication and the silkscreen layer.

Margin

Because the extents are defined by the pcb's minimum and maximum x/y values you may want to add some extra spacing. The function call below, adds a spacing of 20.0 unit to all four directions ( list( '( spacingLeft spacingBottom ) '( spacingRight spacingTop ) ) ).

    exportJson( ?margin list( '( 20.0 20.0 ) '( 20.0 20.0 ) ) )

Texts

Texts are represented as svgpaths by default. If you want to use custom font_data or the newstroke font you can pass the optional argument ?textsAsSvgPaths nil to the export function( exportJson( ?textsAsSvgPaths nil ) ) and the texts are described as defined in DATAFORMAT.md.

Variants and alternate parts

If no variants.lst is present in the allegro directory, a warning is displayed in the command prompt and all components are considered in the json file; otherwise a json file for each variant is created and the DNP field in the extra_fields is set to mark unplaced components. When an alternate part are used, the value of the part is changed to the value of the alternate part.

By passing the optional argument ?excludeDNP t to the export function ( exportJson( ?excludeDNP t ) ) all fabrication and silkscreen data of an unplaced component are ignored.

Parts with no reference designator assigned are not included in the interactive BOM.

Custom properties

Any custom properties assigned to a component are added to the extra_fields.

Layer Mapping

Only the following layers are considered for file creation:

ibom allegro
edges BOARD GEOMETRY/DESIGN_OUTLINE
BOARD GEOMETRY/CUTOUT
fabrication PACKAGE GEOMETRY/ASSEMBLY_TOP
PACKAGE GEOMETRY/ASSEMBLY_BOTTOM
REF DES/ASSEMBLY_TOP
REF DES/ASSEMBLY_BOTTOM
COMPONENT_VALUE/ASSEMBLY_TOP
COMPONENT_VALUE/ASSEMBLY_BOTTOM
silkscreen PACKAGE GEOMETRY/SILKSCREEN_TOP
PACKAGE GEOMETRY/SILKSCREEN_BOTTOM
REF DES/SILKSCREEN_TOP
REF DES/SILKSCREEN_BOTTOM
COMPONENT_VALUE/SILKSCREEN_TOP
COMPONENT_VALUE/SILKSCREEN_BOTTOM

Call interactive HTML BOM from allegro

If you want to export the json file and convert it to the ibom in one step, you can use the code snippet below to write your own script. For ibomArgs see command line options.

ibomSourcePath = ...

when( ibomSourcePath
    ibomPythonFile = strcat( ibomSourcePath "generate_interactive_bom.py" )		
)

ibomArgs = "--name %f --dnp-field DNP --show-fabrication --hide-silkscreen --dest-dir ../ibom --layer-view F --dark-mode --no-browser"

workingDir = getWorkingDir()

; list create files in json directory
files = getDirFiles( "json" ) 

foreach( file files 
    subStrings = parseString( file "." )

    ; if file is json file
    when( car( last( subStrings ) ) == "json" 
        fullFilePath = strcat( "\"" buildString( list( workingDir "json" file ) "/" ) "\"" )
        command = buildString( list( "python" ibomPythonFile fullFilePath ibomArgs ) )
        result = shell( command )	

        unless( result				
            axlUIConfirm( "Error during ibom generation ..." 'error )
        )
    )						
)				
axlUIConfirm( "Process finished!" 'info )

Example

As an example I have done the json export and the ibom creation for the AD-FMCOMMS3-EBZ design, which .brd file is freely accessible.

exportjson's People

Contributors

juulsa avatar

Stargazers

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

Watchers

 avatar

exportjson's Issues

Dummy net lines are absent

And again thank you very much for your script!

There is another glitch I found I think.

Shapes with "dummy nets" from etch are exported but lines are not. Is it possible to add them to export? I have some text made with lines of dummy net, it would be great to have it exported to graphics.

PCB Designer 16.6

Issue
Is this plugin supported for PCB Designer 16.6? It shows me an error for the board from example.

Thieving export and missing dummy lines

Hello again!

I was testing your script and found out that it does not export thieving groups. I assume that you know that in Allegro thieving is a via with some padstack shape without drill. Is it possible to add thieving export? On some boards such things cover lots of board area.

Thanks for your work!

Can I do this using command prompt

Is there anyway I could run a command on windows command prompt to export the json? The export to html in one step code you had. Where do I put that?

Customizable output layer mapping

Hello @juulsA !

Is it possible to process and output to json not only lines but also shapes that are drawn at silkscreen layers?

Is it possible to include BOARD GEOMETRY/SILKSCREEN_TOP
BOARD GEOMETRY/SILKSCREEN_BOTTOM
to export?

exportJson error:can't handle (nil - 0.0)

Hi:
I want to convert an allegro .brd file to json after converting to ibom, but I get the following error:
Command > exportJson
W- WARNING No variant.lst found, exporting entire design ...
CDS version: 16.600000
E- Error difference: can't handle (nil - 0.0)
Command > exportJson( ?excludeDNP t )
E- Command not found: exportJson( ?excludeDNP t )
I am not skilled in allegro, please advise how to solve this error, thank you!

Can't parse json with cutouts

Hello @juulsA ! Thanks for a great script!

I try to use it with my boards, I work with 22.1HF005. There is a bug I think. If there are any graphics at the Board geometry/Cutout subclass the json file can not be parsed by the python script. Says something like this:

d:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom>python generate_interactive_bom.py AD-FMComms3_revA.json

Loading AD-FMComms3_revA.json
2023-10-27 19:57:01,267 INFO Successfully parsed d:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\AD-FMComms3_revA.json
Traceback (most recent call last):
  File "d:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\generate_interactive_bom.py", line 84, in <module>
    main()
  File "d:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\generate_interactive_bom.py", line 77, in main
    ibom.main(parser, config, logger)
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\core\ibom.py", line 327, in main
    pcbdata, components = parser.parse()
                          ^^^^^^^^^^^^^^
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\genericjson.py", line 149, in parse
    self.add_drawing_bounding_box(drawing, board_outline_bbox)
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\common.py", line 136, in add_drawing_bounding_box
    {
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\common.py", line 134, in add_arc
    bbox.add_svgpath(svgpath, width, self.logger)
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\common.py", line 237, in add_svgpath
    for segment in parse_path(svgpath, logger):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\svgpath.py", line 507, in parse_path
    Arc(current_pos, radius, rotation, arc, sweep, end))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\OrCAD\Scripts\InteractiveHtmlBom\InteractiveHtmlBom\ecad\svgpath.py", line 131, in __init__
    assert start != end
           ^^^^^^^^^^^^
AssertionError

Is it possible to fix it? I saw another issue where you recommend to comment a line with Cutout subclass. Is it a recommended workaround?

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.