public TextGraphics DrawText(
            string text,
            bool scalable,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

                if (node == null)
                {
                    node = graphicsData.ClientGraphics.AddNode(
                        graphicsData.GetGraphicNodeFreeId());
                }

                TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics());

                graphic.Text = text;

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
        public TextGraphics DrawText(
            string text,
            bool scalable,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

                if (node == null)
                {
                    node = graphicsData.ClientGraphics.AddNode(
                        graphicsData.GetGraphicNodeFreeId());
                }

                TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics());

                graphic.Text = text;

                return graphic;
            }
            catch
            {
                return null;
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a TextGraphics with different styles and properties.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void TextGraphicsDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

            string clientId = "{Add-in Guid}";

            ClientGraphics   graphics = null;
            GraphicsDataSets dataSets = null;

            try
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId];
                dataSets = doc.GraphicsDataSetsCollection[clientId];
            }
            catch
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);
                dataSets = doc.GraphicsDataSetsCollection.Add(clientId);
            }

            TransientGeometry Tg = AdnInventorUtilities.InvApplication.TransientGeometry;

            GraphicsNode node = graphics.AddNode(graphics.Count + 1);

            //Create scalable text graphics
            TextGraphics scalableTxt = node.AddScalableTextGraphics();

            //Set the properties of the text
            scalableTxt.Text                = "Scalable Text";
            scalableTxt.Anchor              = Tg.CreatePoint(0, 20, 0);
            scalableTxt.Bold                = true;
            scalableTxt.Font                = "Arial";
            scalableTxt.FontSize            = 10;
            scalableTxt.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft;
            scalableTxt.Italic              = true;
            scalableTxt.PutTextColor(119, 187, 17);
            scalableTxt.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle;


            //Create anchored text graphics
            TextGraphics anchoredTxt = node.AddTextGraphics();

            //Set the properties of the text.
            anchoredTxt.Text     = "Anchored Text";
            anchoredTxt.Bold     = true;
            anchoredTxt.FontSize = 30;
            anchoredTxt.PutTextColor(255, 170, 0);

            Point anchorPoint = Tg.CreatePoint(1, 1, 1);

            //Set the text's anchor in model space.
            anchoredTxt.Anchor = anchorPoint;

            //Anchor the text graphics in the view.
            anchoredTxt.SetViewSpaceAnchor(
                anchorPoint,
                Tg.CreatePoint2d(30, 30),
                ViewLayoutEnum.kTopLeftViewCorner);


            TextGraphics symbolTxt1 = node.AddTextGraphics();

            symbolTxt1.Text = "n ";

            Point modelAnchorPoint = Tg.CreatePoint(50, 0, 0);

            //Because this text will have pixel scaling behavior these coordinates are in pixel space.
            symbolTxt1.Anchor              = Tg.CreatePoint(0, 0, 0);
            symbolTxt1.Font                = "AIGDT";
            symbolTxt1.FontSize            = 25;
            symbolTxt1.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft;
            symbolTxt1.PutTextColor(221, 0, 0);
            symbolTxt1.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle;
            symbolTxt1.SetTransformBehavior(
                modelAnchorPoint,
                DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling,
                1);

            Box box = symbolTxt1.RangeBox;

            //Draw the next section of the string relative to the first section.
            TextGraphics symbolTxt2 = node.AddTextGraphics();

            symbolTxt2.Text = "9.4 - 9.8";

            //The range of the previous character is used to determine where to position
            //the next string. The range is returned in pixels.
            symbolTxt2.Anchor = Tg.CreatePoint(box.MaxPoint.X, 0, 0);

            symbolTxt2.Font                = "Arial";
            symbolTxt2.FontSize            = 25;
            symbolTxt2.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft;
            symbolTxt2.PutTextColor(221, 0, 0);
            symbolTxt2.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle;
            symbolTxt2.SetTransformBehavior(
                modelAnchorPoint,
                DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling,
                1);

            doc.Views[1].Update();
        }