Пример #1
0
        public static TypedValue ProxyExplodeToBlock(ResultBuffer rbArgs)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            TypedValue res = new TypedValue((int)LispDataType.Text,"");

            if (rbArgs.AsArray().Length == 2)
            {
                TypedValue entity = rbArgs.AsArray()[0];
                TypedValue blkPrefix = rbArgs.AsArray()[1];

                if ((entity.TypeCode == (int)LispDataType.ObjectId) && (blkPrefix.TypeCode == (int)LispDataType.Text))
                {
                    using (Transaction tr = doc.TransactionManager.StartTransaction())
                    {
                        try
                        {
                            ObjectId id = (ObjectId)entity.Value;
                            DBObjectCollection objs = new DBObjectCollection();
                            BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                            Entity entx = (Entity)tr.GetObject(id, OpenMode.ForWrite);
                            entx.Explode(objs);

                            string blkName = blkPrefix.Value.ToString() + entx.Handle.ToString();

                            if (bt.Has(blkName) == false)
                            {
                                BlockTableRecord btr = new BlockTableRecord();
                                btr.Name = blkName;

                                bt.UpgradeOpen();
                                ObjectId btrId = bt.Add(btr);
                                tr.AddNewlyCreatedDBObject(btr, true);

                                foreach (DBObject obj in objs)
                                {
                                    Entity ent = (Entity)obj;
                                    btr.AppendEntity(ent);
                                    tr.AddNewlyCreatedDBObject(ent, true);
                                }
                            }
                            res = new TypedValue((int)LispDataType.Text, blkName);

                            tr.Commit();
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception ex)
                        {
                            tr.Abort();
                            ed.WriteMessage(ex.Message);
                        }
                    }
                }
            }
            return res;
        }
Пример #2
0
        public ResultBuffer RubyLoadLISP(ResultBuffer rb)
        {
            const int RTSTR = 5005;

              Document doc = Application.DocumentManager.MdiActiveDocument;
              Editor ed = doc.Editor;

              if (rb == null)
              {
            ed.WriteMessage("\nError: too few arguments\n");
              }
              else
              {
            Array args = rb.AsArray();
            TypedValue tv = (TypedValue)args.GetValue(0);

            if (tv != null && tv.TypeCode == RTSTR)
            {
              bool success =
            ExecuteRubyScript(Convert.ToString(tv.Value));
              return
            (success
              ? new ResultBuffer(new TypedValue(RTSTR, tv.Value))
              : null);
            }
              }
              return null;
        }
Пример #3
0
        public ResultBuffer DeleteDocumentLisp(ResultBuffer incomingBuffer)
        {
            var result = false;

            var documentId = incomingBuffer
                             ?.AsArray()
                             .FirstOrDefault(_ => _.TypeCode == (short)LispDataType.Text)
                             .Value
                             ?.ToString();

            if (!string.IsNullOrWhiteSpace(documentId))
            {
                result = CommandHandlerFactory
                         .Instance
                         .GetDeleteDocumentHandler()
                         .Delete(documentId);
            }
            else
            {
                result = CommandHandlerFactory
                         .Instance
                         .GetDeleteDocumentHandler()
                         .Delete();
            }

            return(new ResultBuffer(new TypedValue(result ? (int)LispDataType.T_atom : (int)LispDataType.Nil)));
        }
