示例#1
0
        public static bool ConvertVersion(string inputFile, DwgVersion version, out string outputFile)
        {
            outputFile = GetAndPrepareOutputFileName(inputFile);
            if (outputFile == "")
            {
                return(false);
            }

            try
            {
                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(inputFile);
                try
                {
                    using (doc.LockDocument())
                        doc.Database.SaveAs(outputFile, version);
                    return(true);
                }
                catch
                {
                    outputFile = "";
                    return(false);
                }
                finally
                {
                    doc.CloseAndDiscard();
                }
            }
            catch
            {
                outputFile = "";
                return(false);
            }
        }
示例#2
0
        public virtual DecomposeForSaveReplacementRecord DecomposeForSave(DwgVersion version)
        {
            createInstance();
            DecomposeForSaveReplacementRecord DecomposeForS = BaseDBObject.DecomposeForSave(version);

            tr.Dispose();
            return(DecomposeForS);
        }
示例#3
0
文件: Class885.cs 项目: 15831944/WW
        public static DxfVersion smethod_4(DwgVersion dwgVersion)
        {
            DxfVersion dxfVersion;

            switch (dwgVersion)
            {
            case DwgVersion.Dwg1010:
                dxfVersion = DxfVersion.Dxf10;
                break;

            case DwgVersion.Dwg1011:
                dxfVersion = DxfVersion.Dxf10PlusUnofficial;
                break;

            case DwgVersion.Dwg1012:
                dxfVersion = DxfVersion.Dxf12;
                break;

            case DwgVersion.Dwg1013:
                dxfVersion = DxfVersion.Dxf13;
                break;

            case DwgVersion.Dwg1014:
                dxfVersion = DxfVersion.Dxf14;
                break;

            case DwgVersion.Dwg1015Beta:
            case DwgVersion.Dwg1015:
                dxfVersion = DxfVersion.Dxf15;
                break;

            case DwgVersion.Dwg1018Beta:
            case DwgVersion.Dwg1018:
                dxfVersion = DxfVersion.Dxf18;
                break;

            case DwgVersion.Dwg1021Beta:
            case DwgVersion.Dwg1021:
                dxfVersion = DxfVersion.Dxf21;
                break;

            case DwgVersion.Dwg1024Beta:
            case DwgVersion.Dwg1024:
                dxfVersion = DxfVersion.Dxf24;
                break;

            case DwgVersion.Dwg1027Beta:
            case DwgVersion.Dwg1027:
                dxfVersion = DxfVersion.Dxf27;
                break;

            default:
                throw new NotSupportedException("Unknown DwgVersion " + (object)dwgVersion + ".");
            }
            return(dxfVersion);
        }
示例#4
0
        internal override void Read(Class434 or, Class259 objectBuilder)
        {
            base.Read(or, objectBuilder);
            Interface30 objectBitStream = or.ObjectBitStream;
            int         num1;

            if (or.Builder.Version > DxfVersion.Dxf14)
            {
                num1 = objectBitStream.imethod_11();
                if (or.Builder.Version > DxfVersion.Dxf15)
                {
                    objectBitStream.ReadString();
                }
                int num2 = objectBitStream.imethod_11();
                this.dwgVersion_0 = (DwgVersion)(num2 & (int)ushort.MaxValue);
                this.short_1      = (short)(num2 >> 16);
                this.bool_2       = objectBitStream.imethod_6();
                if (this.bool_2)
                {
                    objectBitStream.imethod_11();
                    objectBitStream.imethod_11();
                }
            }
            else
            {
                num1 = objectBitStream.imethod_11();
                objectBitStream.imethod_11();
            }
            this.dxfClass_0 = or.Builder.Model.Classes.GetClassWithClassNumber((short)num1);
            Class1048 class1048 = (Class1048)objectBitStream;

            this.stream_0 = (Stream) new PagedMemoryStream(1024L, 1024);
            this.long_0   = (long)class1048.MainReader.imethod_21((PagedMemoryStream)this.stream_0);
            Class444.Create(or.Builder.Version, this.stream_0);
            if (class1048.StringReader != class1048.MainReader)
            {
                this.stream_1 = (Stream) new PagedMemoryStream(1024L, 1024);
                this.uint_0   = class1048.StringReader.imethod_21((PagedMemoryStream)this.stream_1);
            }
            else
            {
                this.method_13(or.Builder.Version);
            }
            while (class1048.HandleReader.Stream.Position < class1048.HandleReader.Stream.Length)
            {
                ReferenceType           referenceType;
                ulong                   handle = class1048.HandleReader.imethod_34(0UL, true, out referenceType);
                DxfTypedObjectReference typedObjectReference = new DxfTypedObjectReference(referenceType);
                this.list_0.Add(typedObjectReference);
                objectBuilder.ChildBuilders.Add((Interface10)typedObjectReference.method_0(handle));
            }
        }
