Active Contributor LE3
Active Contributor
Posts: 30
Registered: ‎06-07-2004
Message 1 of 1 (251 Views)

RealDWG 2013 *bug* ?

251 Views, 0 Replies
05-14-2012 08:06 AM

We are getting an error (see attached image) using RealDWG 2013 on this test function below note the same code as-is works in RealDWG 2009 - the DW1645ASY.dwg it is a drawing made of 3D solids, if we try this with a drawing without 3D solids sometimes it will work and others not - Any ideas? or Help that I can get about this? - Thanks:


        public static void Draw(string outputFile)
            string acadTemplateFile = @"C:\hotfiles\CAD_Templates\Common\acad.dwt";
            using (Host host = new Host())
                using (Autodesk.AutoCAD.DatabaseServices.Database db = new Autodesk.AutoCAD.DatabaseServices.Database(false, true))
                    File.Copy(acadTemplateFile, outputFile, false);
                    db.ReadDwgFile(outputFile, System.IO.FileShare.ReadWrite, false, null);
                    HostApplicationServices.WorkingDatabase = db;

                    using (Transaction tr = db.TransactionManager.StartTransaction())
                        BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                        BlockTableRecord iModelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                        ObjectId blockId = ObjectId.Null;

                        using (Transaction tran = db.TransactionManager.StartTransaction())
                            using (Autodesk.AutoCAD.DatabaseServices.Database sdb = new Autodesk.AutoCAD.DatabaseServices.Database(false, true))
                                string file = @"C:\hotfiles\CAD_Templates\Ductwork\3D\Elbow 45\DW1645ASY.dwg";
                                sdb.ReadDwgFile(file, System.IO.FileShare.ReadWrite, false, "");

                                blockId = db.Insert(file, sdb, true);
                            HostApplicationServices.WorkingDatabase = db;


                        BlockReference blockRef = new BlockReference(Point3d.Origin, blockId);
                        tr.AddNewlyCreatedDBObject(blockRef, true);


                    db.SaveAs(outputFile, DwgVersion.AC1015);

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.