Esempio n. 1
0
        /// <summary>
        ///  creating leader text on a sheet.
        /// Before running this sample, open a drawing document and select a linear drawing edge.
        /// </summary>
        /// <remarks></remarks>
        public void AddLeaderNote()
        {
            // Set a reference to the drawing document.
            // This assumes a drawing document is active.
            DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument;

            // Set a reference to the active sheet.
            Sheet oActiveSheet = oDrawDoc.ActiveSheet;

            // Set a reference to the drawing curve segment.
            // This assumes that a drawing curve is selected.
            DrawingCurveSegment oDrawingCurveSegment = oDrawDoc.SelectSet[1];

            // Set a reference to the drawing curve.
            DrawingCurve oDrawingCurve = oDrawingCurveSegment.Parent;

            // Get the mid point of the selected curve
            // assuming that the selected curve is linear
            Point2d oMidPoint = oDrawingCurve.MidPoint;

            // Set a reference to the TransientGeometry object.
            TransientGeometry oTG = _InvApplication.TransientGeometry;

            ObjectCollection oLeaderPoints = _InvApplication.TransientObjects.CreateObjectCollection();

            // Create a few leader points.
            oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10));
            oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5));

            // Create an intent and add to the leader points collection.
            // This is the geometry that the leader text will attach to.
            GeometryIntent oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve);

            oLeaderPoints.Add(oGeometryIntent);

            // Create text with simple string as input. Since this doesn't use
            // any text overrides, it will default to the active text style.
            string sText = null;

            sText = "API Leader Note";

            LeaderNote oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText);

            // Insert a node.
            LeaderNode oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes[1];

            LeaderNode oSecondNode = oFirstNode.ChildNodes[1];

            oFirstNode.InsertNode(oSecondNode, oTG.CreatePoint2d(oMidPoint.X + 5, oMidPoint.Y + 5));
        }