Пример #4
0
        public static void ProxyExplodeInPlace(ResultBuffer rbArgs)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            if (rbArgs.AsArray().Length == 1)
            {
                TypedValue entity = rbArgs.AsArray().First();

                if (entity.TypeCode == (int)LispDataType.ObjectId)
                {
                    using (Transaction tr = doc.TransactionManager.StartTransaction())
                    {
                        try
                        {
                            ObjectId id = (ObjectId)entity.Value;
                            DBObjectCollection objs = new DBObjectCollection();
                            BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                            Entity entx = (Entity)tr.GetObject(id, OpenMode.ForWrite);
                            entx.Explode(objs);

                            entx.Erase();

                            BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                            foreach (DBObject obj in objs)
                            {
                                Entity ent = (Entity)obj;
                                btr.AppendEntity(ent);
                                tr.AddNewlyCreatedDBObject(ent, true);
                            }

                            tr.Commit();
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception ex)
                        {
                            tr.Abort();
                            ed.WriteMessage(ex.Message);
                        }
                    }
                }
            }
        }
        public object ESRI_RemoveConnection(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 1)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string b = typedValue.Value.ToString();
                        if (!AGSConnection.bConnectionsLoaded)
                        {
                            AGSConnection.LoadConnections();
                        }
                        if (App.Connections.Count > 0)
                        {
                            foreach (AGSConnection current in App.Connections)
                            {
                                if (string.Equals(current.Name, b, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    App.Connections.Remove(current);
                                    current.RemoveFile();
                                    result = LspUtil.LispTrue;
                                    return(result);
                                }
                            }
                        }
                        result = null;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Пример #6
0
        /// <summary>
        /// Получить расширенные данные подписи объекта
        /// Предполагается, что в самом объекте будет храниться только одна строковая ячейка расширенных данных
        /// Если потребуется хранение большего объема информации необходимо использовать CreateExtensionDictionary и Xrecord
        /// (http://forums.augi.com/showthread.php?107513-C-sample-attaching-XRecord-to-a-graphical-object)
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public static string GetCaptionFromXData(Entity ent)
        {
            string       returnVal = null;
            ResultBuffer buffer    = ent.GetXDataForApplication(Constants.AppName);

            if (buffer != null)
            {
                List <TypedValue> xdataList       = new List <TypedValue>(buffer.AsArray());
                List <TypedValue> xdataStringList = xdataList.FindAll(x => x.TypeCode == 1000);
                if (xdataStringList.Count > 0)
                {
                    returnVal = (string)xdataStringList[0].Value;
                }
            }
            return(returnVal);
        }
Пример #7
0
 public void MenuLoadSwitch(ResultBuffer rbArgs)
 {
     if (rbArgs != null && rbArgs.AsArray().Length == 2)
     {
         List <string> args = new List <string>();
         foreach (TypedValue rb in rbArgs)
         {
             args.Add(rb.Value.ToString());
         }
         string strVal1 = args[0]; //Menu Name
         string strVal2 = args[1]; //File Name
         if (strVal1 != "" && strVal2 != "")
         {
         }
     }
 }
 // Token: 0x060000C6 RID: 198 RVA: 0x0000A180 File Offset: 0x00008380
 internal TypedValue[] b(DBObject A_0)
 {
     TypedValue[] result;
     using (ResultBuffer xdataForApplication = A_0.GetXDataForApplication(this.XDAppName))
     {
         if (xdataForApplication != null)
         {
             result = xdataForApplication.AsArray();
         }
         else
         {
             result = new TypedValue[1];
         }
     }
     return(result);
 }
Пример #9
0
        private static ResultBuffer LoadAssembly(ResultBuffer rbArgs)
        {
            ResultBuffer result = null;

            try
            {
                TypedValue[] args = rbArgs.AsArray();
                var          asm  = System.Reflection.Assembly.LoadFrom(args[0].Value.ToString());
                result.Add(new TypedValue(0x138D, "OK"));
            }
            catch
            {
                result.Add(new TypedValue(0x138D, "Catch Error"));
            }
            return(result);
        }
Пример #10
0
        static public ResultBuffer getexpirationdate_net(ResultBuffer args)
        {
            if (args == null)
            {
                throw new ArgumentException("No arguments provided.");
            }

            Array argsArray = null;

            argsArray = args.AsArray();

            if (argsArray.Length == 0)
            {
                throw new ArgumentException("No arguments provided.");
            }

            string rsaPublicKey = (string)((TypedValue)argsArray.GetValue(0)).Value;
            string pathToFile   = (string)((TypedValue)argsArray.GetValue(1)).Value;

            var license = new LicenseKey().LoadFromFile(pathToFile).HasValidSignature(rsaPublicKey);

            if (license != null && license.MaxNoOfMachines > 0)
            {
                // check the machine code too only if node-locking is enabled.
                if (!Helpers.IsOnRightMachinePI(license, false, false))
                {
                    return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32), -1)));
                }
            }

            if (!license.IsValid())
            {
                return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32), -1)));
            }

            if (license != null && license.MaxNoOfMachines > 0)
            {
                // check the machine code too only if node-locking is enabled.
                if (!Helpers.IsOnRightMachinePI(license, false, false))
                {
                    return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32), -1)));
                }
            }

            return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32),
                                                   (Int32)license.Expires.Subtract(new DateTime(1970, 1, 1)).TotalSeconds)));
        }
            public static MemoryStream ResBufToStream(ResultBuffer resBuf)
            {
                var ms     = new MemoryStream();
                var values = resBuf.AsArray();

                // Start from 1 to skip application name

                for (var i = 1; i < values.Length; i++)
                {
                    var datachunk = (byte[])values[i].Value;
                    ms.Write(datachunk, 0, datachunk.Length);
                }

                ms.Position = 0;

                return(ms);
            }
