diff --git a/eeschema/netlist_exporters/netlist_exporter_base.cpp b/eeschema/netlist_exporters/netlist_exporter_base.cpp index e924f3f353..831b30f7e7 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_base.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2017 jp.charras at wanadoo.fr * Copyright (C) 2013-2017 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -119,7 +119,9 @@ static bool sortPinsByNum( PIN_INFO& aPin1, PIN_INFO& aPin2 ) } -void NETLIST_EXPORTER_BASE::CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aSheetPath ) +void NETLIST_EXPORTER_BASE::CreatePinList( SCH_COMPONENT* aSymbol, + SCH_SHEET_PATH* aSheetPath, + bool aKeepUnconnectedPins ) { wxString ref( aSymbol->GetRef( aSheetPath ) ); @@ -145,7 +147,8 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PAT // Collect all pins for this reference designator by searching the entire design for // other parts with the same reference designator. // This is only done once, it would be too expensive otherwise. - findAllUnitsOfSymbol( aSymbol, aSymbol->GetPartRef().get(), aSheetPath ); + findAllUnitsOfSymbol( aSymbol, aSymbol->GetPartRef().get(), + aSheetPath, aKeepUnconnectedPins ); } else // GetUnitCount() <= 1 means one part per package @@ -158,11 +161,13 @@ void NETLIST_EXPORTER_BASE::CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PAT { const wxString& netName = conn->Name(); - // Skip unconnected pins - CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, *aSheetPath ); + if( !aKeepUnconnectedPins ) // Skip unconnected pins if requested + { + CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, *aSheetPath ); - if( !sg || sg->m_no_connect || sg->m_items.size() < 2 ) + if( !sg || sg->m_no_connect || sg->m_items.size() < 2 ) continue; + } m_sortedSymbolPinList.emplace_back( pin->GetNumber(), netName ); } @@ -214,7 +219,8 @@ void NETLIST_EXPORTER_BASE::eraseDuplicatePins() void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_COMPONENT* aSymbol, - LIB_PART* aPart, SCH_SHEET_PATH* aSheetPath ) + LIB_PART* aPart, SCH_SHEET_PATH* aSheetPath, + bool aKeepUnconnectedPins ) { wxString ref = aSymbol->GetRef( aSheetPath ); wxString ref2; @@ -241,11 +247,13 @@ void NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol( SCH_COMPONENT* aSymbol, { const wxString& netName = conn->Name(); - // Skip unconnected pins - CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, sheet ); + if( !aKeepUnconnectedPins ) // Skip unconnected pins if requested + { + CONNECTION_SUBGRAPH* sg = graph->FindSubgraphByName( netName, sheet ); - if( !sg || sg->m_no_connect || sg->m_items.size() < 2 ) - continue; + if( !sg || sg->m_no_connect || sg->m_items.size() < 2 ) + continue; + } m_sortedSymbolPinList.emplace_back( pin->GetNumber(), netName ); } diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h index d83b6ffa8a..6019d6ae25 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.h +++ b/eeschema/netlist_exporters/netlist_exporter_base.h @@ -115,8 +115,10 @@ protected: * This list is sorted by pin number. The symbol is the next actual symbol after \a aSymbol. * Power symbols and virtual symbols that have their reference designators starting with * '#' are skipped. + * if aKeepUnconnectedPins = false, unconnected pins will be removed from list + * but usually we need all pins in netlists. */ - void CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aSheetPath ); + void CreatePinList( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aSheetPath, bool aKeepUnconnectedPins ); /** * Check if the given symbol should be processed for netlisting. @@ -147,9 +149,11 @@ protected: * Search the entire design for all units of \a aSymbol based on matching reference * designator, and for each unit, add all its pins to the temporary sorted pin list, * m_sortedSymbolPinList. + * if aKeepUnconnectedPins = false, unconnected pins will be removed from list + * but usually we need all pins in netlists. */ void findAllUnitsOfSymbol( SCH_COMPONENT* aSymbol, LIB_PART* aPart, - SCH_SHEET_PATH* aSheetPath ); + SCH_SHEET_PATH* aSheetPath, bool aKeepUnconnectedPins ); public: /** diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index d1860cf4f0..eb03823fe1 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2018 jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -77,7 +77,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, if( !symbol ) continue; - CreatePinList( symbol, &sheet ); + CreatePinList( symbol, &sheet, true ); if( symbol->GetPartRef() && symbol->GetPartRef()->GetFPFilters().GetCount() != 0 ) cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetPartRef().get(), sheet ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index 8c13f55e24..da7cf9db56 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -287,7 +287,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl ) if( !symbol ) continue; - CreatePinList( symbol, &sheet ); + CreatePinList( symbol, &sheet, true ); SPICE_ITEM spiceItem; spiceItem.m_parent = symbol;