示例#5
0
        public override void CopyFrom(DxfHandledObject from, CloneContext cloneContext)
        {
            base.CopyFrom(from, cloneContext);
            DxfProxyEntity dxfProxyEntity = (DxfProxyEntity)from;

            this.dxfClass_0 = dxfProxyEntity.dxfClass_0 != null?Class906.smethod_9(cloneContext, dxfProxyEntity.dxfClass_0) : (DxfClass)null;

            this.proxyGraphics_0 = dxfProxyEntity.proxyGraphics_0 != null ? (ProxyGraphics)dxfProxyEntity.proxyGraphics_0.Clone(cloneContext) : (ProxyGraphics)null;
            this.dwgVersion_0    = dxfProxyEntity.dwgVersion_0;
            this.short_1         = dxfProxyEntity.short_1;
            this.bool_2          = dxfProxyEntity.bool_2;
            this.long_0          = dxfProxyEntity.long_0;
            if (dxfProxyEntity.stream_0 == null)
            {
                this.stream_0 = (Stream)null;
            }
            else
            {
                long position = dxfProxyEntity.stream_0.Position;
                dxfProxyEntity.stream_0.Position = 0L;
                this.stream_0 = (Stream) new PagedMemoryStream(dxfProxyEntity.stream_0, (long)(int)dxfProxyEntity.stream_0.Length);
                dxfProxyEntity.stream_0.Position = position;
            }
            this.uint_0 = dxfProxyEntity.uint_0;
            if (dxfProxyEntity.stream_1 == null)
            {
                this.stream_1 = (Stream)null;
            }
            else
            {
                long position = dxfProxyEntity.stream_1.Position;
                dxfProxyEntity.stream_1.Position = 0L;
                this.stream_1 = (Stream) new PagedMemoryStream(dxfProxyEntity.stream_1, (long)(int)dxfProxyEntity.stream_1.Length);
                dxfProxyEntity.stream_1.Position = position;
            }
            this.list_0.Clear();
            foreach (DxfTypedObjectReference typedObjectReference in dxfProxyEntity.list_0)
            {
                if (typedObjectReference.ObjectReference.Value == null)
                {
                    this.list_0.Add(new DxfTypedObjectReference(typedObjectReference.ReferenceType, DxfObjectReference.Null));
                }
                else
                {
                    this.list_0.Add(new DxfTypedObjectReference(typedObjectReference.ReferenceType, cloneContext.CloneReference((DxfHandledObject)typedObjectReference.ObjectReference.Value).Reference));
                }
            }
        }
示例#6
0
        private void RadBtn_Click(object sender, EventArgs e)
        {
            RadioButton RadBtn = sender as RadioButton;

            this.ClickRadBtnText = RadBtn.Tag.ToString();
            switch (this.ClickRadBtnText)
            {
            case "2004~2006":
                this.CurrentVer = DwgVersion.AC1021;
                break;

            default:
                this.CurrentVer = DwgVersion.AC1021;
                break;
            }
        }
示例#7
0
        public override bool ShowDialog()
        {
            using (SaveDXFForm form = new SaveDXFForm())
            {
                form.DXFVersion = version;

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(false);
                }

                version = form.DXFVersion;

                return(true);
            }
        }
示例#8
0
        private bool method_24(bool writeToDxf, DxfVersion fileVersion)
        {
            DwgVersion dwgVersion = Class885.smethod_3(fileVersion);

            if (writeToDxf != this.bool_2)
            {
                return(false);
            }
            if (this.dwgVersion_0 == dwgVersion)
            {
                return(true);
            }
            if (this.dwgVersion_0 < dwgVersion)
            {
                return(dwgVersion <= DwgVersion.Dwg1014);
            }
            return(false);
        }