Пример #12
0
        public static List <ProfileObject> ReadFromNod()
        {
            Editor      ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            Transaction trans = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction();

            List <ProfileObject> profileObjects = new List <ProfileObject>();

            using (trans)
            {
                try
                {
                    foreach (DBDictionaryEntry entry in AppDictionary)
                    {
                        // check to see if our entry is in there, excpetion will be thrown if not so process that
                        // condition in the catch
                        ObjectId entryId = entry.m_value;
                        //create xrecord
                        Xrecord xrecord = default(Xrecord);

                        //read it from the AppDirectory
                        xrecord = (Xrecord)trans.GetObject(entryId, OpenMode.ForRead);

                        //get the data from xrecord
                        ResultBuffer resbuf      = xrecord.Data;
                        TypedValue[] resbufvalue = resbuf.AsArray();

                        profileObjects.Add(new ProfileObject()
                        {
                            NodKey             = (string)resbufvalue[0].Value,
                            DistanceAtCrossing = (double)resbufvalue[1].Value,
                            LineType           = (string)resbufvalue[2].Value,
                            Layer = (string)resbufvalue[3].Value,
                            Depth = (int)resbufvalue[4].Value
                        });

                        ed.WriteMessage(string.Format("\n{0}, {1}, {2}, {3}, {4}", resbufvalue[0].Value, resbufvalue[1].Value, resbufvalue[2].Value, resbufvalue[3].Value, resbufvalue[4].Value));
                    }
                }
                catch
                {
                    ed.WriteMessage("Does not Exists App Dictionary.");
                }
            }

            return(profileObjects);
        }
Пример #13
0
        private static bool GetArgs2(ResultBuffer rb, ref string current, List<string> configs)
        {
            if (rb == null) return false;
            TypedValue[] values = rb.AsArray();
            if (values.Length <= 2) return false;

            current = values[1].Value.ToString();

            for (int i = 2; i < (values.Length - 1); i++)
            {
                var v = values[i];
                configs.Add(v.Value.ToString());
            }

            return true;

        }
Пример #14
0
        // Parse the XData from an existing QR Code for
        // the default value we care about
        // (could be optimised with a HashSet, but this would
        // only be for "complex" data such as contacts)

        private static object GetDefault(
            string name, ResultBuffer defs
            )
        {
            if (defs != null)
            {
                TypedValue[] tvs = defs.AsArray();
                for (int i = 0; i < tvs.Length; i++)
                {
                    if (tvs[i].Value.ToString() == name)
                    {
                        return(tvs[i + 1].Value);
                    }
                }
            }
            return(null);
        }
