Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to use graphics.Text2D() method to render Text

HusseinOthman75
Enthusiast

How to use graphics.Text2D() method to render Text

HusseinOthman75
Enthusiast
Enthusiast

I Want to use graphics.Text2D() to render text on a selected Model Item. Can you please give example on using Text2D() to implement this task. Your help is highly appreciated

0 Likes
Reply
396 Views
4 Replies
Replies (4)

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @HusseinOthman75 ,

 

Does this help?

 

namespace Navisworks_2023
{
    [PluginAttribute("Navis2023", "ADSK", ToolTip = "Run 2023 code", DisplayName = "Your Display Name Here")]
    public class Class1 : RenderPlugin
    {

        public override void OverlayRender(View view, Graphics graphics)
        {
            graphics.BeginWindowContext();

            // draw text
            graphics.Color(Color.Red, 1.0);
            graphics.Text2D(new TextFontInfo("typeFace", 10, 10, true, false), "Your Text Here", Point2D.Origin, (int)100, (int)100);

            // end overlay
            graphics.EndWindowContext();
        }
    }
}

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

HusseinOthman75
Enthusiast
Enthusiast
Thank you very much, sppreciate your reply, very much helpful, just one issue remaining, i have Point3D represents the center of model item, how can i get Pint2D. Thanks in advance
0 Likes

RAVERADESIGNER
Participant
Participant

how  should i assign the graphics object? (where can i find it?)

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @RAVERADESIGNER ,

 

You do not need to explicitly assign or create the graphics object; it is managed and provided by Navisworks' rendering system when the OverlayRender method is invoked.

To utilize the OverlayRender method, you must implement the RenderPlugin interface.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes