← Back to team overview

kicad-developers team mailing list archive

Re: DXF import only works in default Canvas.

 

Sorry Nick,

I could have worded that better. I am working on making the DXF import as an area. So I have a modified version of dxf2brd_items that in addPolyline detects that a 'fill_polygon' flag is set (in the modified dxfimport dialog) and when the DXF is
then a closed polygon, it imports the poly as a PCB_ZONE_T and an S_POLYGON
shape (which I assume is the right type and shape).

Like this:

    // Closed polyline can be imported as a filled area when this
    // selected in the import dialog box.
    if( ( aData.flags & 1 ) && m_fillPolygons )
    {
        DRAWSEGMENT* poly = new DRAWSEGMENT( NULL );

        wxPoint startpoint;
        wxPoint polypoint;

        std::vector <wxPoint> pts;
        for( unsigned ii = 0; ii < aData.vertlist.size(); ii++ )
        {
            DRW_Vertex* vertex = aData.vertlist[ii];
            polypoint = wxPoint( mapX( vertex->basePoint.x ),
                                 mapY( vertex->basePoint.y ) );
            // Remember start point
            if( ii == 0 )
            {
                startpoint = polypoint;
            }
            pts.push_back( polypoint );
        }

        // Close polygon back to the start point
        pts.push_back( startpoint );

        poly->SetType( PCB_ZONE_T );
        poly->SetShape( S_POLYGON );
        poly->SetLayer( ToLAYER_ID( m_brdLayer ) );
        poly->SetWidth( mapDim( 0.0001 ) );
        poly->SetPolyPoints( pts );

        m_newItemsList.push_back( poly );
    }
    else
            .....

This will result in a 'gr_poly' in pcbnew with the issues described of importing only in
legacy mode and only showing in GL mode.

In the footprint editor this import results in an 'fp_poly' but will al the points missing in the footprint file. As yet I have not been able to track what the issue there is.

So the DXF area import is not really ready for prime time as yet. My aim is to eventually
import complex copper shapes like antennas onto the board from a DXF.

But the DXF import only working in legacy mode and not in the other modes is a
definitely a bug I think.

Marco

On 29-Jul-15 18:58, Nick Østergaard wrote:
2015-07-29 2:35 GMT+02:00 Marco Hess <marco.hess@xxxxxxxxxxxxxx>:
Hi,

I am still experimenting with the DXF import feature and something I found
is that the DXF import only seems to work in the default canvas.

If the others OpenGL or Cairo canvas is active, the DXF import does nothing,
i.e. nothing gets imported in pcbnew.

I suspect this might be a bug. As I am not that familiar yet with the
differences in these canvases from a code perspective, any ideas as to where
this issue would be?

Then another issue with the DXF import but which is probably for more in the
future is related to importing DXF polygons as areas instead of a group of
lines.

With the default canvas, the import works (i.e. the pcbnew file is modified
and contains a 'gr_poly' with the shape points) but does not show. Switching
to the OpenGL canvas then reveals the shape. Ideas?
How do do that? When I try to save the resulting file only see 5878, I
used the dxf from
https://forum.kicad.info/t/gerber-to-footprint/435/13?u=nickoe

I only see gr_line.

--
Marco Hess
Through IP Pty. Ltd. - AUSTRALIA
www.through-ip.com  | marco.hess@xxxxxxxxxxxxxx
p: +61 407 78 55 66 | f: +61 8 8121 6191



Follow ups

References