Пример #15
0
        /// <summary>
        /// 取得编码
        /// </summary>
        public static string GetCode(this Entity ent)
        {
            ResultBuffer resBuf = ent.GetXDataForApplication(Consts.AppNameForCode);

            if (resBuf == null)
            {
                return(null);
            }
            foreach (TypedValue tValue in resBuf.AsArray())
            {
                if (tValue.TypeCode == 1000)
                {
                    return(tValue.Value.ToString());
                }
            }
            return(null);
        }
Пример #16
0
        clearAllXdata(this ObjectId id)
        {
            ResultBuffer rb = id.getXData(null);

            if (rb == null)
            {
                return;
            }
            TypedValue[]        tvs     = rb.AsArray();
            List <string>       apps    = new List <string>();
            List <TypedValue[]> tvsList = tvs.parseXData(out apps);

            foreach (string n in apps)
            {
                id.clearXData(n);
            }
        }
        private string ReadWKTFromXrecord(Xrecord rec)
        {
            ResultBuffer data = rec.Data;
            string       result;

            if (data != null)
            {
                TypedValue[] array = data.AsArray();
                result = array[0].Value.ToString();
            }
            else
            {
                this.AcadId = ObjectId.Null;
                result      = "";
            }
            return(result);
        }
Пример #18
0
        obj_Modified(object sender, EventArgs e)
        {
            DBObject dbObj = (DBObject)sender;

            if (dbObj.IsErased)
            {
                return;
            }
            ResultBuffer rb = dbObj.GetXDataForApplication(null);

            TypedValue[]        tvs      = rb.AsArray();
            List <string>       nameApps = null;
            List <TypedValue[]> lstTVs   = xData.parseXData(tvs, out nameApps);

            foreach (TypedValue[] tvsRet in lstTVs)
            {
                string nameApp = tvsRet[0].Value.ToString();
                string nameObj = tvsRet[1].Value.ToString();

                switch (nameApp)
                {
                case "lnkBubs":

                    switch (nameObj)
                    {
                    case "TARGET":
                        break;

                    case "TX":
                        modTXlnkBubs(dbObj.ObjectId, tvsRet);
                        break;

                    case "SM":
                        break;

                    case "LDR":
                        modLDRlnkBubs(dbObj.ObjectId, tvsRet);
                        break;
                    }
                    break;

                case "lnkBubsLdrEndPnt":
                    break;
                }
            }
        }
Пример #19
0
        public void EditTable()
        {
            TypedValue[] acTypValAr = new TypedValue[2];
            acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "ACAD_TABLE"), 0);
            acTypValAr.SetValue(new TypedValue((int)DxfCode.LayerName, "TABLE"), 1);

            SelectionFilter filter = new SelectionFilter(acTypValAr);

            ac.Document            doc = ac.Application.DocumentManager.MdiActiveDocument;
            Database               db  = doc.Database;
            PromptSelectionOptions promptSelectionOptions = new PromptSelectionOptions();
            Editor ed = doc.Editor;
            PromptSelectionResult selRel = ed.GetSelection(promptSelectionOptions, filter);

            if (selRel.Status == PromptStatus.OK)
            {
                SelectionSet selSet = selRel.Value;
                if (selSet.Count >= 1)
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        Table        gotTable = (Table)tr.GetObject(selSet[0].ObjectId, OpenMode.ForRead);
                        ResultBuffer rb       = gotTable.XData;
                        if (rb != null)
                        {
                            TypedValue[] vArr = rb.AsArray();
                            if (vArr.Length == 2 && vArr[0].Value.ToString() == uriInit)
                            {
                                string   url  = string.Format("{0}/#/{1}?id={2}", Goodie.hostName, uriInit, vArr[1].Value);
                                JsonData data = OpeningBrowser(url);
                                if (data != null)
                                {
                                    EditOrCreateTable(data, gotTable.Position);
                                    gotTable.UpgradeOpen();
                                    gotTable.Erase();
                                }
                                tr.Commit();
                            }
                        }
                    }
                }
            }


            Table tb = new Table();
        }
Пример #20
0
        /// <summary>
        /// 获取FXD数据
        /// </summary>
        /// <param name="dbo"></param>
        /// <param name="appName"></param>
        /// <returns></returns>
        public static object GetFirstXDataT(this DBObject dbo, string appName)
        {
            ResultBuffer xdataForApp = dbo.GetXDataForApplication(appName);

            if (xdataForApp == null)
            {
                return(null);
            }
            foreach (var value in xdataForApp.AsArray())
            {
                if (value.TypeCode != 1001)
                {
                    return(value.Value);
                }
            }
            return(null);
        }
Пример #21
0
        private static void GetArgs(ResultBuffer rb, out FensterOptions opts)
        {
            TypedValue[] values = rb.AsArray();

            opts                = new FensterOptions();
            opts.Breite         = (double)values[1].Value;
            opts.Hoehe          = (double)values[2].Value;
            opts.Parapet        = (double)values[3].Value;
            opts.OlAb           = (double)values[4].Value;
            opts.Staerke        = (double)values[5].Value;
            opts.Stock          = (double)values[6].Value;
            opts.SprossenBreite = (double)values[7].Value;
            opts.Sprossen       = (int)(short)values[8].Value;
            opts.TextAbstand    = (double)values[9].Value;
            opts.FluegelStaerke = (double)values[10].Value;
            opts.FensterArt     = FensterOptions.StringToFenArt((string)values[11].Value);
        }
Пример #22
0
        public object ESRI_GetFeatureClassQuery(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 1)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string          name = typedValue.Value.ToString();
                        MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(name);
                        if (localFeatureClass == null)
                        {
                            result = null;
                        }
                        else
                        {
                            TypedValue[] array2 = localFeatureClass.Query.AsArray();
                            if (array2.Length == 0)
                            {
                                localFeatureClass.SetDefaultQuery();
                            }
                            ResultBuffer resultBuffer = new ResultBuffer(localFeatureClass.Query.AsArray());
                            result = resultBuffer;
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Пример #23
0
 private static void GetConfiguration()
 {
     _CurrentConfig = string.Empty;
     using (var rb = new ResultBuffer(new TypedValue((int)LispDataType.Text, "c:Plan2CurrentConfig")))
     {
         int          stat = 0;
         ResultBuffer res  = CADDZone.AutoCAD.Samples.AcedInvokeSample.InvokeLisp(rb, ref stat);
         if (stat == RTNORM && res != null)
         {
             _CurrentConfig = res.AsArray()[0].Value.ToString();
             res.Dispose();
         }
         else
         {
             throw new InvalidOperationException("Konnte Konfigurationsdateiname nicht ermitteln!");
         }
     }
 }
Пример #24
0
        public bool FabSetItemProp(ResultBuffer args)
        {
            bool    ret = false;
            dynamic res = null;

            if (args != null)
            {
                TypedValue[] argarray = args.AsArray();
                ObjectId     ent;
                string       path  = "";
                dynamic      value = null;
                dynamic      itm   = null;
                if (argarray.Length >= 2)
                {
                    if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                    {
                        ent = (ObjectId)argarray[0].Value;
                        try { itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString()); }
                        catch (System.Exception) { }
                    }
                    else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                    {
                        itm = (string)argarray[0].Value;
                        if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                        {
                            itm = VarCache[hand.VariableName(itm)];
                        }
                    }
                    if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                    {
                        path = (string)argarray[1].Value;
                    }
                    if (argarray.Length >= 3)
                    {
                        value = hand.ConvertFromRB(argarray[2]);
                    }
                }
                if (itm != null && path.Length > 1)
                {
                    res = Sequencing.GenericPropertySetter(itm, new List <string>(path.Split('.')), value);
                }
            }
            return(ret);
        }
