/// <summary> /// TODO /// </summary> /// <returns></returns> public string PrintInfo(bool supressPartName, int count = 0) { var acCurDb = Application.DocumentManager.MdiActiveDocument.Database; //Get variables to strings var countStr = count.ToString(); var objIdStr = ObjId.ToString(); var lengthStr = acCurDb.ConvertToDwgUnits(Length); var widthStr = acCurDb.ConvertToDwgUnits(Width); var thickStr = acCurDb.ConvertToDwgUnits(Thickness); var volStr = acCurDb.ConvertToDwgUnits(Volume); var asymStr = Asymmetry.RoundToTolerance(); //Remove parenthesis from ObjIds objIdStr = objIdStr.Replace("(", string.Empty); objIdStr = objIdStr.Replace(")", string.Empty); if (count < 10) { countStr = "0" + countStr; } var prntStr = string.Empty; if (count > 0) { prntStr += count + ":"; } if (!supressPartName) { if (!string.IsNullOrEmpty(RcName)) { prntStr += RcName; } else { prntStr += " #" + objIdStr; } } prntStr += " - L:" + lengthStr + " W:" + widthStr + " T:" + thickStr + " V:" + volStr + " A:" + asymStr + " [" + AsymVStr(AsymmetryVector) + "] P:" + ProdType; //Print to the current editor return(prntStr); }
/// <summary> /// TODO /// </summary> /// <param name="acSol"></param> private void ReadEntity(Solid3d acSol, Database acCurDb, Transaction acTrans) { RcName = acSol.GetPartName(); ParentHandle = acSol.GetParent(); ChildHandles = acSol.GetChildren(); IsSweep = acSol.GetIsSweep(); IsMirror = acSol.GetIsMirror(); RcInfo = acSol.GetPartInfo(); RcQtyOf = acSol.GetQtyOf(); RcQtyTotal = acSol.GetQtyTotal(); TxDirection = acSol.GetTextureDirection(); GetRotationMatrices(acSol); GetLayMatrix(acSol); if (LayMatrix == new Matrix3d()) { LayMatrix = GetAbstractMatrix(acSol); } using (var solCopy = acSol.Clone() as Solid3d) { if (solCopy != null) { if (LayMatrix != Matrix3d.Identity) { solCopy.TransformBy(LayMatrix); } //Get Volume & Extents Extents = solCopy.GetBounds(); MinExt = Extents.MinPoint; MaxExt = Extents.MaxPoint; Centroid = solCopy.MassProperties.Centroid; Box = Extents.Volume(); Volume = acSol.Volume(); } } var identity = Matrix3d.Identity; if ((MaxExt.Z + MinExt.Z) / 2 < 0) { var vector3D = new Vector3d(0, 1, 0); identity = Matrix3d.Rotation(3.14159265358979, vector3D, new Point3d()); LayMatrix *= identity; } if (IsBox) { Asymmetry = 0; } else { var boxCen = GetBoxCenter(MinExt, MaxExt).RoundToTolerance(); AsymmetryVector = boxCen.GetVectorTo(Centroid.RoundToTolerance()); AsymmetryVector = AsymmetryVector.TransformBy(identity); Asymmetry = AsymmetryVector.Length; if (!Asymmetry.IsLessThanTol()) { Asymmetry = Asymmetry.RoundToTolerance(); } else { Asymmetry = 0; } AsymmetryVector = AsymmetryVector.RoundToTolerance(); if (Asymmetry > 0) { FixMatrix(boxCen); } AsymString = AsymVStr(AsymmetryVector); } //Get length, width, thickness if (IsSweep) { //TODO } else { var measures = new List <double>(3) { MaxExt.X - MinExt.X, MaxExt.Y - MinExt.Y, MaxExt.Z - MinExt.Z }; measures.Sort(); if (TxDirection == TextureDirection.Across) { Width = measures[2].RoundToTolerance(); Length = measures[1].RoundToTolerance(); } else { Length = measures[2].RoundToTolerance(); Width = measures[1].RoundToTolerance(); } Thickness = measures[0].RoundToTolerance(); } //Add the XData acSol.AddXData(this, acCurDb, acTrans); }