public static void SaveSelection() { var ids = Interaction.GetPickSet(); if (ids.Length == 0) { Interaction.WriteLine("No entity selected."); return; } string name = Interaction.GetString("\nSelection name"); if (name == null) { return; } if (CustomDictionary.GetValue("Selections", name) != string.Empty) { Interaction.WriteLine("Selection with the same name already exists."); return; } var handles = ids.QSelect(entity => entity.Handle.Value.ToString()).ToArray(); string dictValue = string.Join("|", handles); CustomDictionary.SetValue("Selections", name, dictValue); }
/// <summary> /// View entities interactively. /// </summary> /// <param name="entityIds">The entity IDs.</param> /// <param name="action">The action.</param> public static void ZoomHighlightView(List <ObjectId> entityIds, Action <int> action = null) // newly 20130815 { if (entityIds.Count > 0) { var highlightIds = new List <ObjectId>(); while (true) { string input = Interaction.GetString("\nType in a number to view, press ENTER to exit: "); if (input == null) { break; } var index = Convert.ToInt32(input); if (index <= 0 || index > entityIds.Count) { Interaction.WriteLine("Invalid entity number."); continue; } action?.Invoke(index); highlightIds.Clear(); highlightIds.Add(entityIds[index - 1]); Interaction.ZoomObjects(highlightIds); Interaction.HighlightObjects(highlightIds); } } }
public static void ShowExtents() // newly 20130815 { var ids = Interaction.GetSelection("\nSelect entity"); var extents = ids.GetExtents(); var rectId = Draw.Rectang(extents.MinPoint, extents.MaxPoint); Interaction.GetString("\nPress ENTER to exit..."); rectId.QOpenForWrite(rect => rect.Erase()); }
public static void PolylineInfo() // mod by WY 20130202 { var id = Interaction.GetEntity("\nSpecify a polyline", typeof(Polyline)); if (id == ObjectId.Null) { return; } var poly = id.QOpenForRead <Polyline>(); for (int i = 0; i <= poly.EndParam; i++) { Interaction.WriteLine("[Point {0}] coord: {1}; bulge: {2}", i, poly.GetPointAtParameter(i), poly.GetBulgeAt(i)); } var txtIds = new List <ObjectId>(); double height = poly.GeometricExtents.MaxPoint.DistanceTo(poly.GeometricExtents.MinPoint) / 50.0; for (int i = 0; i < poly.NumberOfVertices; i++) { txtIds.Add(Draw.MText(i.ToString(), height, poly.GetPointAtParameter(i), 0, true)); } Interaction.GetString("\nPress ENTER to exit"); txtIds.QForEach(mt => mt.Erase()); }