示例#9
0
        public override bool ShowDialog()
        {
            using (SaveFileForm form = new SaveFileForm())
            {
                form.KeepCurrentDwgVersion = keepCurrentVersion;
                form.DwgVersion            = version;
                form.FilenameSuffix        = suffix;

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(false);
                }

                keepCurrentVersion = form.KeepCurrentDwgVersion;
                version            = form.DwgVersion;
                suffix             = form.FilenameSuffix;

                return(true);
            }
        }
示例#10
0
        private int ConvertDwgFile(string FilePath, DwgVersion Version)
        {
            Database db = new Database(false, true);

            try
            {
                db.ReadDwgFile(FilePath, FileOpenMode.OpenForReadAndReadShare, true, "");
                db.CloseInput(true);
                string FileName = Path.GetFileNameWithoutExtension(FilePath);
                db.SaveAs(FileName + "Converted", Version);
                return(1);
            }
            catch (System.NotImplementedException ex)
            {
                return(0);
            }
            catch
            {
                return(-1);
            }
        }
示例#11
0
 public Class362(
     DwgVersion version,
     long binaryDataSizeInBits,
     Interface30 binaryDataReader,
     uint stringDataSizeInBits,
     Interface30 stringDataReader,
     List <DxfTypedObjectReference> objectReferences)
 {
     this.long_0        = binaryDataSizeInBits;
     this.interface30_0 = binaryDataReader;
     if (version < DwgVersion.Dwg1021)
     {
         this.uint_0        = 0U;
         this.interface30_1 = binaryDataReader;
     }
     else
     {
         this.uint_0        = stringDataSizeInBits;
         this.interface30_1 = stringDataReader;
     }
     this.list_0 = objectReferences;
 }
示例#12
0
        private List <string> CanConvertVersion()
        {
            int           AcadVer    = Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
            List <string> CurrentVer = new List <string>();

            switch (AcadVer)
            {
            case 17:
                CurrentVer = DWGVersion.Take(1).ToList();
                break;

            case 18:
                CurrentVer = DWGVersion.Take(2).ToList();
                break;

            case 19:
                CurrentVer = DWGVersion.Take(3).ToList();
                break;

            case 20:
                CurrentVer = DWGVersion.Take(3).ToList();
                break;

            case 21:
                CurrentVer = DWGVersion.Take(3).ToList();
                break;

            case 22:
                CurrentVer = DWGVersion.Take(4).ToList();
                break;

            default:
                break;
            }
            return(CurrentVer);
        }
示例#13
0
文件: Class993.cs 项目: 15831944/WW
        public void Write()
        {
            Interface29 nterface29 = Class724.Create(this.dxfVersion_0, (Stream)this.memoryStream_0, this.encoding_0);

            nterface29.imethod_11(byte.MaxValue);
            nterface29.imethod_11((byte)119);
            nterface29.imethod_11((byte)1);
            DwgVersion dwgVersion = Class885.smethod_3(this.dxfModel_0.Header.AcadVersion);

            nterface29.imethod_18((short)dwgVersion);
            nterface29.imethod_18((short)this.dxfModel_0.Header.AcadMaintenanceVersion);
            nterface29.imethod_19(this.dxfModel_0.NumberOfSaves);
            nterface29.imethod_19(-1);
            short num1 = this.dxfModel_0.NumberOfSaves <= (int)short.MaxValue ? (short)0 : (short)(this.dxfModel_0.NumberOfSaves - (int)short.MaxValue);
            short num2 = (short)(this.dxfModel_0.NumberOfSaves - (int)num1);

            nterface29.imethod_18(num2);
            nterface29.imethod_18(num1);
            nterface29.imethod_19(0);
            nterface29.imethod_18((short)dwgVersion);
            nterface29.imethod_18((short)this.dxfModel_0.Header.AcadMaintenanceVersion);
            nterface29.imethod_18((short)dwgVersion);
            nterface29.imethod_18((short)this.dxfModel_0.Header.AcadMaintenanceVersion);
            nterface29.imethod_18((short)5);
            nterface29.imethod_18((short)2195);
            nterface29.imethod_18((short)5);
            nterface29.imethod_18((short)2195);
            nterface29.imethod_18((short)0);
            nterface29.imethod_18((short)1);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            int days1;
            int milliseconds1;

            Class644.smethod_1(this.dxfModel_0.Header.CreateDateTime, out days1, out milliseconds1);
            nterface29.imethod_19(days1);
            nterface29.imethod_19(milliseconds1);
            int days2;
            int milliseconds2;

            Class644.smethod_1(this.dxfModel_0.Header.UpdateDateTime, out days2, out milliseconds2);
            nterface29.imethod_19(days2);
            nterface29.imethod_19(milliseconds2);
            int num3 = -1;

            if (this.dxfModel_0.Header.HandleSeed <= (ulong)int.MaxValue)
            {
                num3 = (int)this.dxfModel_0.Header.HandleSeed;
            }
            nterface29.imethod_19(num3);
            nterface29.imethod_19(0);
            nterface29.imethod_18((short)0);
            nterface29.imethod_18((short)((int)num2 - (int)num1));
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(this.dxfModel_0.NumberOfSaves);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
            nterface29.imethod_19(0);
        }
