/// <summary> /// Prompts a user to place the current tag. /// </summary> public void Place() { if (!Application.IsConnected) { throw SprExceptions.SprNotConnected; } if (IsPlaced) { throw new SprException("Tag {0} is already placed", Id); } var tagOrigin = new SprPoint3D(); // Get an object on screen and set the origin point to its location Application.HighlightClear(); var objId = Application.GetObjectId("SELECT TAG START POINT", ref tagOrigin); if (objId == 0) { Application.Windows.TextWindow.Text = "Tag placement canceled."; return; } // Highlight the selected object Application.HighlightObject(objId, Color.Fuchsia); // Get the tag leader point using the origin for depth var tagLeader = Application.GetPoint("SELECT TAG LEADER LOCATION", tagOrigin); if (tagLeader == null) { Application.HighlightClear(); Application.Windows.TextWindow.Text = "Tag placement canceled."; return; } _linkedObject = Application.GetObjectData(objId); Flags |= SprConstants.SprTagLabel; Id = Application.NextTag; // Set the tag registry values SprUtilities.SetTagRegistry(this); // Place the tag Application.SprStatus = Application.DrApi.TagSetDbl(Id, 0, Flags, ref tagLeader.DrPointDbl, ref tagOrigin.DrPointDbl, LinkedObject.Linkage.DrKey, Text); if (Application.SprStatus != 0) { throw Application.SprException; } //IsPlaced = true; _leaderPoint = tagLeader; _originPoint = tagOrigin; Application.Tags.Add(this); Refresh(); // Clear the tag registry SprUtilities.ClearTagRegistry(); SendToTextWindow(); Application.HighlightClear(); Application.SprStatus = Application.DrApi.ViewUpdate(1); if (Application.SprStatus != 0) { throw Application.SprException; } }
/// <summary> /// Prompts a user to select new leader points for an existing tag. /// DisplayLeader will automatically be set to true. /// </summary> public void EditLeader() { if (!Application.IsConnected) { throw SprExceptions.SprNotConnected; } if (!IsPlaced) { throw new SprException("Tag {0} is not placed.", Id); } var tagOrigin = new SprPoint3D(); // Get an object on screen and set the origin point to its location Application.HighlightClear(); var objId = Application.GetObjectId("SELECT NEW TAG START POINT", ref tagOrigin); if (objId == 0) { Application.Windows.TextWindow.Text = "Tag placement canceled."; return; } // Highlight the selected object Application.HighlightObject(objId, Color.Fuchsia); // Get the tag leader point on screen var tagLeader = Application.GetPoint("SELECT NEW LEADER LOCATION", tagOrigin); if (tagLeader == null) { Application.HighlightClear(); Application.Windows.TextWindow.Text = "Tag placement canceled."; return; } _linkedObject = Application.GetObjectData(objId); DisplayLeader = true; Flags |= SprConstants.SprTagLabel; Flags |= SprConstants.SprTagEdit; // Update the tag with the new leader points Application.SprStatus = Application.DrApi.TagSetDbl(Id, 0, Flags, tagLeader.DrPointDbl, tagOrigin.DrPointDbl, LinkedObject.Linkage.DrKey, Text); if (Application.SprStatus != 0) { throw Application.SprException; } Refresh(); // Flip the tag 180 degrees. Intergraph is AWESOME! var swap = LeaderPoint; LeaderPoint = OriginPoint; OriginPoint = swap; Update(); SendToTextWindow(); Application.HighlightClear(); Application.SprStatus = Application.DrApi.ViewUpdate(1); if (Application.SprStatus != 0) { throw Application.SprException; } }