public static Pair <Point3d, Point3d> GetVPortToModelSpaceDiagpnal(ref Viewport vpr) { double xLnegth = vpr.Width / vpr.CustomScale; double yLength = vpr.Height / vpr.CustomScale; Quaternion q1 = new Quaternion(0, 1, 0, 0); Quaternion q2 = new Quaternion(0, 0, 1, 0); q1 = q1.get_rotateAroundAxe(new Quaternion(0, 0, 0, 1), vpr.TwistAngle); q2 = q2.get_rotateAroundAxe(new Quaternion(0, 0, 0, 1), vpr.TwistAngle); UCS ucs = new UCS(new Quaternion(), q1, q2); Vector3d vMOV = vpr.ViewTarget - Point3d.Origin; Quaternion qMOV = new Quaternion(0, vMOV.X, vMOV.Y, vMOV.Z); Quaternion c = new Quaternion(0, vpr.ViewCenter.X, vpr.ViewCenter.Y, 0); Quaternion c1 = new Quaternion(0, c.GetX() + xLnegth / 2.0, c.GetY() + yLength / 2.0, 0); Quaternion c2 = new Quaternion(0, c.GetX() - xLnegth / 2.0, c.GetY() - yLength / 2.0, 0); c = ucs.FromACS(c); c1 = ucs.FromACS(c1); c2 = ucs.FromACS(c2); c += qMOV; c1 += qMOV; c2 += qMOV; return(new Pair <Point3d, Point3d>(new Point3d(c1.GetX(), c1.GetY(), 0), new Point3d(c2.GetX(), c2.GetY(), 0))); }
public void PositionMarkStart() { Matrix3d ucs = _editorHelper.CurrentUcs; Point3d pO = Application.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin; PromptPointResult firstPointResult = _editorHelper.PromptForPoint("Pick arrow point : ", false, false); if (firstPointResult.Status != PromptStatus.OK) { return; } var firstPoint = firstPointResult.Value.TransformBy(GeometryUtility.GetTransforMatrixToWcs()); PromptPointResult secondPointResult = _editorHelper.PromptForPoint("Pick pos number sign point : ", true, true, firstPoint); if (secondPointResult.Status != PromptStatus.OK) { return; } var secondPoint = secondPointResult.Value.TransformBy(GeometryUtility.GetTransforMatrixToWcs()); PromptIntegerResult posNumberResult = _editorHelper.PromptForInteger("Enter POS integer number :"); if (posNumberResult.Status != PromptStatus.OK) { return; } _editorHelper.CurrentUcs = Matrix3d.Identity; Quaternion S = new Quaternion(0, secondPoint.X, secondPoint.Y, secondPoint.Z); Quaternion F = new Quaternion(0, firstPoint.X, firstPoint.Y, firstPoint.Z); Vector3d v1 = pO.GetVectorTo(secondPoint); Vector3d v = secondPoint.GetVectorTo(new Point3d(0, 0, 0)); secondPoint = secondPoint.TransformBy(Matrix3d.Displacement(v)); firstPoint = firstPoint.TransformBy(Matrix3d.Displacement(v)); Quaternion ucsOrigin = new Quaternion(0, pO.X, pO.Y, pO.Z); Quaternion Xaxe = new Quaternion(0, ucs.CoordinateSystem3d.Xaxis.X, ucs.CoordinateSystem3d.Xaxis.Y, ucs.CoordinateSystem3d.Xaxis.Z); Quaternion Yaxe = new Quaternion(0, ucs.CoordinateSystem3d.Yaxis.X, ucs.CoordinateSystem3d.Yaxis.Y, ucs.CoordinateSystem3d.Yaxis.Z); Xaxe = ucsOrigin + Xaxe; Yaxe = ucsOrigin + Yaxe; UCS UCS = new UCS(ucsOrigin, Xaxe, Yaxe); Quaternion FS = UCS.FromACS(S) - UCS.FromACS(F); double ang = FS.angToX(); if (FS.GetY() < 0) { ang *= -1; } Hashtable dynamicBlockProperties = new Hashtable(); Hashtable dynamicBlockAttributes = new Hashtable(); dynamicBlockProperties.Add("Base Point", secondPoint); dynamicBlockProperties.Add("Distance", secondPoint.DistanceTo(firstPoint)); dynamicBlockProperties.Add("Angle", ang); dynamicBlockAttributes.Clear(); dynamicBlockAttributes.Add("POS", posNumberResult.Value); string dynamicBlockFullName = _blockDrawingProvider.GetBlockFile(MethodBase.GetCurrentMethod().DeclaringType.Name); if (dynamicBlockFullName == null) { _editorHelper.WriteMessage("Dynamic block PositionMark.dwg does not exist."); return; } ObjectId refO = _drawingHelper.ImportDynamicBlockAndFillItsProperties( dynamicBlockFullName, secondPoint, dynamicBlockProperties, dynamicBlockAttributes); using (Transaction acTrans = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { Entity ent = (Entity)acTrans.GetObject(refO, OpenMode.ForWrite); ent.TransformBy(ucs); ent.TransformBy(Matrix3d.Displacement(v1)); acTrans.Commit(); } _editorHelper.CurrentUcs = ucs; _logger.Info(MethodBase.GetCurrentMethod().DeclaringType.Name); }
public void LevelHeightSignStart() { var insertionPointResult = _editorHelper.PromptForPoint("Pick insertion point : "); if (insertionPointResult.Status != PromptStatus.OK) { return; } var dynamicBlockProperties = new Hashtable(); var dynamicBlockAttributes = new Hashtable(); dynamicBlockProperties.Add("Base Point", insertionPointResult.Value); var dynamicBlockPath = _blockDrawingProvider.GetBlockFile(MethodBase.GetCurrentMethod().DeclaringType.Name); if (dynamicBlockPath == null) { _editorHelper.WriteMessage("Dynamic block LevelHeightSign.dwg does not exist."); return; } var brefId = _drawingHelper.ImportDynamicBlockAndFillItsProperties( dynamicBlockPath, insertionPointResult.Value, dynamicBlockProperties, dynamicBlockAttributes); using (var transaction = _doc.TransactionManager.StartTransaction()) { var blockReference = (BlockReference)transaction.GetObject(brefId, OpenMode.ForWrite); var zAxis = _doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis; var xAxis = _doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Xaxis; var yAxis = _doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Yaxis; var origin = _doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin; var mat = Matrix3d.AlignCoordinateSystem( Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, origin, xAxis, yAxis, zAxis); blockReference.TransformBy(mat); var ORIGIN = new Quaternion(0, origin.X, origin.Y, origin.Z); var axeX = new Quaternion(0, xAxis.X, xAxis.Y, xAxis.Z); var axeY = new Quaternion(0, yAxis.X, yAxis.Y, yAxis.Z); var ucs = new UCS(ORIGIN, ORIGIN + axeX, ORIGIN + axeY); var basePoint = new Quaternion( 0, insertionPointResult.Value.X, insertionPointResult.Value.Y, insertionPointResult.Value.Z); basePoint = ucs.ToACS(basePoint); ucs = new UCS(ORIGIN, ORIGIN + axeX, basePoint); var y = ucs.FromACS(basePoint).GetY(); if (double.IsNaN(y)) { y = 0.0; } foreach (ObjectId attId in blockReference.AttributeCollection) { var attributeReference = (AttributeReference)transaction.GetObject(attId, OpenMode.ForWrite); if (attributeReference.Tag == "LEVEL") { var mess = y.ToString("0.#####"); attributeReference.TextString = (mess.Length > 0) ? mess : "0.0"; } } transaction.Commit(); } _logger.Info(MethodBase.GetCurrentMethod().Name); }
private void CreateInsulationPolylineAndAppendToModelSpace(Point3d[] inputPoints, int rk, bool drawPerimeterOfInsulation) { var inputQPoints = new Quaternion[4]; // completed after sorting #region sorting var longestDistance = 0.0; var indexFirstPoint = 0; for (var i = 1; i < 4; i++) { var currentDistance = inputPoints[i - 1].DistanceTo(inputPoints[i]); if (currentDistance > longestDistance) { longestDistance = currentDistance; indexFirstPoint = i - 1; } } if (inputPoints[3].DistanceTo(inputPoints[0]) > longestDistance) { indexFirstPoint = 3; } var tempPoints = new Point3d[4]; for (var i = indexFirstPoint; i < 4 + indexFirstPoint; i++) { if (i < 4) { tempPoints[i - indexFirstPoint] = inputPoints[i]; } else { tempPoints[i - indexFirstPoint] = inputPoints[i - 4]; } } for (var i = 0; i < 4; i++) { inputPoints[i] = tempPoints[i]; inputQPoints[i] = new Quaternion(0.0, inputPoints[i].X, inputPoints[i].Y, inputPoints[i].Z); } #endregion var uCSOfInputPoints = new UCS(inputQPoints[0], inputQPoints[1], inputQPoints[2]); if (Math.Abs((uCSOfInputPoints.FromACS(inputQPoints[3])).GetZ()) > 0.00000254) { _editorHelper.WriteMessage("Four Points are not in the same Plane !"); _logger.Info("User input is invalid."); return; } #region counterclockwise selection test var centerUcsOfInputPoints = new Quaternion(0, 0, 0, 0); var zAxisInUscOfInputPoints = new Quaternion(0, 0, 0, 1000); var zAxisInAcs = uCSOfInputPoints.ToACS(zAxisInUscOfInputPoints) - uCSOfInputPoints.ToACS(centerUcsOfInputPoints); if (zAxisInAcs.GetZ() < 0) { var tempPoint = new Point3d(); var tempQuaternion = new Quaternion(); tempPoint = inputPoints[0]; inputPoints[0] = inputPoints[1]; inputPoints[1] = tempPoint; tempQuaternion = inputQPoints[0]; inputQPoints[0] = inputQPoints[1]; inputQPoints[1] = tempQuaternion; tempPoint = inputPoints[2]; inputPoints[2] = inputPoints[3]; inputPoints[3] = tempPoint; tempQuaternion = inputQPoints[2]; inputQPoints[2] = inputQPoints[3]; inputQPoints[3] = tempQuaternion; uCSOfInputPoints = new UCS(inputQPoints[0], inputQPoints[1], inputQPoints[2]); } #endregion var ucsPoints = new Point3d[4]; //are coordinates in a 0.0 WCS to draw (drawing only in oXY 0,0 per WCS and transform when it is ready polyline transform) var ucsQPoints = new Quaternion[4]; //are coordinates in a 0.0 WCS to draw (drawing only in oXY 0,0 per WCS and when it is ready polyline transform) var complexPoints = new Complex[4]; var sidesOffPolygon = new Complex[4]; #region 2d prepare for (int i = 0; i < 4; i++) { Quaternion q = uCSOfInputPoints.FromACS(inputQPoints[i]); ucsQPoints[i] = new Quaternion(0, (Math.Abs(q.GetX()) > 0.00000254) ? q.GetX() : 0.0, (Math.Abs(q.GetY()) > 0.00000254) ? q.GetY() : 0.0, (Math.Abs(q.GetZ()) > 0.00000254) ? q.GetZ() : 0.0); ucsPoints[i] = new Point3d(ucsQPoints[i].GetX(), ucsQPoints[i].GetY(), ucsQPoints[i].GetZ()); complexPoints[i] = new Complex(ucsQPoints[i].GetX(), ucsQPoints[i].GetY()); if (i > 0) { sidesOffPolygon[i - 1] = complexPoints[i] - complexPoints[i - 1]; } } sidesOffPolygon[3] = complexPoints[0] - complexPoints[3]; #endregion #region convex check for (var i = 0; i < 4; i++) { if (Math.Abs(GetAngleInPointIndex(i, complexPoints)) >= Math.PI) { break; } } #endregion var minThickness = (complexPoints[2].imag() < complexPoints[3].imag()) ? complexPoints[2].imag() : complexPoints[3].imag(); var segmentsCount = (int)Math.Ceiling((sidesOffPolygon[0].abs() / minThickness) / 0.35); var radius = sidesOffPolygon[0].abs() * 2 / (segmentsCount * 2); radius /= rk; var lowerLine = new List <Complex>(); var upperLine = new List <Complex>(); var insulationPerimeter = new Polyline(); insulationPerimeter.SetDatabaseDefaults(); insulationPerimeter.AddVertexAt(0, new Point2d(complexPoints[0].real(), complexPoints[0].imag()), 0, 0, 0); insulationPerimeter.AddVertexAt(1, new Point2d(complexPoints[1].real(), complexPoints[1].imag()), 0, 0, 0); insulationPerimeter.AddVertexAt(2, new Point2d(complexPoints[2].real(), complexPoints[2].imag()), 0, 0, 0); insulationPerimeter.AddVertexAt(3, new Point2d(complexPoints[3].real(), complexPoints[3].imag()), 0, 0, 0); insulationPerimeter.AddVertexAt(4, new Point2d(complexPoints[0].real(), complexPoints[0].imag()), 0, 0, 0); var objectsCollection = insulationPerimeter.GetOffsetCurves(-radius); var acPolyOffset = objectsCollection[0] as Polyline; var pointsFromOffset = new Complex[4]; for (var i = 0; i < 4; i++) { var point = acPolyOffset.GetPoint3dAt(i); pointsFromOffset[i] = new Complex(point.X, point.Y); } var variant = 0; if (pointsFromOffset[3].real() < pointsFromOffset[0].real() && (pointsFromOffset[3] - pointsFromOffset[0]).abs() / (radius * 2) > 1 && Math.Abs(pointsFromOffset[2].real() - pointsFromOffset[1].real()) > radius * 2) { variant = 1; lowerLine.Add(pointsFromOffset[0]); var xPos = pointsFromOffset[0].real(); do { xPos += radius * 2.0; if (xPos <= pointsFromOffset[1].real() + radius * 2 / 3) { lowerLine.Add(new Complex(xPos, radius)); } } while (xPos < (pointsFromOffset[0] - pointsFromOffset[1]).abs() + radius * 2 / 3); xPos = 0; var ort = (pointsFromOffset[3] - pointsFromOffset[0]) / (pointsFromOffset[3] - pointsFromOffset[0]).abs(); var k = Math.Abs(Math.Cos(ort.arg())); k -= 0.01; do { xPos += 2 * radius / Math.Abs(k); if (xPos < (pointsFromOffset[3] - pointsFromOffset[0]).abs() + radius * 2 / 3) { lowerLine.Insert(0, ort * xPos + pointsFromOffset[0]); } } while (xPos < (pointsFromOffset[3] - pointsFromOffset[0]).abs() + radius * 2 / 3); lowerLine.RemoveAt(0); } if (pointsFromOffset[1].real() < pointsFromOffset[2].real() && (pointsFromOffset[2] - pointsFromOffset[1]).abs() / (radius * 2) > 1 && Math.Abs(pointsFromOffset[2].real() - pointsFromOffset[1].real()) > radius * 2) { variant = 2; lowerLine.Add(pointsFromOffset[1]); var xPos = pointsFromOffset[1].real(); do { xPos -= radius * 2.0; if (xPos >= pointsFromOffset[0].real() - radius * 2.0 / 3.0) { lowerLine.Insert(0, new Complex(xPos, radius)); } } while (xPos > pointsFromOffset[0].real() - radius * 2.0 / 3.0); xPos = 0; var ort = (pointsFromOffset[2] - pointsFromOffset[1]) / (pointsFromOffset[2] - pointsFromOffset[1]).abs(); var k = Math.Abs(Math.Cos(ort.arg())); k -= 0.01; do { xPos += 2 * radius / Math.Abs(k); if (xPos < (pointsFromOffset[2] - pointsFromOffset[1]).abs() + radius * 2.0 / 3.0) { lowerLine.Add(ort * xPos + pointsFromOffset[1]); } } while (xPos < (pointsFromOffset[2] - pointsFromOffset[1]).abs() + radius * 2.0 / 3.0); } if (variant == 0) { lowerLine.Add(pointsFromOffset[0]); var xPos = pointsFromOffset[0].real(); do { xPos += radius * 2.0; if (xPos <= pointsFromOffset[1].real() + radius * 2.0) { lowerLine.Add(new Complex(xPos, radius)); } } while (xPos < (pointsFromOffset[0] - pointsFromOffset[1]).abs() + radius * 2.0); } var insulationPolyline = new Polyline(); insulationPolyline.SetDatabaseDefaults(); var old = new KeyValuePair <Complex, Complex>(); for (var i = 1; i < lowerLine.Count; i++) { var hlpPoint = (lowerLine[i] + lowerLine[i - 1]) / 2.0; var verticalLine = new Line(new Point3d(hlpPoint.real(), hlpPoint.imag(), 0), new Point3d(hlpPoint.real(), hlpPoint.imag() + 0.01, 0)); var pts = new Point3dCollection(); try { acPolyOffset.IntersectWith(verticalLine, Intersect.ExtendBoth, pts, IntPtr.Zero, IntPtr.Zero); } catch (Exception aCadRuntimeException) { _logger.Error("Unable to Intersect 2 entities", aCadRuntimeException); } if (pts.Count != 2) { continue; } var p = (pts[0].Y > pts[1].Y) ? pts[0] : pts[1]; var cc = new Complex(p.X, p.Y); if ((cc - hlpPoint).abs() > 2 * radius) { upperLine.Add(new Complex(p.X, p.Y)); var tangentPointsTopLeftBotRight = GetTangentPointsOfCommonInternalTanget(cc, radius, lowerLine[i], radius, true); var tangentPointsBotRightTopLeft = GetTangentPointsOfCommonInternalTanget(lowerLine[i - 1], radius, cc, radius, false); if (i > 1) { double ang1 = 0; ang1 = ((lowerLine[i - 1] - tangentPointsBotRightTopLeft.Key) / (lowerLine[i - 1] - old.Value)) .arg(); insulationPolyline.AddVertexAt(0, new Point2d(tangentPointsBotRightTopLeft.Key.real(), tangentPointsBotRightTopLeft.Key.imag()), -Math.Tan(ang1 / 4), 0, 0); } else { insulationPolyline.AddVertexAt(0, new Point2d(tangentPointsBotRightTopLeft.Key.real(), tangentPointsBotRightTopLeft.Key.imag()), 0, 0, 0); } double ang = ((cc - tangentPointsBotRightTopLeft.Value) / (cc - tangentPointsTopLeftBotRight.Key)).arg(); insulationPolyline.AddVertexAt(0, new Point2d(tangentPointsBotRightTopLeft.Value.real(), tangentPointsBotRightTopLeft.Value.imag()), 0, 0, 0); insulationPolyline.AddVertexAt(0, new Point2d(tangentPointsTopLeftBotRight.Key.real(), tangentPointsTopLeftBotRight.Key.imag()), Math.Tan(ang / 4), 0, 0); insulationPolyline.AddVertexAt(0, new Point2d(tangentPointsTopLeftBotRight.Value.real(), tangentPointsTopLeftBotRight.Value.imag()), 0, 0, 0); old = tangentPointsTopLeftBotRight; } else { if (i < lowerLine.Count / 2) { lowerLine.RemoveAt(i - 1); } else { lowerLine.RemoveAt(i); } i--; } } var vectorBaseLine = new Complex(inputPoints[1].X, inputPoints[1].Y) - new Complex(inputPoints[0].X, inputPoints[0].Y); #region transforms insulationPolyline.TransformBy(Matrix3d.Rotation(vectorBaseLine.arg(), new Vector3d(0, 0, 1), Point3d.Origin)); insulationPerimeter.TransformBy(Matrix3d.Rotation(vectorBaseLine.arg(), new Vector3d(0, 0, 1), Point3d.Origin)); insulationPolyline.TransformBy(Matrix3d.Displacement(Point3d.Origin.GetVectorTo(inputPoints[0]))); insulationPerimeter.TransformBy(Matrix3d.Displacement(Point3d.Origin.GetVectorTo(inputPoints[0]))); insulationPolyline.TransformBy(_editorHelper.CurrentUcs); insulationPerimeter.TransformBy(_editorHelper.CurrentUcs); #endregion var oldLayer = _documentHelper.Database.Clayer; _documentHelper.LayerManipulator.CreateLayer("3-0", System.Drawing.Color.Lime); insulationPolyline.Layer = "0"; var softInsulationBlock = new BlockTableRecord(); var nameSalt = DateTime.Now.GetHashCode().ToString(); softInsulationBlock.Name = "SoftInsulation_" + nameSalt; softInsulationBlock.Origin = inputPoints[0]; using (var acTrans = _documentHelper.TransactionManager.StartTransaction()) { var acBlkTbl = acTrans.GetObject(_documentHelper.Database.BlockTableId, OpenMode.ForWrite) as BlockTable; acBlkTbl.Add(softInsulationBlock); acTrans.AddNewlyCreatedDBObject(softInsulationBlock, true); softInsulationBlock.AppendEntity(insulationPolyline); acTrans.AddNewlyCreatedDBObject(insulationPolyline, true); if (drawPerimeterOfInsulation) { insulationPerimeter.Layer = "0"; softInsulationBlock.AppendEntity(insulationPerimeter); acTrans.AddNewlyCreatedDBObject(insulationPerimeter, true); } var rigidInsulationRef = new BlockReference(inputPoints[0], softInsulationBlock.ObjectId) { Layer = "3-0" }; var currentSpace = (BlockTableRecord)acTrans.GetObject(_documentHelper.Database.CurrentSpaceId, OpenMode.ForWrite); currentSpace.AppendEntity(rigidInsulationRef); acTrans.AddNewlyCreatedDBObject(rigidInsulationRef, true); acTrans.Commit(); } _documentHelper.LayerManipulator.ChangeLayer(oldLayer); }
public void RecalcLevelHeightSignStart() { var objectIdCollection = _editorHelper.PromptForSelection("Select LEVEL Entites:"); if (objectIdCollection.Status != PromptStatus.OK) { return; } var origin = _doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin; var ORIGIN = new Quaternion(0, origin.X, origin.Y, origin.Z); using (var transaction = _doc.TransactionManager.StartTransaction()) { var blockTable = (BlockTable)transaction.GetObject(_db.BlockTableId, OpenMode.ForRead); // TODO : Level must not be hard coded. TDD - convensions test var blockTableRecordLevelSign = (BlockTableRecord)transaction.GetObject(blockTable["Level"], OpenMode.ForWrite); var btrIDs = new UtilityClass().GetAllRefernecesOfBtr(blockTableRecordLevelSign.ObjectId, transaction); foreach (ObjectId asObjId in btrIDs) { var ok = false; for (var i = 0; i < objectIdCollection.Value.GetObjectIds().Length; i++) { if (asObjId == objectIdCollection.Value.GetObjectIds()[i]) { ok = true; break; } } if (ok == false) { continue; } var blockReference = transaction.GetObject(asObjId, OpenMode.ForWrite) as BlockReference; var basePoint = blockReference.Position; var normal = blockReference.Normal; var xAxis = new Point3d(); var testP = new Point3d(); var dbObjectCollection = new DBObjectCollection(); blockReference.Explode(dbObjectCollection); foreach (Entity entity in dbObjectCollection) { if (entity.ColorIndex == 1) { var line = entity as Line; xAxis = line.StartPoint; if (xAxis.DistanceTo(basePoint) < 0.5) { xAxis = line.EndPoint; } } else { var str = entity.GetType().ToString(); if (str.Contains("Poly")) { var polyline = entity as Polyline; testP = polyline.GetLineSegmentAt(1).MidPoint; } } } var op = new Quaternion(0, basePoint.X, basePoint.Y, basePoint.Z); var ox = new Quaternion(0, xAxis.X, xAxis.Y, xAxis.Z); var oz = new Quaternion(0, normal.X, normal.Y, normal.Z); var testQ = new Quaternion(0, testP.X, testP.Y, testP.Z); var ucs = new UCS(op, ox, op + oz); if (ucs.FromACS(testQ).GetZ() < 0) { ucs = new UCS(op, op + oz, ox); } var y = -ucs.FromACS(ORIGIN).GetZ(); foreach (ObjectId attId in blockReference.AttributeCollection) { var attributeReference = (AttributeReference)transaction.GetObject(attId, OpenMode.ForWrite); if (attributeReference.Tag != "LEVEL") { continue; } var oldStr = "\nold = " + attributeReference.TextString; if (double.IsNaN(y)) { y = 0.0; } var mess = y.ToString("0.#####"); attributeReference.TextString = ((mess.Length > 0) ? mess : "0.0"); _doc.Editor.WriteMessage(oldStr + " / " + DateTime.Now.ToString("d")); } } transaction.Commit(); } _logger.Info(MethodBase.GetCurrentMethod().Name); }