示例#14
0
        private void method_18(DxfReader r, Class259 objectBuilder)
        {
            this.bool_2 = true;
            DxfVersion version = r.ModelBuilder.Version;

            this.dwgVersion_0 = Class885.smethod_3(version);
            if (this.stream_0 == null)
            {
                this.stream_0 = (Stream) new PagedMemoryStream(1024L, 1024);
            }
            if (this.dwgVersion_0 > DwgVersion.Dwg1018 && this.stream_1 == null)
            {
                this.stream_1 = (Stream) new PagedMemoryStream(1024L, 1024);
            }
            r.method_85();
            Encoding    encoding   = Encodings.GetEncoding((int)r.Model.Header.DrawingCodePage);
            Interface40 nterface40 = (Interface40) new Class725(this.stream_0, encoding, version);

            DxfProxyEntity.Class361 class361 = new DxfProxyEntity.Class361((Interface29) new Class990((Stream)null, nterface40, this.dwgVersion_0 > DwgVersion.Dwg1018 ? (Interface40) new Class728(this.stream_1, encoding, version) : nterface40, nterface40));
            while (r.CurrentGroup.Code != 0)
            {
                switch (Class820.smethod_2(r.CurrentGroup.Code))
                {
                case Enum5.const_8:
                case Enum5.const_9:
                case Enum5.const_14:
                case Enum5.const_15:
                    ulong            handle           = (ulong)r.CurrentGroup.Value;
                    DxfHandledObject dxfHandledObject = new DxfHandledObject();
                    dxfHandledObject.SetHandle(handle);
                    DxfObjectReference dxfObjectReference = new DxfObjectReference((IDxfHandledObject)dxfHandledObject);
                    Struct18           group1             = new Struct18(r.CurrentGroup.Code, (object)dxfObjectReference);
                    class361.imethod_0(group1);
                    r.method_85();
                    continue;

                case Enum5.const_13:
                    int             code    = r.CurrentGroup.Code;
                    WW.Math.Point3D point3D = new WW.Math.Point3D((double)r.CurrentGroup.Value, 0.0, 0.0);
                    r.method_85();
                    if (r.CurrentGroup.Code == code + 10)
                    {
                        point3D.Y = (double)r.CurrentGroup.Value;
                        r.method_85();
                        if (r.CurrentGroup.Code == code + 20)
                        {
                            point3D.Z = (double)r.CurrentGroup.Value;
                            r.method_85();
                        }
                    }
                    Struct18 group2 = new Struct18(code, (object)point3D);
                    class361.imethod_0(group2);
                    continue;

                default:
                    class361.imethod_0(r.CurrentGroup);
                    r.method_85();
                    continue;
                }
            }
        }
