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
private static void AddPropertySetToObjects(UiData uiData, ObjectId propertySetDefinitionId, Transaction trans) { foreach (List <ObjectId> ids in uiData.classObjectIdsMap.Values) { foreach (ObjectId id in ids) { Autodesk.AutoCAD.DatabaseServices.DBObject obj = trans.GetObject(id, OpenMode.ForWrite) as Autodesk.AutoCAD.DatabaseServices.DBObject; PropertyDataServices.RemovePropertySet(obj, propertySetDefinitionId); PropertyDataServices.AddPropertySet(obj, propertySetDefinitionId); } } }
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
copyTextContentsToTextEnt(SelectionSet SS0, SelectionSet SSX) { string strContents = string.Empty; try { using (Transaction tr = BaseObjs.startTransactionDb()) { ObjectId[] objIDs = null; ObjectId objID0 = ObjectId.Null; ObjectId objIDX = ObjectId.Null; objIDs = SS0.GetObjectIds(); if (objIDs.Length == 1) { objID0 = objIDs[0]; Autodesk.AutoCAD.DatabaseServices.DBObject dbObj0 = tr.GetObject(objID0, OpenMode.ForRead); try { DBText TXT = (DBText)dbObj0; if (TXT != null) { strContents = TXT.TextString.ToString(); } else { MText mTXT = (MText)dbObj0; if (mTXT != null) { strContents = mTXT.Text.ToString(); } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 192"); } } objIDs = SSX.GetObjectIds(); if (objIDs.Length == 1) { objIDX = objIDs[0]; Autodesk.AutoCAD.DatabaseServices.DBObject dbObjX = tr.GetObject(objIDX, OpenMode.ForWrite); try { DBText TXT = (DBText)dbObjX; if (TXT != null) { TXT.TextString = strContents; } else { MText mTXT = (MText)dbObjX; if (mTXT != null) { mTXT.Contents = strContents; } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 219"); } } else if (objIDs.Length > 1) { foreach (ObjectId objID in objIDs) { Autodesk.AutoCAD.DatabaseServices.DBObject dbObjX = tr.GetObject(objID, OpenMode.ForWrite); try { DBText TXT = (DBText)dbObjX; if (TXT != null) { TXT.TextString = strContents; } else { MText mTXT = (MText)dbObjX; if (mTXT != null) { mTXT.Contents = strContents; } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 245"); } } } tr.Commit(); } //end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 255"); } }
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