private void CreateImportItem(List <ImportItem> importItems)
        {
            BMECInstanceManager instanceManager = BMECApi.Instance.InstanceManager;

            foreach (ImportItem importItem in importItems)
            {
                if (string.IsNullOrEmpty(importItem.Key) || !importItem.Valid)
                {
                    //log-- this means there are blank records
                    continue;
                }
                System.Windows.Forms.Application.DoEvents();
                ArrayList associations   = new ArrayList();
                ArrayList propertyValues = new ArrayList();

                //use the instance to set the properties
                foreach (IECPropertyValue propertyValue in importItem.Instance)
                {
                    if (propertyValue.IsNull)
                    {
                        continue;
                    }
                    if (propertyValue.StringValue == null)
                    {
                        continue;
                    }
                    string pval = string.Format("{0}={1}", propertyValue.AccessString, propertyValue.StringValue);
                    propertyValues.Add(pval);
                }

                foreach (string rItem in importItem.RelationClassValueCache.Keys)
                {
                    string relatedVal = string.Format("{0}={1}", rItem, importItem.RelationClassValueCache[rItem]);
                    associations.Add(relatedVal);
                }
                string clsName = importItem.Instance.ClassDefinition.Name;
                if (associations.Count > 0)
                {
                    WorkspaceUtilities.SaveSettings("Associations." + clsName, associations);
                }

                IECInstance ecInstance = instanceManager.CreateECInstance(clsName);
                BMECApi.Instance.SpecProcessor.FillCurrentPreferences(ecInstance, true);
                ECInstanceDialog ecDlg = new ECInstanceDialog(importItem.Instance);
                ecDlg.InitializeWithCustomProperties(associations, propertyValues, true);
                ecDlg.SaveData(false);
            }
        }
            /*------------------------------------------------------------------------------------**/
            /// <summary>
            /// Import
            /// </summary>
            /// <param name="unparsed"></param>
            /*--------------+---------------+---------------+---------------+---------------+------*/
            public static void Import
            (
                string unparsed
            )
            {
                if (string.IsNullOrEmpty(unparsed))
                {
                    WorkspaceUtilities.DisplayErrorMessage(LocalizableStrings.BadImportCommand, LocalizableStrings.ImportCommandFormat);
                    return;
                }

                BMECApi.Instance.ClearActivePlacementTool();  // exit current placement tool
                IECClass ecClass = SchemaUtilities.PlantSchema.GetClass(unparsed.Trim());

                if (ecClass == null)
                {
                    WorkspaceUtilities.DisplayErrorMessage(string.Format(LocalizableStrings.BadClassName, unparsed.Trim()), "");
                    return;
                }

                BMECInstanceManager instanceManager = BMECApi.Instance.InstanceManager;

                OpenFileDialog openFileDlg = new OpenFileDialog();

                openFileDlg.Multiselect = false;
                openFileDlg.Filter      = "Import data file|*.txt";
                openFileDlg.ShowDialog();
                if (string.IsNullOrEmpty(openFileDlg.FileName))
                {
                    return;
                }

                if (!IsImportFileValidFormat(openFileDlg.FileName, ecClass))
                {
                    return;
                }

                System.IO.StreamReader sr = System.IO.File.OpenText(openFileDlg.FileName);

                ArrayList associations   = new ArrayList();
                ArrayList propertyValues = new ArrayList();


                WaitDialog wtDlg = new WaitDialog();

                wtDlg.SetTitleString(LocalizableStrings.ImportingInstances);
                wtDlg.SetInformationSting(LocalizableStrings.ImportingInstancesInfo);
                wtDlg.Show();

                string lineRead = sr.ReadLine().Trim();

                while (!sr.EndOfStream)
                {
                    Application.DoEvents();
                    if (string.IsNullOrEmpty(lineRead))
                    {
                        lineRead = sr.ReadLine().Trim();
                        continue;
                    }
                    if (lineRead == "[Associations]")
                    {
                        associations.Clear();
                        while (!sr.EndOfStream)
                        {
                            lineRead = sr.ReadLine().Trim();
                            if (string.IsNullOrEmpty(lineRead))
                            {
                                continue;
                            }

                            if (lineRead == "[InstanceData]")
                            {
                                break;
                            }

                            associations.Add(lineRead);
                        }
                    }

                    if (lineRead == "[InstanceData]")
                    {
                        propertyValues.Clear();
                        while (!sr.EndOfStream)
                        {
                            lineRead = sr.ReadLine().Trim();
                            if (lineRead == "[InstanceData]")
                            {
                                break;
                            }

                            if (lineRead == "[Associations]")
                            {
                                break;
                            }

                            if (string.IsNullOrEmpty(lineRead))
                            {
                                continue;
                            }

                            propertyValues.Add(lineRead);
                        }

                        IECInstance ecInstance = instanceManager.CreateECInstance(ecClass.Name);
                        BMECApi.Instance.SpecProcessor.FillCurrentPreferences(ecInstance, true);
                        ecInstance.InstanceId = "mechanical";
                        ECInstanceDialog ecDlg = new ECInstanceDialog(ecInstance);
                        ecDlg.InitializeWithCustomProperties(associations, propertyValues, true);
                        ecDlg.SaveData();
                    }
                }
                wtDlg.Close();
                sr.Close();
            }