getCogoPoint(string prompt1, out ObjectId idCgPnt, ObjectId idCgPntBase, int osMode) { Object mode = SnapMode.getOSnap(); string elev = string.Empty; ObjectId idCogoPnt = ObjectId.Null; idCgPnt = ObjectId.Null; Point3d pnt3dBase = Pub.pnt3dO; Point3d pnt3dX = Pub.pnt3dO; if (idCgPntBase != ObjectId.Null) { pnt3dBase = idCgPntBase.getCogoPntCoordinates(); } bool escape; PromptStatus ps; try { if (pnt3dBase != Pub.pnt3dO) { pnt3dX = UserInput.getPoint(prompt1, pnt3dBase, out escape, out ps, osMode); } else { pnt3dX = UserInput.getPoint(prompt1, out ps, osMode); } if (pnt3dX == Pub.pnt3dO) { return(elev); } ObjectIdCollection ids = new ObjectIdCollection(); BaseObjs._db.forEachMS <CogoPoint>(cg => { if (cg.Location == pnt3dX) { idCogoPnt = cg.ObjectId; ids.Add(idCogoPnt); } }); switch (ids.Count) { case 0: break; case 1: elev = string.Format("{0:F2}", idCogoPnt.getCogoPntElevation()); idCgPnt = idCogoPnt; break; case 2: Application.ShowAlertDialog("Multiple CogoPoints at same location. Exiting..."); break; } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " UserInput.cs: line: 384"); } finally { SnapMode.setOSnap((int)mode); } return(elev); }
addLdrText(string nameCmd, string nameApp, ObjectId idLdr, List <ObjectId> idsCgPnts, string top = "", string bot = "", string bot2 = "", double deltaZ = 0.0, double xFactor = 0.8, bool useBackgroundFill = false, List <Point3d> pnts3dX = null) { string resultTop = top.ToUpper(); string resultBot = bot.ToUpper(); string resultBot2 = bot2.ToUpper(); Point3d pnt3dTop = Pub.pnt3dO; Point3d pnt3dBot = Pub.pnt3dO; Point3d pnt3dLdrMid = Pub.pnt3dO; Point3d pnt3dLdrIns = Pub.pnt3dO; //text insertion point on Ldr before offset Point3d pnt3dLdrEnd = Pub.pnt3dO; Point3d pnt3d1 = Pub.pnt3dO; Point3d pnt3d2 = Pub.pnt3dO; ObjectId idTxTop = ObjectId.Null; //text ObjectId idTxBot = ObjectId.Null; ObjectId idTxBot2 = ObjectId.Null; double angle = 0.0; double scale = Misc.getCurrAnnoScale(); double gapTop = 0.09; double gapBot = 0.09; List <Point3d> pnts3dLdr = new List <Point3d>(); int n = 0; //Application.ShowAlertDialog(idLDR.IsErased.ToString() + idLDR.IsEffectivelyErased.ToString() + idLDR.ToString()); PromptStatus ps = PromptStatus.Cancel; if (nameCmd == "cmdFFD") { pnt3d1 = UserInput.getPoint("Pick Insertion Point for Label: ", out ps, osMode: 0); //Line line = LdrText_JigLine.jigLine(pnt3d1); //angle = line.Angle; //line.ObjectId.delete(); angle = (double)Application.GetSystemVariable("VIEWTWIST"); } else { if (idLdr.IsEffectivelyErased || idLdr.IsErased) { return; } pnts3dLdr = idLdr.getCoordinates3dList(); n = pnts3dLdr.Count; angle = pnts3dLdr[n - 2].getDirection(pnts3dLdr[n - 1]); //angle opposite direction arrow is pointing for GS or direction of 2nd segment of leader if 3 points pnt3dLdrEnd = pnts3dLdr[n - 1]; } double angleTx = 0; AttachmentPoint apTop; AttachmentPoint apBot; string justifyTop = string.Empty; string justifyBot = string.Empty; bool left_justify = Base_Tools45.Math.left_Justify(angle); if (left_justify) { apTop = AttachmentPoint.BottomLeft; apBot = AttachmentPoint.TopLeft; angleTx = angle + pi; justifyTop = Pub.JUSTIFYLEFT; justifyBot = Pub.JUSTIFYLEFT; } else { apTop = AttachmentPoint.BottomRight; apBot = AttachmentPoint.TopRight; angleTx = angle; justifyTop = Pub.JUSTIFYRIGHT; justifyBot = Pub.JUSTIFYRIGHT; } if (cmdsGS.Contains(nameCmd)) { // overrides for GS commands apTop = AttachmentPoint.BottomCenter; justifyTop = Pub.JUSTIFYCENTER; } if (nameCmd == "cmdFFD") { apTop = AttachmentPoint.MiddleCenter; justifyTop = Pub.JUSTIFYCENTER; } if (nameCmd == "cmdDEP") { justifyTop = Pub.JUSTIFYCENTER; } if (bot.Length < 4) { justifyBot = Pub.JUSTIFYCENTER; } double widthTop = 0; double widthBot = 0; double station = 0.0; double offset = 0.0; Txt.setAnnoStyle(); Color color = Misc.getColorByLayer(); switch (nameCmd) { case "cmdFFD": string txtTop = string.Format("{0}{1}{2}", resultTop, @"\P", resultBot); idTxTop = Txt.addMText(txtTop, pnt3d1, angleTx, 0.0, 0.50, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.8, true, backgroundFill: useBackgroundFill); station = 0.0; offset = 0.0; return; case "cmdGS3": pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt()); pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4)); if (left_justify) { pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 5)); } else { pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4)); pnt3dTop = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 5)); } idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.085, apTop, "Annotative", "GRADES", color, justifyTop, AnnotativeStates.True, 0.7, backgroundFill: useBackgroundFill); Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset); pnts3dLdr = new List <Point3d> { idLdr.getBegPnt(), idLdr.getEndPnt(), pnt3dLdrIns }; break; case "cmdGS": case "cmdGS0": case "cmdGSE": case "cmdGSS": case "cmdGSX": case "cmdSL": case "cmdSS": if (nameCmd == "cmdGSX") { gapTop = 0.01; } else { gapTop = 0.09; } pnt3dLdrMid = idLdr.getBegPnt().getMidPoint2d(idLdr.getEndPnt()); pnt3dLdrIns = pnt3dLdrMid.traverse(angle, (0.09 * scale / 2.4)); if (left_justify) { pnt3dTop = pnt3dLdrIns.traverse(angle - pi / 2, (gapTop * scale / 4)); } else { pnt3dTop = pnt3dLdrIns.traverse(angle + pi / 2, (gapTop * scale / 4)); } idTxTop = Txt.addMText(top, pnt3dTop, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill); Geom.getStaOff(idsCgPnts, pnt3dLdrIns, ref station, ref offset); pnts3dLdr = new List <Point3d> { idLdr.getBegPnt(), idLdr.getEndPnt(), pnt3dLdrIns //pnt3dM - on ldr opposite text insertion point }; break; default: idTxTop = Txt.addMText(resultTop, pnt3dLdrEnd, angleTx, 0.0, 0.09, apTop, "Annotative", "GRADES", color, justifyTop, backgroundFill: useBackgroundFill); widthTop = idTxTop.getMTextWidth(); if (resultBot != string.Empty) { idTxBot = Txt.addMText(resultBot, pnt3dLdrEnd, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill); } if (resultBot2 != string.Empty) { pnt3dBot = pnt3dLdrEnd.traverse(angleTx - pi / 2, (.14 * scale)); idTxBot2 = Txt.addMText(resultBot2, pnt3dBot, angleTx, 0.0, 0.09, apBot, "Annotative", "GRADES", color, justifyBot, backgroundFill: useBackgroundFill); } station = 0.0; offset = 0.0; break; } if (resultBot == string.Empty || nameCmd == "cmdFFD") { widthBot = 0; } else { widthBot = idTxBot.getMTextWidth(); } double width = 0; if (widthBot > widthTop) { width = widthBot; } else { width = widthTop; } //Adjust callout leader length if (!cmdsGS.Contains(nameCmd)) { if (nameCmd == "cmdFLX" || nameCmd == "cmdGX") { gapTop = 0.01; gapBot = 0.08; } else { gapTop = 0.09; gapBot = 0.09; } Point3d pnt3dLdrEndAdj = pnts3dLdr[n - 2].traverse(angle, width); //reseting leader endpoint based on text width idLdr.adjLdrEndPnt(pnt3dLdrEndAdj); pnts3dLdr = idLdr.getCoordinates3dList(); if (left_justify) { pnt3dTop = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapTop * scale / 4); pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapBot * scale / 4); } else { pnt3dTop = pnt3dLdrEndAdj.traverse(angle + pi / 2, gapTop * scale / 4); pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, gapBot * scale / 4); } idTxTop.adjMTextXYandAngle(pnt3dTop, angleTx, width); if (idTxBot != ObjectId.Null) { idTxBot.adjMTextXYandAngle(pnt3dBot, angleTx, width); } if (idTxBot2 != ObjectId.Null) { if (left_justify) { pnt3dBot = pnt3dLdrEndAdj.traverse(angle + pi / 2, 0.14 * scale); } else { pnt3dBot = pnt3dLdrEndAdj.traverse(angle - pi / 2, 0.14 * scale); } idTxBot2.adjMTextXYandAngle(pnt3dBot, angleTx, width); } } idLdr.moveToTop(); //Add XData if (nameCmd != "cmdRDR" && nameCmd != "cmdSW") { if (idTxTop.IsValid) { addXDataLnks(nameApp, nameCmd, idLdr, idTxTop, idTxBot, idTxBot2, pnt3dTop, scale, deltaZ, pnts3dLdr, idsCgPnts, station, offset, pnts3dX); } else { return; } //addMTextIdToAppDict(nameApp, idTxTop); } }