updateBrkLine(CogoPoint cogoPnt) { Database DB = BaseObjs._db; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ResultBuffer RB = cogoPnt.GetXDataForApplication("lblBrks"); foreach (TypedValue TV in RB) { if (TV.TypeCode == 1005) { string strHandle = TV.Value.ToString(); long LN = Convert.ToInt64(strHandle, 16); Handle HN = new Handle(LN); ObjectId objID = DB.GetObjectId(false, HN, 0); Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead); BaseObjs._editor.WriteMessage(dbObj.Handle.ToString()); } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 780"); } } //end updateBrkline
cogoPnt_Modified(object sender, EventArgs e) { ResultBuffer RB = null; using (Transaction tr = BaseObjs.startTransactionDb()) { try { RB = cogoPnt.GetXDataForApplication("lbkBrks"); if (RB != null) { Mod.updateBrkLine(cogoPnt); } } catch { tr.Abort(); return; } tr.Commit(); } // end using tr } // cogoPnt_Modified
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"); } }
updateDesignCallout(CogoPoint cogoPnt, string strApp) { ResultBuffer RB = null; MText mText = null; string[] strLines; string[] strFieldsTop; string[] strFieldsBot; string strCalloutX = ""; string strElev = cogoPnt.Location.Z.ToString("#,###.00"); try { using (Transaction tr = BaseObjs.startTransactionDb()) { RB = cogoPnt.GetXDataForApplication(strApp); string strCallout0 = ""; foreach (TypedValue TV in RB) { if (TV.TypeCode.ToString() == "1005") { string strHandle = TV.Value.ToString(); ObjectId objID = Misc.getObjectIdFromHandle(strHandle); Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead); mText = (MText)dbObj; strCallout0 = mText.Contents; if (strApp == "FL") { strLines = Txt.splitLines(strCallout0); strCalloutX = string.Format("{0}\\P{1}", strElev, strLines[1]); } if (strApp == "FF") { strLines = Txt.splitLines(strCallout0); strFieldsTop = Txt.splitFields(strLines[0], ' '); strFieldsBot = Txt.splitFields(strLines[1], ' '); } if (strApp == "G") { strLines = Txt.splitLines(strCallout0); strFieldsTop = Txt.splitFields(strLines[0], ' '); strFieldsBot = Txt.splitFields(strLines[1], ' '); } Events.deactivateMText("*", mText); mText.UpgradeOpen(); mText.Contents = strCalloutX; mText.DowngradeOpen(); Events.activateMText("*", mText); } } RB = mText.GetXDataForApplication(strApp); foreach (TypedValue TV in RB) { if (TV.TypeCode.ToString() == "1005") { string strHandle = TV.Value.ToString(); ObjectId objID = Misc.getObjectIdFromHandle(strHandle); Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(objID, OpenMode.ForRead); Leader LDR = (Leader)dbObj; Events.deactivateLdr("*", LDR); LDR.UpgradeOpen(); LDR.SetVertexAt(0, new Point3d(cogoPnt.Location.X, cogoPnt.Location.Y, 0.0)); LDR.DowngradeOpen(); Events.activateLdr("*", LDR); } } tr.Commit(); } //end using tr } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1004"); } } //end updateDesignCallout
updateExistCallouts(SelectionSet SS) { ResultBuffer RB = null; BlockReference BR = null; CogoPoint cogoPnt = null; string strAppName = string.Empty; string strElev = string.Empty; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ObjectId[] objIDs = SS.GetObjectIds(); foreach (ObjectId objID in objIDs) { cogoPnt = (CogoPoint)tr.GetObject(objID, OpenMode.ForRead); strElev = cogoPnt.Location.Z.ToString("#,###.00"); RB = cogoPnt.GetXDataForApplication("lblPnts"); if (RB != null) { strAppName = "lblPnts"; } else { RB = cogoPnt.GetXDataForApplication("lblPntsPT"); strAppName = "lblPntsPT"; } if (RB != null) { try { foreach (TypedValue TV in RB) { if (TV.TypeCode.ToString() == "1005") { try { string strHandle = TV.Value.ToString(); ObjectId brID = Misc.getObjectIdFromHandle(strHandle); Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = tr.GetObject(brID, OpenMode.ForRead); BR = (BlockReference)dbObj; if (BR != null) { AttributeCollection AC = BR.AttributeCollection; foreach (ObjectId arID in AC) { AttributeReference AR = (AttributeReference)tr.GetObject(arID, OpenMode.ForWrite); string strAttVal = AR.TextString.ToString(); if (strAttVal != string.Empty) { string[] strFields = Txt.splitFields(strAttVal, ' '); if (strFields[0] != string.Empty) { string strVal = strFields[0]; if (strVal.StartsWith("(")) { string strChr = strVal[1].ToString(); int num; Boolean isNum = strChr.isInteger(out num); if (isNum == true) { strAttVal = string.Format("({0} {1}", strElev, strFields[1]); AR.TextString = strAttVal; } } } } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1091"); } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1098"); } } } tr.Commit(); } //end using tr } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 1108"); } } //end updateDesignCallout