protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var gp = new GetPoint(); gp.SetCommandPrompt("Start point"); gp.AddOptionEnumList("Justification", m_justification); gp.ConstrainToConstructionPlane(false); for (;;) { var res = gp.Get(); if (res == GetResult.Option) { var option = gp.Option(); if (null != option) { var list = Enum.GetValues(typeof(TextJustification)).Cast <TextJustification>().ToList(); m_justification = list[option.CurrentListOptionIndex]; } continue; } if (res != GetResult.Point) { return(Result.Cancel); } break; } var point = gp.Point(); var plane = gp.View().ActiveViewport.ConstructionPlane(); plane.Origin = point; var text = new TextEntity { Plane = plane, Justification = m_justification }; text.PlainText = text.Justification.ToString(); var attr = new ObjectAttributes { ColorSource = ObjectColorSource.ColorFromObject, ObjectColor = Color.FromArgb(0, 0, 255) }; var object_id = doc.Objects.AddText(text, attr); RhinoApp.WriteLine("{0}", object_id.ToString()); doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Start point"); gp.AddOptionEnumList("Justification", m_justification); gp.ConstrainToConstructionPlane(false); for (;;) { GetResult res = gp.Get(); if (res == GetResult.Option) { CommandLineOption option = gp.Option(); if (null != option) { List <TextJustification> list = Enum.GetValues(typeof(TextJustification)).Cast <TextJustification>().ToList(); m_justification = list[option.CurrentListOptionIndex]; } continue; } else if (res != GetResult.Point) { return(Result.Cancel); } break; } Point3d point = gp.Point(); Plane plane = gp.View().ActiveViewport.ConstructionPlane(); plane.Origin = point; TextEntity text = new TextEntity(); text.Plane = plane; text.Justification = m_justification; text.Text = text.Justification.ToString(); doc.Objects.AddPoint(point); doc.Objects.AddText(text); doc.Views.Redraw(); return(Result.Success); }