Exemple #1
0
        internal static void m_db_ObjectOpenedForModify(object sender, ObjectEventArgs e)
        {
            EM_Helper.StreamMessage(String.Format("ObjectOpenedForModify - {0} {1}", e.DBObject.ToString(), e.DBObject.Id.ToString()));

            try {
                RXObject obj  = e.DBObject;
                string   type = obj.GetType().Name;

                if (!types.Contains(type))
                {
                    return;
                }

                List <EM_EData> enData = new List <EM_EData>();

                ResultBuffer rb       = null;
                ObjectId     idX      = ObjectId.Null;
                string       objTypeX = string.Empty;
                Handle       hX       = "0".stringToHandle();
                Point3d      pnt3d    = Public.pnt3dOrg;

                switch (type)
                {
                case "CogoPoint":
                    CogoPoint ent = (CogoPoint)obj;
                    rb       = ent.GetXDataForApplication(null);
                    idX      = ent.ObjectId;
                    objTypeX = type;
                    hX       = ent.Handle;
                    break;

                case "DBText":
                case "MText":
                case "Leader":
                case "Polyline":
                case "Polyline3d":
                case "BlockReference":
                    Entity entX = (Entity)obj;
                    rb       = entX.GetXDataForApplication(null);
                    idX      = entX.ObjectId;
                    objTypeX = type;
                    hX       = entX.Handle;
                    break;
                }

                if (rb == null)
                {
                    return;
                }

                TypedValue[] tvsX = rb.AsArray();

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

                for (int i = 0; i < lstTVs.Count; i++)
                {
                    TypedValue[] tvs     = lstTVs[i];
                    string       nameApp = tvs[0].Value.ToString();

                    if (!Public.lstApps.Contains(nameApp))
                    {
                        continue;
                    }

                    if (type == "MText")
                    {
                        MText mTxt = (MText)e.DBObject;
                        pnt3d = mTxt.Location;
                    }
                    else if (type == "DBText")
                    {
                        DBText Txt = (DBText)e.DBObject;
                        pnt3d = Txt.Position;
                    }
                    else
                    {
                        pnt3d = Public.pnt3dOrg;
                    }
                    EM_EData eData = new EM_EData(hX, idX, objTypeX, pnt3d, tvs);
                    enData.Add(eData);
                    EW_Storage.enData = enData;
                }
            }
            catch (System.Exception ex) {
                BaseObjs.writeDebug(ex.Message + " EM_EventsDb.cs: line: 96");
            }
        }