示例#15
0
        private bool method_17(
            DxfReader r,
            Class285 objectBuilder,
            ref long graphicsDataSizeInBytes,
            ref PagedMemoryStream graphicsData,
            ref Stream currentStream)
        {
            switch (r.CurrentGroup.Code)
            {
            case 1:
                string cPlusPlusClassName = (string)r.CurrentGroup.Value;
                this.dxfClass_0 = r.Model.Classes.GetClassWithCPlusPlusName(cPlusPlusClassName);
                break;

            case 70:
                this.bool_2 = (short)r.CurrentGroup.Value != (short)0;
                break;

            case 90:
                int num1 = (int)r.CurrentGroup.Value;
                break;

            case 91:
                int num2 = (int)r.CurrentGroup.Value;
                this.dxfClass_0 = r.Model.Classes.GetClassWithClassNumber((short)num2);
                break;

            case 92:
                graphicsDataSizeInBytes = (long)(int)r.CurrentGroup.Value;
                if (graphicsData == null)
                {
                    graphicsData = new PagedMemoryStream((long)(int)graphicsDataSizeInBytes, System.Math.Min((int)graphicsDataSizeInBytes, 65536));
                }
                else
                {
                    graphicsData.SetLength(graphicsDataSizeInBytes);
                }
                currentStream = (Stream)graphicsData;
                break;

            case 93:
                this.long_0 = (long)(int)r.CurrentGroup.Value;
                if (this.long_0 != 0L)
                {
                    int val1 = (int)this.long_0 + 7 >> 3;
                    if (this.stream_0 == null)
                    {
                        this.stream_0 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536));
                    }
                    else
                    {
                        this.stream_0.SetLength((long)val1);
                    }
                }
                currentStream = this.stream_0;
                break;

            case 94:
                int num3 = (int)r.CurrentGroup.Value;
                break;

            case 95:
                int num4 = (int)r.CurrentGroup.Value;
                this.dwgVersion_0 = (DwgVersion)(num4 & (int)ushort.MaxValue);
                this.short_1      = (short)(num4 >> 16);
                break;

            case 96:
                this.uint_0 = (uint)(int)r.CurrentGroup.Value;
                if (this.uint_0 != 0U)
                {
                    int val1 = (int)(this.uint_0 + 7U >> 3);
                    if (this.stream_1 == null)
                    {
                        this.stream_1 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536));
                    }
                    else
                    {
                        this.stream_1.SetLength((long)val1);
                    }
                }
                currentStream = this.stream_1;
                break;

            case 160:
                graphicsDataSizeInBytes = (long)r.CurrentGroup.Value;
                if (graphicsData == null)
                {
                    graphicsData = new PagedMemoryStream((long)(int)graphicsDataSizeInBytes, System.Math.Min((int)graphicsDataSizeInBytes, 65536));
                }
                else
                {
                    graphicsData.SetLength(graphicsDataSizeInBytes);
                }
                currentStream = (Stream)graphicsData;
                break;

            case 161:
                this.long_0 = (long)r.CurrentGroup.Value;
                if (this.long_0 != 0L)
                {
                    int val1 = (int)this.long_0 + 7 >> 3;
                    if (this.stream_0 == null)
                    {
                        this.stream_0 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536));
                    }
                    else
                    {
                        this.stream_0.SetLength((long)val1);
                    }
                }
                currentStream = this.stream_0;
                break;

            case 162:
                this.uint_0 = (uint)(long)r.CurrentGroup.Value;
                if (this.uint_0 != 0U)
                {
                    int val1 = (int)this.uint_0 + 7 >> 3;
                    if (this.stream_1 == null)
                    {
                        this.stream_1 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536));
                    }
                    else
                    {
                        this.stream_1.SetLength((long)val1);
                    }
                }
                currentStream = this.stream_1;
                break;

            case 310:
                if (currentStream == null)
                {
                    throw new Exception("No stream size specified.");
                }
                byte[] buffer1 = (byte[])r.CurrentGroup.Value;
                currentStream.Write(buffer1, 0, buffer1.Length);
                break;

            case 311:
                if (currentStream == null)
                {
                    throw new Exception("No stream size specified.");
                }
                if (currentStream != this.stream_1)
                {
                    throw new Exception("Wrong stream");
                }
                byte[] buffer2 = (byte[])r.CurrentGroup.Value;
                currentStream.Write(buffer2, 0, buffer2.Length);
                break;

            case 330:
                this.method_19(r, (Class259)objectBuilder, ReferenceType.SoftPointerReference);
                break;

            case 340:
                this.method_19(r, (Class259)objectBuilder, ReferenceType.HardPointerReference);
                break;

            case 350:
                this.method_19(r, (Class259)objectBuilder, ReferenceType.SoftOwnershipReference);
                break;

            case 360:
                this.method_19(r, (Class259)objectBuilder, ReferenceType.HardOwnershipReference);
                break;

            default:
                return(this.method_9(r, objectBuilder));
            }
            r.method_85();
            return(true);
        }
