public ErrorStatus RoundHeight(int digits) { Database db = HostApplicationServices.WorkingDatabase; _AcDb.TransactionManager myTm = db.TransactionManager; Transaction myT = db.TransactionManager.StartTransaction(); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectContextManager conTextManager = db.ObjectContextManager; ErrorStatus es = ErrorStatus.KeyNotFound; if (this.HöheOrg != null) { if (MyString.Precision(this.HöheOrg) >= digits) { try { using (DocumentLock dl = Application.DocumentManager.MdiActiveDocument.LockDocument()) { BlockTable bt = (BlockTable)myT.GetObject(db.BlockTableId, OpenMode.ForRead); ObjectId id = bt[BlockTableRecord.ModelSpace]; AttributeCollection col = _blkRef.AttributeCollection; foreach (ObjectId attId in col) { AttributeReference attRef = (AttributeReference)myT.GetObject(attId, OpenMode.ForWrite); switch (attRef.Tag) { case "height": double Höhe = Convert.ToDouble(this.HöheOrg, CultureInfo.InvariantCulture); attRef.TextString = Höhe.ToString("F" + digits.ToString()); attRef.Dispose(); _Hdigits = digits; es = ErrorStatus.OK; break; } } } } catch { } finally { myT.Commit(); myT.Dispose(); ed.Regen(); } } } return(es); }
private void FillTable(SelectionSet ssRes) { ObjectId[] objID = ssRes.GetObjectIds(); //SelectionSet iterieren foreach (ObjectId blkID in objID) { using (DocumentLock dl = Application.DocumentManager.MdiActiveDocument.LockDocument()) { try { m_myT.GetObject(blkID, OpenMode.ForRead); BlockReference blkRef = (BlockReference)m_myT.GetObject(blkID, OpenMode.ForRead); //nur Blöcke mit Attributen berücksichtigen AttributeCollection colAtt = blkRef.AttributeCollection; if (colAtt.Count >= 1) { Messpunkt MP = new Messpunkt(blkRef); //XData lesen RegAppTable acRegAppTbl; acRegAppTbl = (RegAppTable)m_myT.GetObject(m_db.RegAppTableId, OpenMode.ForRead); ResultBuffer rb = new ResultBuffer(); rb = blkRef.XData; if (rb == null) { break; } foreach (TypedValue tv in rb) { switch (tv.TypeCode) { case 1000: try { MP.HöheOrg = (string)tv.Value; } catch { } break; } } //Attribute iterieren foreach (ObjectId attID in colAtt) { AttributeReference attRef = (AttributeReference)m_myT.GetObject(attID, OpenMode.ForRead); Messpunkt.Att att = new Messpunkt.Att() { Value = attRef.TextString, Pos = attRef.Position, Layer = attRef.Layer }; MP.AddAttribute(att); attRef.Dispose(); } LsMP.Add(MP); } } catch { } } } // m_myT.Commit(); } //fillTable
private void fillTable(SelectionSet ssRes) { ObjectId[] objID = ssRes.GetObjectIds(); int i = 0; //SelectionSet iterieren foreach (ObjectId blkID in objID) { using (DocumentLock dl = Application.DocumentManager.MdiActiveDocument.LockDocument()) { try { m_myT.GetObject(blkID, OpenMode.ForRead); BlockReference blkRef = (BlockReference)m_myT.GetObject(blkID, OpenMode.ForRead); //nur Blöcke mit Attributen berücksichtigen AttributeCollection colAtt = blkRef.AttributeCollection; if (colAtt.Count >= 1) { Messpunkt MP = new Messpunkt(blkRef); //XData lesen ResultBuffer rb = blkRef.XData; if (rb != null) { int n = 0; foreach (TypedValue tv in rb) { switch (tv.TypeCode) { case 1000: try { MP.CASHöhe = Convert.ToDouble(tv.Value); } catch { } break; case 1001: break; case 1071: try { MP.HeigthPrecision = Convert.ToInt32(tv.Value); } catch { } break; } n++; } } //Attribute iterieren foreach (ObjectId attID in colAtt) { AttributeReference attRef = (AttributeReference)m_myT.GetObject(attID, OpenMode.ForRead); Messpunkt.Att att = new Messpunkt.Att(); att.Value = attRef.TextString; att.Pos = attRef.Position; att.Layer = attRef.Layer; MP.addAttribute(att); attRef.Dispose(); } lsMP.Add(MP); } } catch { } } } m_myT.Commit(); } //fillTable