@menno wrote:
I just noticed that when a file import plug-in has multiple file types declared, that when a file gets dropped onto Rhino the index in de ReadFile method is incorrect. When the file gets opened from the File>Open or File>Import menu, the problem does not appear.
When I drag a file with extension
.dat
onto Rhino when the file import plug-in (see below for code) is loaded, I get the following:Observed output
Received index 0
TXT fileExpected output
Received index 1
DAT Fileprivate int txtIndex, datIndex, wordIndex; protected override Rhino.PlugIns.FileTypeList AddFileTypes(Rhino.FileIO.FileReadOptions options) { var result = new Rhino.PlugIns.FileTypeList(); txtIndex = result.AddFileType("Text file (*.txt)", "txt"); datIndex = result.AddFileType("Data File (*.dat, *.plt)", "dat", "plt"); wordIndex = result.AddFileType("Word Document (*.docx)", "docx"); RhinoApp.WriteLine("TXT index {0}", txtIndex); RhinoApp.WriteLine("DAT index {0}", datIndex); RhinoApp.WriteLine("WORD index {0}", wordIndex); return result; } protected override bool ReadFile(string filename, int index, RhinoDoc doc, Rhino.FileIO.FileReadOptions options) { bool read_success = false; RhinoApp.WriteLine("Received index {0}", index); if (index == txtIndex) RhinoApp.WriteLine("TXT file"); else if (index == datIndex) RhinoApp.WriteLine("DAT file"); else if (index == wordIndex) RhinoApp.WriteLine("WORD file"); return read_success; }
Posts: 2
Participants: 2