public static string AssignWKT(Document doc, string wktString)
        {
            if (string.IsNullOrEmpty(wktString))
            {
                return(wktString);
            }
            if (wktString == "<Undefined>")
            {
                return(wktString);
            }
            if (MSCPrj.IsWKID(wktString))
            {
                return("");
            }
            string result;

            try
            {
                using (doc.LockDocument((DocumentLockMode)20, null, null, false))
                {
                    using (Transaction transaction = doc.Database.TransactionManager.StartTransaction())
                    {
                        Database   database   = doc.Database;
                        Xrecord    xrecord    = new Xrecord();
                        TypedValue typedValue = new TypedValue(1, wktString);
                        xrecord.Data = (new ResultBuffer(new TypedValue[]
                        {
                            typedValue
                        }));
                        DBDictionary dBDictionary = (DBDictionary)transaction.GetObject(database.NamedObjectsDictionaryId, (OpenMode)1, false);
                        ObjectId     acadId       = dBDictionary.SetAt("ESRI_PRJ", xrecord);
                        xrecord.DisableUndoRecording(true);
                        transaction.AddNewlyCreatedDBObject(xrecord, true);
                        transaction.Commit();
                        AfaDocData.ActiveDocData.DocPRJ.WKT    = wktString;
                        AfaDocData.ActiveDocData.DocPRJ.AcadId = acadId;
                        foreach (MSCMapService current in AfaDocData.ActiveDocData.DocDataset.MapServices.Values)
                        {
                            current.RefreshConnectedService();
                        }
                        foreach (MSCImageService current2 in AfaDocData.ActiveDocData.DocDataset.ImageServices.Values)
                        {
                            current2.RefreshConnectedService();
                        }
                        result = wktString;
                    }
                }
            }
            catch (SystemException ex)
            {
                string arg_186_0 = ex.Message;
                result = "";
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex2)
            {
                string arg_199_0 = ex2.Message;
                result = "";
            }
            return(result);
        }
Exemplo n.º 2
0
        protected void WriteTypedValue(Database db, Transaction t, DBDictionary dict, string key, TypedValue tv)
        {
            Xrecord xrecord = new Xrecord();

            xrecord.Data = (new ResultBuffer(new TypedValue[]
            {
                tv
            }));
            dict.SetAt(key, xrecord);
            xrecord.DisableUndoRecording(true);
            t.AddNewlyCreatedDBObject(xrecord, true);
        }
