KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_solidworks.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <wx/string.h>
21
22#include <pcb_io_solidworks.h>
24#include <altium_pcb.h>
26#include <pcb_io/pcb_io.h>
27
28#include <board.h>
29
30#include <compoundfilereader.h>
31#include <utf.h>
32
33PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) )
34{
35}
36
37
39{
40}
41
42
43bool PCB_IO_SOLIDWORKS::CanReadBoard( const wxString& aFileName ) const
44{
45 if( !PCB_IO::CanReadBoard( aFileName ) )
46 return false;
47
49}
50
51
52BOARD* PCB_IO_SOLIDWORKS::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
53 const STRING_UTF8_MAP* aProperties, PROJECT* aProject )
54{
55 m_props = aProperties;
56
57 m_board = aAppendToMe ? aAppendToMe : new BOARD();
58
59 // Give the filename to the board if it's new
60 if( !aAppendToMe )
61 m_board->SetFileName( aFileName );
62
63 // clang-format off
64 const std::map<ALTIUM_PCB_DIR, std::string> mapping = {
65 { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" },
66 { ALTIUM_PCB_DIR::ARCS6, "D2864697BB2D411B857EBD69D74447" },
67 { ALTIUM_PCB_DIR::BOARD6, "21CE7E3D9BFF41679BACA1184CAF54" },
68 { ALTIUM_PCB_DIR::BOARDREGIONS, "67075A4119214CE4AB174F9B1A9A41" },
69 { ALTIUM_PCB_DIR::CLASSES6, "1122D4F14A924F9CA5C2060AF370E0" },
70 { ALTIUM_PCB_DIR::COMPONENTS6, "208CAE8E44BD43D5B3CCA426D9331B" },
71 { ALTIUM_PCB_DIR::COMPONENTBODIES6, "6DDF94E6CB364893BED31C189F9AF3" },
72 { ALTIUM_PCB_DIR::DIMENSIONS6, "6148AE8C77B042798B46830E96BB24" },
73 { ALTIUM_PCB_DIR::FILLS6, "5944DE0E258C41E2B0B382AC964048" },
74 { ALTIUM_PCB_DIR::MODELS, "874F98A7E25A48EDAD394EB891E503" },
75 { ALTIUM_PCB_DIR::NETS6, "0201837ACD434D55B34BBC68B75BAB" },
76 { ALTIUM_PCB_DIR::PADS6, "E4D0C33E25824886ABC7FEEAE7B521" },
77 { ALTIUM_PCB_DIR::POLYGONS6, "7ABD4252549749DD8DB16804819AC3" },
78 { ALTIUM_PCB_DIR::REGIONS6, "6B3892541AB94CD999291D590B5C86" }, // probably wrong; in as a placeholder
79 { ALTIUM_PCB_DIR::RULES6, "7009830ADF65423FA6CCB73A77E710" },
80 { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "91241C66300E4490965070BA56F6F7" },
81 { ALTIUM_PCB_DIR::TEXTS6, "4AF3D139533041489C2A57BBF9890D" },
82 { ALTIUM_PCB_DIR::TRACKS6, "5D0C6E18E16A4BBFAA256C24B79EAE" },
83 { ALTIUM_PCB_DIR::VIAS6, "2AF5387F097242D3A1095B6FAC3397" },
84 { ALTIUM_PCB_DIR::WIDESTRINGS6, "9B378679AF85466C8673A41EE46393" }
85
86 /*
87 * Understood but not needed:
88 * 04A8F96E0E4C478C813AE57CACCD0F - Legacy text storage
89 * 01F1BD1AA06E4D6A9D1ABF0BBFF4A4 - Fwd/Back compatibility messages
90 *
91 * Not yet used by KiCad:
92 * 7C01505E39124E67BCCAB1883B8FB7 - Design Rule Checker Options6
93 * 63B31A3709B54882BFA96424906BE8 - EmbeddedFonts6
94 * 8B83C7E94C1D419B9B2D5505479820 - Pin Swap Options6
95 * F78C10230A794F5C93ACB50AC693B2 - Advanced Placer Options6
96 *
97 * No data yet on:
98 * 1C0DB1ED572645BEB65D029D20406C
99 * 2AA5C1C72BF14315A47DD931B84A79
100 * 6468C28D32CC4867AB374091CC8431
101 * 6B3892541AB94CD999291D590B5C86
102 * 8675F4105E444E6D9B2BEE6273769D
103 * B983FCC2B6DE46E0B94006B6393235
104 * D6551D22B6DB44659C3F32F7E1949D
105 *
106 * Not yet identified:
107 * D06DD2E4A51C4A3EA96D9ED8C8F3F3
108 * F9C465994DE840579ED19E820C19C2
109 *
110 * Region-like objects that don't map cleanly (maybe Solidworks sketches?)
111 * 84958494F3F54075975C4E199DB8EB
112 * 2E731D36D1F049428744F0661F3E44
113 */
114 };
115 // clang-format on
116
117 ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName );
118
119 try
120 {
121 // Parse File
123 pcb.Parse( altiumPcbFile, mapping );
124 }
125 catch( CFB::CFBException& exception )
126 {
127 THROW_IO_ERROR( exception.what() );
128 }
129
130 return m_board;
131}
void Parse(const ALTIUM_COMPOUND_FILE &aAltiumPcbFile, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
Definition: altium_pcb.cpp:301
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
void SetFileName(const wxString &aFileName)
Definition: board.h:317
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition: io_base.h:213
static bool checkFileHeader(const wxString &aFileName)
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:72
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition: pcb_io.h:343
const STRING_UTF8_MAP * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition: pcb_io.h:346
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io.cpp:43
Container for project specific data.
Definition: project.h:62
A name/value tuple with unique names and optional values.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39