// Labeling profil names private static void LabelingProfileName(DataStruct.MillingElement millingElement, Transaction acTrans, BlockTableRecord acBlkTblRec, Database acCurDb) { double deltaRefTextX = -3.0; double deltaRefTextY = 0; // Open the Block table for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // set necessary layer MillingDataEngine.Func.Layers.SetAsCurrent("Texts", acCurDb); // Create a single-line text object for Profile name DBText acText = new DBText(); acText.SetDatabaseDefaults(); acText.Justify = AttachmentPoint.MiddleCenter; acText.AlignmentPoint = new Point3d(millingElement.StartPoint.CoordinateX + deltaRefTextX, 50 + deltaRefTextY, millingElement.StartPoint.CoordinateZ); acText.Height = 0.5; acText.TextString = millingElement.ProfileName; acText.Rotation = 1.57; // add text to block table and transaction acBlkTblRec.AppendEntity(acText); acTrans.AddNewlyCreatedDBObject(acText, true); }
// Labeling profil stations private static void LabelingProfileStation(DataStruct.MillingElement millingElement, Transaction acTrans, BlockTableRecord acBlkTblRec, Database acCurDb) { double deltaRefTextX = -2.4; double deltaRefTextY = 0; // Open the Block table for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // set necessary layer MillingDataEngine.Func.Layers.SetAsCurrent("Texts", acCurDb); // Create a single-line text object for Profile name DBText acText = new DBText(); acText.SetDatabaseDefaults(); acText.Justify = AttachmentPoint.MiddleCenter; acText.AlignmentPoint = new Point3d(millingElement.StartPoint.CoordinateX + deltaRefTextX, 50 + deltaRefTextY, millingElement.StartPoint.CoordinateZ); acText.Height = 0.5; string stringToPut = millingElement.Station.ToString(); if (stringToPut.Contains('.')) { int stringLength = stringToPut.Length; int positionOfDecimal = stringToPut.IndexOf('.'); string afterDecimal = stringToPut.Substring(positionOfDecimal); stringToPut = AddPlusToStation(stringToPut.Substring(0, positionOfDecimal)) + afterDecimal; } else { stringToPut = AddPlusToStation(stringToPut); stringToPut = stringToPut + ".00"; } acText.TextString = stringToPut; acText.Rotation = 1.57; // add text to block table and transaction acBlkTblRec.AppendEntity(acText); acTrans.AddNewlyCreatedDBObject(acText, true); }
private static void LabelingMillingEndDepth(DataStruct.MillingElement millingElement, Transaction acTrans, BlockTableRecord acBlkTblRec, Database acCurDb, double deltaRefTextX = 0.35, double textHight = 0.25, double deltaYref = 0) { //double deltaRefTextX = 0.35; // Open the Block table for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // set necessary layer MillingDataEngine.Func.Layers.SetAsCurrent("MillingDepth", acCurDb); // Create a single-line text object for milling depth DBText acText = new DBText(); acText.SetDatabaseDefaults(); acText.Position = new Point3d(millingElement.EndPoint.CoordinateX + deltaRefTextX, millingElement.EndPoint.CoordinateY + deltaYref, millingElement.EndPoint.CoordinateZ); acText.Height = textHight; int roundedMillingDepth = Convert.ToInt32(Math.Round(millingElement.EndMillingDepth, 0)); if (roundedMillingDepth == 0) { acText.TextString = roundedMillingDepth + "cm"; } else { acText.TextString = "-" + roundedMillingDepth + "cm"; } // add text to block table and transaction acBlkTblRec.AppendEntity(acText); acTrans.AddNewlyCreatedDBObject(acText, true); }
private static List <DataStruct.MillingElement> ConvertMillingElementsInDiffRanges_New(double station, string profilName, double elementStart, double elementWidth, double startMillingDepth, double endMillingDepth, double multiplier, List <DataStruct.MillingElement> theListToReturn = null, int rangeCounter = -1, double[][] theMillingRangess = null) { if (theListToReturn == null) { theListToReturn = new List <DataStruct.MillingElement>(); } if (elementWidth <= 0) { return(theListToReturn); } double[][] theMillingRanges = new double[][] { }; if (theMillingRangess == null) { double[] lastPosibleRange = new double[2] { DataStruct.MillingElement.MillingRange_3[1], 100 }; List <double[]> theMillingRangesList = new List <double[]>(); foreach (var item in DataStruct.MillingElement.MillingRanges) { theMillingRangesList.Add(item); } theMillingRangesList.Add(lastPosibleRange); theMillingRanges = theMillingRangesList.ToArray(); } else { theMillingRanges = theMillingRangess; } bool isFirstMillingDepthLarger = startMillingDepth > endMillingDepth; if (isFirstMillingDepthLarger) { if (rangeCounter < 0) { rangeCounter = theMillingRanges.Length - 1; } if (startMillingDepth <= 0) { return(theListToReturn); } else { if (startMillingDepth < theMillingRanges[rangeCounter][0]) { rangeCounter--; ConvertMillingElementsInDiffRanges_New(station, profilName, elementStart, elementWidth, startMillingDepth, endMillingDepth, multiplier, theListToReturn, rangeCounter, theMillingRanges); } else { if (endMillingDepth < theMillingRanges[rangeCounter][0]) { double tempStartMilingDepth = startMillingDepth; double tempEndMillingDepth = theMillingRanges[rangeCounter][0]; double tempMillingLength = findMillingLenght(tempStartMilingDepth, tempEndMillingDepth, multiplier); theListToReturn.Add(new DataStruct.MillingElement(station, profilName, elementStart, tempMillingLength, tempStartMilingDepth, tempEndMillingDepth)); double tempElementStart = elementStart - tempMillingLength; double tempElementWidth = elementWidth - tempMillingLength; rangeCounter--; ConvertMillingElementsInDiffRanges_New(station, profilName, tempElementStart, tempElementWidth, tempEndMillingDepth, endMillingDepth, multiplier, theListToReturn, rangeCounter, theMillingRanges); } else { DataStruct.MillingElement tempMillingElement = new DataStruct.MillingElement(station, profilName, elementStart, elementWidth, startMillingDepth, endMillingDepth); theListToReturn.Add(tempMillingElement); } } } } else { if (rangeCounter < 0) { rangeCounter = 0; } if (startMillingDepth < 0) { double tempEndMillingDepth = theMillingRanges[0][0]; double tempStartMillingDepth = startMillingDepth; double tempMillingLength = findMillingLenght(tempStartMillingDepth, tempEndMillingDepth, multiplier); double tempElementSart = elementStart - tempMillingLength; double tempElementWidt = elementWidth - tempMillingLength; ConvertMillingElementsInDiffRanges_New(station, profilName, tempElementSart, tempElementWidt, tempEndMillingDepth, endMillingDepth, multiplier, theListToReturn, rangeCounter, theMillingRanges); } else { if (startMillingDepth > theMillingRanges[rangeCounter][1]) { rangeCounter++; ConvertMillingElementsInDiffRanges_New(station, profilName, elementStart, elementWidth, startMillingDepth, endMillingDepth, multiplier, theListToReturn, rangeCounter, theMillingRanges); } else { if (endMillingDepth > theMillingRanges[rangeCounter][1]) { double tempEndMillingDepth = theMillingRanges[rangeCounter][1]; double tempStartMilingDepth = startMillingDepth; double tempMillingLength = findMillingLenght(tempStartMilingDepth, tempEndMillingDepth, multiplier); theListToReturn.Add(new DataStruct.MillingElement(station, profilName, elementStart, tempMillingLength, tempStartMilingDepth, tempEndMillingDepth)); double tempElementStart = elementStart - tempMillingLength; double tempElementWidth = elementWidth - tempMillingLength; rangeCounter++; ConvertMillingElementsInDiffRanges_New(station, profilName, tempElementStart, tempElementWidth, tempEndMillingDepth, endMillingDepth, multiplier, theListToReturn, rangeCounter, theMillingRanges); } else { theListToReturn.Add(new DataStruct.MillingElement(station, profilName, elementStart, elementWidth, startMillingDepth, endMillingDepth)); return(theListToReturn); } } } } return(theListToReturn); }