Exemplo n.º 3
0
 protected void WriteResultBuffer(Database db, Transaction t, DBDictionary dict, string key, ResultBuffer rb)
 {
     try
     {
         Xrecord xrecord = new Xrecord();
         xrecord.Data = (rb);
         dict.SetAt(key, xrecord);
         xrecord.DisableUndoRecording(true);
         t.AddNewlyCreatedDBObject(xrecord, true);
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        protected DBDictionary WriteImageDictionary(DBDictionary parentDict, Transaction t)
        {
            DBDictionary result;

            try
            {
                parentDict.UpgradeOpen();
                DBDictionary dBDictionary = new DBDictionary();
                this.AcadDictionaryID = parentDict.SetAt(base.Name, dBDictionary);
                dBDictionary.DisableUndoRecording(true);
                t.AddNewlyCreatedDBObject(dBDictionary, true);
                DocUtil.WriteXRecord(t, dBDictionary, "AutoCADID", (DxfCode)330, base.RasterObjectId);
                DocUtil.WriteXRecord(t, dBDictionary, "ServiceFullName", (DxfCode)1, this.ServiceFullName);
                DocUtil.WriteXRecord(t, dBDictionary, "ConnectionName", (DxfCode)1, base.ConnectionName);
                DocUtil.WriteXRecord(t, dBDictionary, "ConnectionURL", (DxfCode)1, base.ConnectionURL);
                DocUtil.WriteXRecord(t, dBDictionary, "UserName", (DxfCode)1, base.UserName);
                if (base.Dynamic)
                {
                    Xrecord xrecord = new Xrecord();
                    xrecord.Data = (new ResultBuffer(new TypedValue[]
                    {
                        new TypedValue(290, true)
                    }));
                    dBDictionary.SetAt("Dynamic", xrecord);
                    xrecord.DisableUndoRecording(true);
                    t.AddNewlyCreatedDBObject(xrecord, true);
                }
                DocUtil.WriteBoundingBox(t, dBDictionary, base.BoundaryExtent);
                DocUtil.WriteXRecord(t, dBDictionary, "ImageFormat", (DxfCode)1, base.ExportOptions.Format);
                DocUtil.WriteXRecord(t, dBDictionary, "Compression", (DxfCode)1, base.ExportOptions.TransCompression);
                DocUtil.WriteXRecord(t, dBDictionary, "Quality", (DxfCode)90, base.ExportOptions.Quality);
                DocUtil.WriteXRecord(t, dBDictionary, "Interpolation", (DxfCode)1, base.ExportOptions.Interpolation);
                DocUtil.WriteXRecord(t, dBDictionary, "MosaicMethod", (DxfCode)1, base.ExportOptions.MosaicMethod);
                DocUtil.WriteXRecord(t, dBDictionary, "OrderField", (DxfCode)1, base.ExportOptions.OrderField);
                DocUtil.WriteXRecord(t, dBDictionary, "OrderBaseValue", (DxfCode)1, base.ExportOptions.OrderBaseValue);
                DocUtil.WriteXRecord(t, dBDictionary, "LockRasterID", (DxfCode)1, base.ExportOptions.LockRasterID);
                DocUtil.WriteXRecord(t, dBDictionary, "Ascending", (DxfCode)290, base.ExportOptions.Ascending);
                DocUtil.WriteXRecord(t, dBDictionary, "MosaicOperator", (DxfCode)1, base.ExportOptions.MosaicOperator);
                result = dBDictionary;
            }
            catch (Exception ex)
            {
                string arg_209_0 = ex.Message;
                result = null;
            }
            return(result);
        }
Exemplo n.º 5
0
        public DBDictionary WriteMapLayer(DBDictionary parentDict, Transaction t)
        {
            DBDictionary dBDictionary = new DBDictionary();

            try
            {
                parentDict.SetAt(this.FixName(this.Name), dBDictionary);
                dBDictionary.DisableUndoRecording(true);
                t.AddNewlyCreatedDBObject(dBDictionary, true);
                DocUtil.WriteXRecord(t, dBDictionary, "MapLayerName", (DxfCode)1, this.Name);
                DocUtil.WriteXRecord(t, dBDictionary, "ID", (DxfCode)90, this.ID);
                DocUtil.WriteXRecord(t, dBDictionary, "ParentID", (DxfCode)90, this.ParentLayerID);
                if (this.Visible)
                {
                    Xrecord xrecord = new Xrecord();
                    xrecord.Data = (new ResultBuffer(new TypedValue[]
                    {
                        new TypedValue(290, true)
                    }));
                    dBDictionary.SetAt("Visible", xrecord);
                    xrecord.DisableUndoRecording(true);
                    t.AddNewlyCreatedDBObject(xrecord, true);
                }
            }
            catch
            {
            }
            try
            {
                if (this.Layers != null && this.Layers.Count > 0)
                {
                    DBDictionary dBDictionary2 = new DBDictionary();
                    dBDictionary.SetAt("ChildLayers", dBDictionary2);
                    t.AddNewlyCreatedDBObject(dBDictionary2, true);
                    foreach (MSCMapLayer current in this.Layers)
                    {
                        current.WriteMapLayer(dBDictionary2, t);
                    }
                }
            }
            catch
            {
            }
            return(dBDictionary);
        }
        protected DBDictionary WriteMapDictionary(DBDictionary parentDict, Transaction t)
        {
            DBDictionary result;

            try
            {
                parentDict.UpgradeOpen();
                DBDictionary dBDictionary = new DBDictionary();
                this.AcadDictionaryID = parentDict.SetAt(base.Name, dBDictionary);
                dBDictionary.DisableUndoRecording(true);
                t.AddNewlyCreatedDBObject(dBDictionary, true);
                DocUtil.WriteXRecord(t, dBDictionary, "AutoCADID", (DxfCode)330, base.RasterObjectId);
                DocUtil.WriteXRecord(t, dBDictionary, "ServiceFullName", (DxfCode)1, this.ServiceFullName);
                DocUtil.WriteXRecord(t, dBDictionary, "ConnectionName", (DxfCode)1, base.ConnectionName);
                DocUtil.WriteXRecord(t, dBDictionary, "ConnectionURL", (DxfCode)1, base.ConnectionURL);
                DocUtil.WriteXRecord(t, dBDictionary, "UserName", (DxfCode)1, base.UserName);
                if (base.Dynamic)
                {
                    Xrecord xrecord = new Xrecord();
                    xrecord.Data = (new ResultBuffer(new TypedValue[]
                    {
                        new TypedValue(290, true)
                    }));
                    dBDictionary.SetAt("Dynamic", xrecord);
                    xrecord.DisableUndoRecording(true);
                    t.AddNewlyCreatedDBObject(xrecord, true);
                }
                DocUtil.WriteBoundingBox(t, dBDictionary, base.BoundaryExtent);
                DocUtil.WriteXRecord(t, dBDictionary, "ImageFormat", (DxfCode)1, base.ExportOptions.Format);
                result = dBDictionary;
            }
            catch (Exception ex)
            {
                string arg_122_0 = ex.Message;
                result = null;
            }
            return(result);
        }