← Back to team overview

kicad-developers team mailing list archive

PATCH: VRML/IDF exporter tweaks and bug fixes

 

This patch changes the unit options in the VRML exporter from "Inch, mm,
Meter" to "mm, 0.1 Inch, Inch"; the 0.1 inch option may allow an exported
model to be used as an input to KiCad if the parser will support the
included URNs in the future.

The patch also fixes a bug in the IDF exporter where the 3D model X,Y,Z
offsets were treated as mm rather than inch.

- Cirilo
=== modified file 'pcbnew/dialogs/dialog_export_vrml.cpp'
--- pcbnew/dialogs/dialog_export_vrml.cpp	2015-03-03 10:50:50 +0000
+++ pcbnew/dialogs/dialog_export_vrml.cpp	2015-08-06 21:55:58 +0000
@@ -151,8 +151,8 @@
 
     // The general VRML scale factor
     // Assuming the VRML default unit is the mm
-    // this is the mm to VRML scaling factor for inch, mm and meter
-    double scaleList[3] = { 1.0/25.4, 1, 0.001 };
+    // this is the mm to VRML scaling factor for mm, 0.1 inch, and inch
+    double scaleList[3] = { 1.0, 10.0/25.4, 1.0/25.4 };
 
     // Build default file name
     fn = GetBoard()->GetFileName();

=== modified file 'pcbnew/dialogs/dialog_export_vrml_base.cpp'
--- pcbnew/dialogs/dialog_export_vrml_base.cpp	2015-03-03 10:50:50 +0000
+++ pcbnew/dialogs/dialog_export_vrml_base.cpp	2015-08-06 21:55:37 +0000
@@ -58,7 +58,7 @@
 	
 	bLowerSizer->Add( bSizer4, 3, wxEXPAND, 5 );
 	
-	wxString m_rbSelectUnitsChoices[] = { _("Inch"), _("mm"), _("Meter") };
+	wxString m_rbSelectUnitsChoices[] = { _("mm"), _("0.1 Inch"), _("Inch") };
 	int m_rbSelectUnitsNChoices = sizeof( m_rbSelectUnitsChoices ) / sizeof( wxString );
 	m_rbSelectUnits = new wxRadioBox( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, m_rbSelectUnitsNChoices, m_rbSelectUnitsChoices, 1, wxRA_SPECIFY_COLS );
 	m_rbSelectUnits->SetSelection( 0 );

=== modified file 'pcbnew/dialogs/dialog_export_vrml_base.fbp'
--- pcbnew/dialogs/dialog_export_vrml_base.fbp	2015-03-03 10:50:50 +0000
+++ pcbnew/dialogs/dialog_export_vrml_base.fbp	2015-08-06 21:55:35 +0000
@@ -752,7 +752,7 @@
                                 <property name="caption"></property>
                                 <property name="caption_visible">1</property>
                                 <property name="center_pane">0</property>
-                                <property name="choices">&quot;Inch&quot; &quot;mm&quot; &quot;Meter&quot;</property>
+                                <property name="choices">&quot;mm&quot; &quot;0.1 Inch&quot; &quot;Inch&quot;</property>
                                 <property name="close_button">1</property>
                                 <property name="context_help"></property>
                                 <property name="context_menu">1</property>

=== modified file 'pcbnew/exporters/export_idf.cpp'
--- pcbnew/exporters/export_idf.cpp	2015-07-04 16:32:37 +0000
+++ pcbnew/exporters/export_idf.cpp	2015-08-06 21:40:41 +0000
@@ -398,9 +398,9 @@
             throw( std::runtime_error( aIDFBoard.GetError() ) );
 
         double rotz = aModule->GetOrientation()/10.0;
-        double locx = modfile->m_MatPosition.x;
-        double locy = modfile->m_MatPosition.y;
-        double locz = modfile->m_MatPosition.z;
+        double locx = modfile->m_MatPosition.x * 25.4;  // part offsets are in inches
+        double locy = modfile->m_MatPosition.y * 25.4;
+        double locz = modfile->m_MatPosition.z * 25.4;
         double lrot = modfile->m_MatRotation.z;
 
         bool top = ( aModule->GetLayer() == B_Cu ) ? false : true;


Follow ups