juulsA / exportJson

Skill script for Allegro PCB designer, which generates a JSON representation of the board.
MIT License
17 stars 8 forks source link

PCB Designer 16.6 #2

Closed Kartohen closed 1 year ago

Kartohen commented 1 year ago

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

juulsA commented 1 year ago

Unfortunetly this is a question I can't answer ... all programming and tests were done with 17.4. Based on the error I can guess, that the program is trying to access a value from an element that does not exist ... I try to add some debug messages to the code, so we can figure where this is happening ... thanks to cadence the line where the error occurs is not printed to the console ... but please give me some time for this.

juulsA commented 1 year ago

another hint: all actions need to be completed / closed by clicking 'done', otherwise the skill scripts often do not run properly ... but I don't think, that this is the case here ...

Kartohen commented 1 year ago

I've found the place where this error appears in the code:

image

Changing var Extents helps to avoid error.

juulsA commented 1 year ago

Thanks for your help! Maybe I have to add some lines of code, so that the script does not run into this error ... maybe the pcb editor 16.6 does not support the dsn->designOutline or the axlDBGetExtents call ... could you check what is the output of the outline, segments and extents by typing the following to the skill command line?

open the skill comand line ( set teslkill )

dsn = axlDBGetDesign() outline = dsn->designOutline

outline should print somethings like this dbid:000001B548763A30

segments = outline->segments

should print a list of dbids

extents = axlDBGetExtents( segments nil )

prints two coordinates, if everything works as intended.

Kartohen commented 1 year ago

On the next step I receive this error:

image

juulsA commented 1 year ago

seems like version 16.6 and 17.4 differs in their default layers ... the BOARD GEOMETRY/CUTOUT is a fixed layer in 17.4 ... If you don't have any cutouts you can comment the whole "add cutout to edges list" commands (add a ; to each line)

