View Issue Details

IDProjectCategoryView StatusLast Update
0001366File formatsFeaturepublic2019-07-30 22:39
Reportercbernardo Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformPCOSLinuxOS Version3.12-1-amd64
Summary0001366: IDF import fails (multiple bugs in Idf.py)
DescriptionOn importing IDF files (both *.emn and *.emp) the importer fails when it encounters a blank line.
Steps To ReproduceFrom the FILE menu, select OPEN and select an *.emn file which has blank lines in it
Additional InformationAn exception is thrown when the blank line is encountered:

File ".../Mod/Idf/Idf.py", line 245, in process_emp
if emprecords[0][0:4]==".END":


File ".../Mod/Idf/Idf.py", line 92, in process_emn
if emnrecords[0][0:4]==".END":


There are multiple bugs here:
1. it is assumed there is a *records[0]
2. a minimum length of 4 is assumed for *records[0]
3. the IDFv3 specification states that IDF keywords are not case sensitive, but the script imposes upper case.
TagsNo tags attached.
FreeCAD Information

Activities

cbernardo

2014-01-26 21:28

reporter  

test_idf.zip (1,447 bytes)

Jriegel

2014-01-27 10:29

administrator   ~0004123

Ok, the IDF code is basically unmaintained. I do not have the systems and time to do much debbuging. If its making more trouble, I would rather remove it..

cbernardo

2014-01-30 00:44

reporter   ~0004130

OK, I'll have a look at the Python script since this is important for people who want to use FreeCAD to design a housing for their electronics. This can take a few weeks.

Jriegel

2014-01-30 18:47

administrator   ~0004131

Thanks!

cbernardo

2014-02-07 01:52

reporter  

idf_import.patch (1,548 bytes)   
diff --git a/src/Mod/Idf/Idf.py b/src/Mod/Idf/Idf.py
index c8c2ed0..c6fbae1 100644
--- a/src/Mod/Idf/Idf.py
+++ b/src/Mod/Idf/Idf.py
@@ -41,8 +41,8 @@ model_tab_filename = FreeCAD.getResourceDir()+ "Mod/Idf/lib/footprints_models.cs
 
 step_path=FreeCAD.getResourceDir()+ "Mod/Idf/lib/"
 
-ignore_hole_size=1 # size in MM to prevent huge number of drilled holes
-EmpDisplayMode=2 # 0='Flat Lines', 1='Shaded', 2='Wireframe', 3='Points'; recommended 2 or 0
+ignore_hole_size=0.35 # size in MM to prevent huge number of drilled holes
+EmpDisplayMode=1 # 0='Flat Lines', 1='Shaded', 2='Wireframe', 3='Points'; recommended 2 or 0
 
 IDF_sort=0 # 0-sort per refdes [1 - part number (not preffered)/refdes] 2-sort per footprint/refdes
 
@@ -89,7 +89,8 @@ def process_emn(doc,filename):
    section_counter=0
    for emnline in emnlines:
        emnrecords=split_records(emnline)
-       if emnrecords[0][0:4]==".END":
+       if len( emnrecords )==0 : continue
+       if len( emnrecords[0] )>4 and emnrecords[0][0:4]==".END":
           passed_sections.append(current_section)
           current_section=""
        elif emnrecords[0][0]==".":
@@ -242,7 +243,8 @@ def process_emp(doc,filename,placement,board_thickness):
    comps=[]
    for empline in emplines:
      emprecords=split_records(empline)
-     if emprecords[0][0:4]==".END":
+     if len( emprecords )==0 : continue
+     if len( emprecords[0] )>4 and emprecords[0][0:4]==".END":
         current_section=""
         passed_sections.append(current_section)
         if comp_PartNumber!="":
idf_import.patch (1,548 bytes)   

cbernardo

2014-02-07 01:55

reporter   ~0004160

I have attached a git patch (idf_import.patch) to the IDF import script. This fixes the issue with the blank lines in the IDF file causing problems. This makes it possible for people to view IDF files exported from KiCad.

Related Changesets

FreeCAD: master e1b5f913

2014-03-25 16:25:10

barleyman


Committer: wmayer Details Diff
Update Idf.py

Fixes from bug 1366 http://www.freecadweb.org/tracker/view.php?id=1366
Affected Issues
0001366
mod - src/Mod/Idf/Idf.py Diff File

FreeCAD: master 8693bfab

2014-03-29 13:19:48

wmayer

Details Diff
+ remove plus sign Affected Issues
0001366
mod - src/Mod/Idf/Idf.py Diff File

Issue History

Date Modified Username Field Change
2014-01-26 21:28 cbernardo New Issue
2014-01-26 21:28 cbernardo File Added: test_idf.zip
2014-01-27 10:29 Jriegel Note Added: 0004123
2014-01-27 10:29 Jriegel Status new => acknowledged
2014-01-30 00:44 cbernardo Note Added: 0004130
2014-01-30 18:47 Jriegel Note Added: 0004131
2014-02-07 01:52 cbernardo File Added: idf_import.patch
2014-02-07 01:55 cbernardo Note Added: 0004160
2014-03-29 12:51 wmayer Changeset attached => FreeCAD Master master 8693bfab
2014-03-29 12:52 wmayer Status acknowledged => closed
2014-03-29 12:52 wmayer Resolution open => fixed
2019-07-30 22:39 Kunda1 Changeset attached => FreeCAD master e1b5f913