Пример #25
0
        }//method

        //----------------------------------------------------------------------------------------------------------------
        private static void SchrijfAttributen(Xrecord xr)
        {
            ResultBuffer buffer = xr.Data;

            TypedValue[] tvs = buffer.AsArray();

            //Schrijf attributenaantal
            int attributenaantal = tvs.Count() / 2;

            binWriter.Write(attributenaantal);

            for (int i = 0; i < attributenaantal; i++)
            {
                //Schrijf attrnaam
                string attrnaam = tvs[2 * i].Value.ToString();
                Schrijfstring(attrnaam);

                //Schrijf attrtype en attrwaarde
                TypedValue typedRecord = tvs[2 * i + 1];
                short      typecode    = typedRecord.TypeCode;
                switch (typecode)
                {
                case (int)DxfCode.Int32:
                    Schrijfstring("Integer");
                    binWriter.Write((Int32)typedRecord.Value);
                    break;

                case (int)DxfCode.Real:
                    Schrijfstring("Float");
                    binWriter.Write(Convert.ToSingle(typedRecord.Value));
                    break;

                case (int)DxfCode.Text:
                    Schrijfstring("String");
                    Schrijfstring((string)typedRecord.Value);
                    break;

                default: break;     //gegevenstype nog niet ondersteund
                }

                //Schrijf attrwaarde
                var attrwaarde = typedRecord.Value;
            }
        }