示例#16
0
 public virtual DecomposeForSaveReplacementRecord DecomposeForSave(DwgVersion version)
 {
     createInstance();
     DecomposeForSaveReplacementRecord DecomposeForS = BaseDBObject.DecomposeForSave(version);
     tr.Dispose();
     return DecomposeForS;
 }
示例#17
0
 /// <summary>
 /// Save and close database.
 /// </summary>
 /// <param name="database">The dwg database</param>
 public static void SaveAsAndCloseDwg(Database database, string filename, DwgVersion dwgVersion)
 {
     database.SaveAs(filename, dwgVersion);
     CloseDwg(database);
 }
示例#18
0
 /// <summary>
 /// 另存为
 /// </summary>
 /// <param name="path">保存路径</param>
 /// <param name="version">DWG版本</param>
 public void SaveAs(string path, DwgVersion version)
 {
     database.SaveAs(path, version);
 }
示例#19
0
        static int Main(string[] args)
        {
            int nRes = 0; // Return value for main

            /**********************************************************************/
            /* Set command line defaults                                          */
            /**********************************************************************/
            SaveType   fileType    = SaveType.Save12;
            DwgVersion outVer      = DwgVersion.AC1021;
            bool       disableWait = false;

            /**********************************************************************/
            /* Initialize Teigha                                                  */
            /**********************************************************************/
            using (Services svcs = new Services())
            {
                /**********************************************************************/
                /* Display the Product and Version that created the executable        */
                /**********************************************************************/
                Console.WriteLine("\nOdWriteEx developed using %ls ver %ls");

                /**********************************************************************/
                /* Parse Command Line inputs                                          */
                /**********************************************************************/
                bool bInvalidArgs = (args.Length < 2);
                if (bInvalidArgs)
                {
                    bInvalidArgs = true;
                    nRes         = 1;
                }

                /**********************************************************************/
                /* Set file version                                                   */
                /**********************************************************************/
                if (args.Length >= 2)
                {
                    string argv2 = args[1];
                    switch (argv2)
                    {
                    case "ACAD12":
                        outVer = DwgVersion.vAC12;
                        break;

                    case "ACAD13":
                        outVer = DwgVersion.vAC13;
                        break;

                    case "ACAD14":
                        outVer = DwgVersion.vAC14;
                        break;

                    case "ACAD2000":
                        outVer = DwgVersion.vAC15;
                        break;

                    case "ACAD2004":
                        outVer = DwgVersion.vAC18;
                        break;

                    case "ACAD2007":
                        outVer = DwgVersion.vAC21;
                        break;

                    case "ACAD2010":
                        outVer = DwgVersion.vAC24;
                        break;

                    default:
                        bInvalidArgs = true;
                        nRes         = 1;
                        break;
                    }
                }

                /**********************************************************************/
                /* Set file type                                                      */
                /**********************************************************************/
                if (args.Length >= 3)
                {
                    string argv3 = args[2];
                    switch (argv3)
                    {
                    case "DWG":
                        fileType = SaveType.Save12;
                        break;

                    case "DXF":
                        fileType = SaveType.Save13;
                        break;

                    default:
                        bInvalidArgs = true;
                        nRes         = 1;
                        break;
                    }
                }

                /**********************************************************************/
                /* Disable prompt of pressing ENTER                                   */
                /**********************************************************************/
                if (args.Length >= 4)
                {
                    string argv4 = args[3];
                    if (argv4 == "-NoWait")
                    {
                        disableWait = true;
                    }
                }

                if (bInvalidArgs)
                {
                    Console.WriteLine("\n\n\tusage: OdWriteEx <filename> [OutVer] [OutType] [-NoWait]");
                    Console.WriteLine("\n\tOutVer can be any of ACAD12, ACAD13, ACAD14, ACAD2000, ACAD2004, ACAD2007, ACAD2010\n");
                    Console.WriteLine("\n\tOutType can be any of DWG, DXF\n");
                    Console.WriteLine("\n\t-NoWait disables prompt of pressing ENTER at the end of execution.\n");
                    return(nRes);
                }

                /**********************************************************************/
                /* Load and Release RecomputeDimBlock                                 */
                /**********************************************************************/
                //::odrxDynamicLinker()->loadApp(TD_T("RecomputeDimBlock")).release();
                //::odrxDynamicLinker()->loadApp(TD_T("ExFieldEvaluator")).release();

                /**********************************************************************/
                /* Find the folder of the output file                                 */
                /**********************************************************************/
                string outputFolder = args[0];
                outputFolder = Path.GetDirectoryName(outputFolder);
                FileStreamBuf fileBuf = new FileStreamBuf(args[0], false, FileShareMode.DenyNo, FileCreationDisposition.CreateAlways);

                try
                {
                    /********************************************************************/
                    /* Create a default OdDbDatabase object                             */
                    /********************************************************************/
                    using (Database pDb = new Database())
                    {
                        DatabaseSummaryInfo        pSumInfo = pDb.SummaryInfo;
                        DatabaseSummaryInfoBuilder builder  = new DatabaseSummaryInfoBuilder(pSumInfo);
                        builder.Title    = "Title";
                        builder.Author   = "Author";
                        builder.Comments = "Comments";
                        builder.Comments = "File was created by OdWriteEx";
                        pDb.SummaryInfo  = builder.ToDatabaseSummaryInfo();

                        /********************************************************************/
                        /* Fill the database                                                */
                        /********************************************************************/
                        HostApplicationServices.WorkingDatabase = pDb;
                        DbFiller filler = new DbFiller();
                        filler.fillDatabase(pDb);

                        /********************************************************************/
                        /* Audit the database                                               */
                        /********************************************************************/
                        using (AuditInfo aiAppAudit = new CustomAuditInfo(outputFolder + "AuditReport.txt"))
                        {
                            aiAppAudit.FixErrors = true;
                            Console.WriteLine("\n\n");
                            pDb.Audit(aiAppAudit);
                        }
                        #region TODO block
                        //{
                        //  OdSecurityParams securityParams;
                        //  securityParams.password = "******";
                        //  securityParams.nFlags = 1;
                        //  securityParams.nProvType = 0xd;

                        //  // L"Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"
                        //  static wchar_t pn[] =
                        //  {
                        //    0x4D, 0x69, 0x63, 0x72, 0x6F,
                        //    0x73, 0x6F, 0x66, 0x74, 0x20,
                        //    0x42, 0x61, 0x73, 0x65, 0x20,
                        //    0x44, 0x53, 0x53, 0x20, 0x61,
                        //    0x6E, 0x64, 0x20, 0x44, 0x69,
                        //    0x66, 0x66, 0x69, 0x65, 0x2D,
                        //    0x48, 0x65, 0x6C, 0x6C, 0x6D,
                        //    0x61, 0x6E, 0x20, 0x43, 0x72,
                        //    0x79, 0x70, 0x74, 0x6F, 0x67,
                        //    0x72, 0x61, 0x70, 0x68, 0x69,
                        //    0x63, 0x20, 0x50, 0x72, 0x6F,
                        //    0x76, 0x69, 0x64, 0x65, 0x72,
                        //    0x00
                        //  };
                        //  securityParams.provName = pn;

                        //  /************************************************************************/
                        //  /* Uncomment the following line to add the password TD_T("Teigha") to the  */
                        //  /* R18+ file to be created                                              */
                        //  /************************************************************************/
                        //  //pDb->setSecurityParams(securityParams);
                        //}
                        #endregion
                        /********************************************************************/
                        /* Write the database                                               */
                        /********************************************************************/
                        pDb.SaveAs(fileBuf, fileType, outVer, true, 16);

                        /*if (SaveType.Save12 == fileType)
                         * {
                         * pDb.SaveAs(args[0], outVer);
                         * }
                         * else
                         * pDb.DxfOut(args[0], 16, outVer);//16 - default*/
                        Console.WriteLine("\nDatabase has been saved as {0}", pDb.Filename);
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine("\n\nError: {0}", e.Message);
                    nRes = -1;
                }
            }

            if (nRes != 0)
            {
                Console.WriteLine("\n\nPress ENTER to continue...");
                if (!disableWait)
                {
                    Console.ReadLine();
                }
            }
            Console.WriteLine("\n\n");
            return(nRes);
        }