cutout = car( axlDBGetShapes( "BOARD GEOMETRY/CUTOUT" ) ) segments = cutout->segments

    foreach( segment segments
        ; parse segment
        if( pcbLinewidth then 
            element = parseSegment( segment pcbLinewidth )  
        else
            element = parseSegment( segment segment->width )  
        )

        if( boundp( 'edges ) then
            tconc( edges element )
        else
            edges = tconc( nil element )
        )      
    )

or change the layer name to the correct layer name.

Kartohen commented 1 year ago

I have this result for Outline:

image

Kartohen commented 1 year ago

I've added ; to all lines

image

But error is the same:

image

Kartohen commented 1 year ago

I've added ; to the next block:

image

Now the next error is:

image

juulsA commented 1 year ago

okay... yeah, sorry, I forgot, that we don't have any information for the board outline now (dsn->boardOutline is nil) ... and edges is an unbound ... maybe we can check, if this is the only error we are running in.

Please do the following:

Comment out the addBoardGeometry and execute exportJson

The function should complete, if there are no further "mistakes". If this works, we try to find a solution for our initial problem.

Kartohen commented 1 year ago

After commenting export did complete. Would it be useful to attach .json file here?

Kartohen commented 1 year ago

I have this list of layers:

image image

juulsA commented 1 year ago

After commenting export did complete. Would it be useful to attach .json file here?

No, I don't need the .json file, but now we know, that we just need to modify the addBoardGeometry function.

Does this prints any dbids?

segments = car( axlDBGetShapes( "Board Geometry/Design_Outline" ) )

Kartohen commented 1 year ago

image

Kartohen commented 1 year ago

I set extents = margin to prevent error about nil, if it matters.

juulsA commented 1 year ago

I set extents = margin to prevent error about nil, if it matters.

I don't think this is a problem. Can you find out, what's the name of the pcb contour layer and the cutouts? And then execute the previous command with the layer name?

Kartohen commented 1 year ago

Outline:

Skill > segments = car( axlDBGetShapes( "Board Geometry/Outline" ) ) dbid:376073928 Skill >

juulsA commented 1 year ago

Then you don't need the lines 686 - 688:

Can be removed: dsn = axlDBGetDesign() outline = dsn->designOutline segments = outline->segments

and replaced by: segments = car( axlDBGetShapes( "Board Geometry/Outline" ) )

Maybe you can try, if extents = axlDBGetExtents( segments nil ) is working now, otherwise leave it as you modified it.

Uncomment the previously commented line addBoardGeometry and give the exportJson a new try.

Kartohen commented 1 year ago

Now I get this kind of error: E- *Error* foreach: second argument must be a list - dbid:177495752

Maybe the issue is in Cutout layer? I can't find it, the only similar layer name is Cut_marks. But for this layer I have:

Skill > segments = car( axlDBGetShapes( "Board Geometry/Cut_Marks" ) ) nil

juulsA commented 1 year ago

To get this running without the cutout layer (comment line 726 - 739).

Does this error returns from the call axlDBGetExtents ( ... )? Then please modify it the way you have done it before.

Kartohen commented 1 year ago

All variants give the same result: E- *Error* foreach: second argument must be a list - dbid:177495752

Only if I comment lines 707-750, export can complete.

juulsA commented 1 year ago

My mistake ... it should be:

outline = car( axlDBGetShapes( "Board Geometry/Outline" ) ) segments = outline->segments

instead of only

segments = car( axlDBGetShapes( "Board Geometry/Outline" ) )

Please try this.

Kartohen commented 1 year ago

Now it works! You made great script, Thank You! And Thank You for help!

juulsA commented 1 year ago

Ok, great! I'll check, if I can solve the issue with a few lines of code, so that the script is also working for older versions of allegro. Thank you for reporting this issue ;)

juulsA commented 1 year ago

Please check my latest version of the script, which should handle all layers correctly.

Kartohen commented 1 year ago

The latest version works properly with ver. 16.6! Thank you!

Kartohen commented 1 year ago

I found out, that in HTML all elements are located on Back side and Front side is empty. File from the example works correct, and file .json that was made in ver. 16.6 has this error.

juulsA commented 1 year ago

Can you share the .json file?

Kartohen commented 1 year ago

My.txt

Kartohen commented 1 year ago

As I understand, in this line, for example, should be "layer": "F"? image

juulsA commented 1 year ago

Yes, if I run the script on this project the layer is set to "F".

Can you add the following to line 1381:

print( symbol->layer )

And tell me what is the output? Thanks!

juulsA commented 1 year ago

Result is the same, Front is empty

AD-FMComms3.txt

The command should have printed something to your command line.

But I think I have to change the code there ... please have some patience

Kartohen commented 1 year ago

I added line print( symbol->layer ) to file exportJson, is it my mistake? Should I add it to file .json?

juulsA commented 1 year ago

No, to the exportJson.il. But please check my latest commit, I hope, I fixed it.

Kartohen commented 1 year ago

Still the same result: emprty Front side.

AD-FMComms3.txt

Kartohen commented 1 year ago

And do you have an opportunity to open my .json file in iBOM? Maybe mistake is only on my side?

Kartohen commented 1 year ago

In .json we need here and for the same elements "F":

image

This way iBom would work correct.

juulsA commented 1 year ago

Yes, this is what I just saw ... But please do this as I described above and make your command line visible, because the information I need is only printed to the command line. And tell me the results.

Yes, if I run the script on this project the layer is set to "F".

Can you add the following to line 1381:

print( symbol->layer )

And tell me what is the output? Thanks!

Kartohen commented 1 year ago

I've added here:

              ; get symbol layer
        print( symbol->layer )
                if( symbol->layer == "TOP" then
                    layer = "\"F\""
                else
                    layer = "\"B\""
                )

This is result in command line:

Command > exportJson
CDS version: 16.600000
nilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnilnil"Export complete!"
W- *WARNING* No variant.lst found, exporting entire design ... 
Command > 
juulsA commented 1 year ago

Ok, give me some time to make some changes to the code.

juulsA commented 1 year ago

Please update to the latest version and give it another try ... hopefully it works now!

Kartohen commented 1 year ago

Now everything is alright! Thank You!