protected override bool WorldDraw(WorldDraw draw) { var wg = draw.Geometry; if (wg != null) { var arrId = AutocadHelpers.GetArrowObjectId(AutocadHelpers.StandardArrowhead._NONE); var mText = new MText { Contents = MlText, Location = _secondPoint, Annotative = AnnotativeStates.True }; mText.SetDatabaseDefaults(); _mLeader = new MLeader(); var ldNum = _mLeader.AddLeader(); _mLeader.AddLeaderLine(ldNum); _mLeader.ContentType = ContentType.MTextContent; _mLeader.ArrowSymbolId = arrId; _mLeader.MText = mText; _mLeader.TextAlignmentType = TextAlignmentType.LeftAlignment; _mLeader.TextAttachmentType = TextAttachmentType.AttachmentBottomOfTopLine; _mLeader.TextAngleType = TextAngleType.HorizontalAngle; _mLeader.EnableAnnotationScale = true; _mLeader.Annotative = AnnotativeStates.True; _mLeader.AddFirstVertex(ldNum, FirstPoint); _mLeader.AddLastVertex(ldNum, _secondPoint); _mLeader.LeaderLineType = LeaderType.StraightLeader; _mLeader.SetDatabaseDefaults(); draw.Geometry.Draw(_mLeader); } return(true); }
public static void StartFunction() { #if !DEBUG Statistic.SendCommandStarting(ModPlusConnector.Instance); #endif var doc = Application.DocumentManager.MdiActiveDocument; var db = doc.Database; var ed = doc.Editor; // Событие наведения курсора на объект ed.TurnForcedPickOn(); ed.PointMonitor += Arc2Line_EdOnPointMonitor; try { while (true) { var peo = new PromptEntityOptions($"\n{Language.GetItem(PlinesEditFunction.LangItem, "k15")}:") { AllowNone = false, AllowObjectOnLockedLayer = true }; peo.SetRejectMessage($"\n{Language.GetItem(PlinesEditFunction.LangItem, "wrong")}"); peo.AddAllowedClass(typeof(Polyline), true); var per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) { return; } var polylineId = per.ObjectId; var pickedPt = AutocadHelpers.UcsToWcs(per.PickedPoint); using (doc.LockDocument()) { using (var tr = db.TransactionManager.StartTransaction()) { var dbObj = tr.GetObject(polylineId, OpenMode.ForRead); if (dbObj is Polyline polyline) { var p = polyline.GetClosestPointTo(pickedPt, false); var param = polyline.GetParameterAtPoint(p); var vx = Convert.ToInt32(Math.Truncate(param)); if (polyline.GetSegmentType(vx) == SegmentType.Arc) { polyline.UpgradeOpen(); polyline.SetBulgeAt(vx, 0.0); } } tr.Commit(); } } } } catch (System.Exception exception) { ExceptionBox.Show(exception); } finally { ed.TurnForcedPickOn(); ed.PointMonitor -= Arc2Line_EdOnPointMonitor; } }