Пример #26
0
        public TypedValue RebuildSurface(ResultBuffer resbuf)
        {
            var nil = new TypedValue((int)LispDataType.Nil);
            var T   = new TypedValue((int)LispDataType.T_atom);

            if (BufferContainsObjectId(resbuf) == false)
            {
                return(nil);
            }
            // get the actual value of the resbuf
            var      args = resbuf.AsArray();
            ObjectId oID  = (ObjectId)args[0].Value;

            Document currentDocument = Application.DocumentManager.MdiActiveDocument;
            Database currentDatabase = currentDocument.Database;

            using (Transaction trans = currentDatabase.TransactionManager.StartTransaction())
            {
                try
                {
                    //check if the oID belongs to a surface
                    Autodesk.Civil.DatabaseServices.Surface surface = oID.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
                    // make sure it's not a reference object
                    // check if the civil object is a data reference
                    if (surface != null)
                    {
                        if (surface.IsReferenceObject == false)
                        {
                            // rebuild the object
                            surface.Rebuild();
                            return(T);
                        }
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(nil);
                }
            }

            // return nil as the final output option
            return(nil);
        }
Пример #27
0
        public void ModifyXData()
        {
            //提示用户选择一个多行文本
            PromptEntityOptions opt = new PromptEntityOptions("\n请选择多行文本");

            opt.SetRejectMessage("\n您选择的不是多行文本,请重新选择");
            opt.AddAllowedClass(typeof(MText), true);
            PromptEntityResult entResult = Ed.GetEntity(opt);

            if (entResult.Status != PromptStatus.OK)
            {
                return;
            }
            ObjectId id = entResult.ObjectId;//用户选择的多行文本的ObjectId

            using (Transaction trans = Db.TransactionManager.StartTransaction())
            {
                //如果扩展数据项(员工编号)为1002,则将其修改为1001


                var dbObject = trans.GetObject(id, OpenMode.ForWrite);

                ResultBuffer rb = dbObject.GetXDataForApplication(appName);

                TypedValue[] arrTV = rb.AsArray();

                for (int i = 0; i < arrTV.Length; i++)
                {
                    var data = arrTV[i];

                    if (data.TypeCode == (short)DxfCode.ExtendedDataInteger32 && (int)data.Value == 1002)
                    {
                        arrTV[i] = new TypedValue(data.TypeCode, 1001);
                        break;
                    }
                }
                dbObject.XData = new ResultBuffer(arrTV);

                dbObject.DowngradeOpen();

                trans.Commit();
            }
            Application.ShowAlertDialog("OK");
        }
        // Token: 0x060000C8 RID: 200 RVA: 0x0000A24C File Offset: 0x0000844C
        internal bool a(DBObject A_0, int A_1, object A_2, Transaction A_3)
        {
            if (A_0.XData == null)
            {
                return(false);
            }
            bool result;

            using (ResultBuffer xdataForApplication = A_0.GetXDataForApplication(this.XDAppName))
            {
                if (xdataForApplication == null)
                {
                    result = false;
                }
                else
                {
                    TypedValue[] array = xdataForApplication.AsArray();
                    if (array.GetUpperBound(0) < A_1)
                    {
                        result = false;
                    }
                    else
                    {
                        if (A_2 is int)
                        {
                            array[A_1] = new TypedValue(1071, A_2);
                        }
                        else
                        {
                            array[A_1] = new TypedValue(1000, A_2.ToString());
                        }
                        if (!A_0.IsWriteEnabled && !A_0.ObjectId.IsNull)
                        {
                            A_3.GetObject(A_0.ObjectId, 1, false, true);
                        }
                        this.a(A_0.Database, A_3);
                        A_0.XData = new ResultBuffer(array);
                        result    = true;
                    }
                }
            }
            return(result);
        }
Пример #29
0
 public static Ballon ReadBallonFromBuffer(ResultBuffer buffer)
 {
     try
     {
         Ballon       bal   = new Ballon();
         TypedValue[] rvArr = buffer.AsArray();
         bal.LayerName   = (string)rvArr[1].Value;
         bal.Angle       = (double)rvArr[2].Value;
         bal.Length      = (double)rvArr[3].Value;
         bal.Radius      = (double)rvArr[4].Value;
         bal.ColorIndex  = (int)rvArr[5].Value;
         bal.StringInput = (string)rvArr[6].Value;
         return(bal);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #30
0
        private void ReplaceXData(ResultBuffer rb)
        {
            if (rb != null)
            {
                Document doc = Application.DocumentManager.MdiActiveDocument;

                Transaction tr = doc.TransactionManager.StartTransaction();
                using (tr)
                {
                    DBObject obj     = tr.GetObject(this.id, OpenMode.ForWrite);
                    string   appName = rb.AsArray()[0].Value.ToString();
                    if (appName2values.ContainsKey(appName))
                    {
                        obj.XData = rb;
                    }
                    tr.Commit();
                }
            }
        }
Пример #31
0
        flipPointsMove(bool add)
        {
            double           dblEasting  = 0;
            double           dblNorthing = 0;
            List <StakedPnt> stakedPnts  = getStakedPnts();

            try
            {
                for (int i = 0; i < stakedPnts.Count; i++)
                {
                    Alignment objAlign = (Alignment)stakedPnts[i].hAlign.getEnt();

                    objAlign.PointLocation(stakedPnts[i].Station, stakedPnts[i].Offset * -1, ref dblEasting, ref dblNorthing);

                    Point3d      pnt3d   = new Point3d(dblEasting, dblNorthing, stakedPnts[i].Elev);
                    ObjectId     idCgPnt = stakedPnts[i].hCgPnt.getObjectId();
                    ResultBuffer rb      = idCgPnt.getXData("STAKE");
                    if (rb == null)
                    {
                        continue;
                    }
                    TypedValue[] tvs    = rb.AsArray();
                    double       offset = double.Parse(tvs[3].Value.ToString()) * -1;
                    tvs[3] = new TypedValue(1040, offset);

                    if (add)
                    {
                        uint pntNum = 0;
                        idCgPnt = pnt3d.setPoint(out pntNum, "SPNT");
                        idCgPnt.setXData(tvs, "STAKE");
                    }
                    else
                    {
                        idCgPnt.moveCogoPoint(pnt3d);
                        idCgPnt.setXData(tvs, "STAKE");
                    }
                }
            }
            catch (System.Exception)
            {
            }
        }
Пример #32
0
        /// <summary>
        /// Converts a <see cref="ResultBuffer"/> to <see cref="List{TypedValue}"/>. If the Lisp arguments are below the minimum or above the maximum required, an exception will be thrown.
        /// </summary>
        /// <param name="arguments"></param>
        /// <param name="minimum"></param>
        /// <param name="maximum"></param>
        /// <returns><see cref="List{TypedValue}"/></returns>
        /// <exception cref="System.Exception"/>
        public static List <TypedValue> HandleLispArguments(ResultBuffer arguments, int minimum, int maximum)
        {
            if (arguments == null)
            {
                throw new System.Exception("too few arguments");
            }

            List <TypedValue> Arguments = new List <TypedValue>(arguments.AsArray());

            if (Arguments.Count < minimum)
            {
                throw new System.Exception("too few arguments");
            }
            else if (Arguments.Count > maximum)
            {
                throw new System.Exception("too many arguments");
            }

            return(Arguments);
        }
Пример #33
0
        updateSG(ObjectId idPoly3dSLP)
        {
            Polyline3d poly3d = (Polyline3d)idPoly3dSLP.getEnt();

            ResultBuffer rbLnkBrks = idPoly3dSLP.getXData(apps.lnkBrks);

            if (rbLnkBrks == null)
            {
                return;
            }
            TypedValue[] tvs = rbLnkBrks.AsArray();

            List <ObjectId> idsCgPNts = tvs.getObjectIdList();

            poly3d.setBegPnt(idsCgPNts[0].getCogoPntCoordinates());
            poly3d.setEndPnt(idsCgPNts[1].getCogoPntCoordinates());

            poly3d.deleteVertices(idsCgPNts);

            ResultBuffer rbSLP = idPoly3dSLP.getXData(apps.lnkSLP);

            if (rbSLP == null)
            {
                return;
            }
            tvs = rbSLP.AsArray();

            tvs.deleteLinkedEnts();

            double B1Width  = double.Parse(tvs[1].Value.ToString());
            double B1Slope  = double.Parse(tvs[2].Value.ToString());
            double B2Width  = double.Parse(tvs[4].Value.ToString());
            double B2Slope  = double.Parse(tvs[5].Value.ToString());
            double slope    = double.Parse(tvs[7].Value.ToString());
            int    side     = int.Parse(tvs[8].Value.ToString());
            int    interval = int.Parse(tvs[9].Value.ToString());
            string surfTAR  = tvs[11].Value.ToString();
            string surfDES  = tvs[12].Value.ToString();

            Grading.Cmds.cmdSG.SG(B1Width, B1Slope, B2Width, B2Slope, slope, interval, surfTAR, surfDES, side, poly3d: poly3d);
        }
Пример #34
0
        public ResultBuffer PythonLoadLISP(ResultBuffer rb)
        {
            const int RTSTR = 5005;

            Document doc =
              Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            if (rb == null)
            {
                ed.WriteMessage("\nError: too few arguments\n");
            }
            else
            {
                // We're only really interested in the first argument

                Array args = rb.AsArray();
                TypedValue tv = (TypedValue)args.GetValue(0);

                // Which should be the filename of our script

                if (tv != null && tv.TypeCode == RTSTR)
                {
                    // If we manage to execute it, let's return the
                    // filename as the result of the function
                    // (just as (arxload) does)

                    bool success =
                      ExecutePythonScript(Convert.ToString(tv.Value));
                    return
                      (success ?
                        new ResultBuffer(
                          new TypedValue(RTSTR, tv.Value)
                        )
                        : null);
                }
            }
            return null;
        }
Пример #35
0
 public void PIK_LispLog(ResultBuffer rb)
 {
     var tvs = rb.AsArray();
     if (tvs.Any())
     {
         Logger.Log.InfoLisp(tvs[0].Value.ToString());
     }
 }
Пример #36
0
        private void ReplaceXData(ResultBuffer rb)
        {
            if (rb != null)
            {
                Document doc = Application.DocumentManager.MdiActiveDocument;

                Transaction tr = doc.TransactionManager.StartTransaction();
                using (tr)
                {
                    DBObject obj = tr.GetObject(this.id, OpenMode.ForWrite);
                    string appName = rb.AsArray()[0].Value.ToString();
                    if (appName2values.ContainsKey(appName))
                    {
                        obj.XData = rb;
                    }
                    tr.Commit();
                }
            }
        }