Пример #1
0
        public bool WriteFile(string filename)
        {
            StreamWriter sw = null;

            FolderPath = Path.GetDirectoryName(filename);
            FileName   = filename;
            if (filename.EndsWith("xml"))
            {
                WriteXMLFile(filename);
                return(true);
            }
#if (IFCJSON)
            else if (filename.EndsWith("json"))
            {
                WriteJSONFile(filename);
                return(true);
            }
#endif
#if (!NOIFCZIP)
            bool zip = filename.EndsWith(".ifczip");
            System.IO.Compression.ZipArchive za = null;
            if (zip)
            {
                if (System.IO.File.Exists(filename))
                {
                    System.IO.File.Delete(filename);
                }
                za = System.IO.Compression.ZipFile.Open(filename, System.IO.Compression.ZipArchiveMode.Create);
                System.IO.Compression.ZipArchiveEntry zae = za.CreateEntry(System.IO.Path.GetFileNameWithoutExtension(filename) + ".ifc");
                sw = new StreamWriter(zae.Open());
            }
            else
#endif
            sw = new StreamWriter(filename);
            CultureInfo current = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            sw.Write(getHeaderString(filename) + "\r\n");
            for (int icounter = 1; icounter < mIfcObjects.Count; icounter++)
            {
                BaseClassIfc ie = mIfcObjects[icounter];
                if (ie != null)
                {
                    string str = ie.ToString();
                    if (!string.IsNullOrEmpty(str))
                    {
                        sw.WriteLine(str);
                    }
                }
            }
            sw.Write(getFooterString());
            sw.Close();
            Thread.CurrentThread.CurrentUICulture = current;
#if (!NOIFCZIP)
            if (zip)
            {
                za.Dispose();
            }
#endif
            return(true);
        }
Пример #2
0
        public override string ToString()
        {
            //IFCModel im = new IFCModel(mIFC2x3,true);
            string result = getHeaderString("") + "\r\n";

            for (int icounter = 1; icounter < mIfcObjects.Count; icounter++)
            {
                BaseClassIfc ie = mIfcObjects[icounter];
                if (ie != null)
                {
                    string str = ie.ToString();
                    if (str != "")
                    {
                        result += str + "\r\n";
                    }
                }
            }
            return(result + getFooterString());
        }