Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Center text and click events in RenderPlugin

4 REPLIES 4
Reply
Message 1 of 5
igor.barcelosC54YD
187 Views, 4 Replies

Center text and click events in RenderPlugin

Hi, 

 

Following this post https://forums.autodesk.com/t5/navisworks-api/create-tags-redlines-in-the-api/m-p/12694487#M7485 I could integrate some MarkUps in my view using the RenderPlugin as shown below : 

igorbarcelosC54YD_0-1712735150379.png

 

I have two more questions :

1/ How can I center the text inside the markup's circle ? I imagine that I would need some function to measure the text in order to properly calculate the coordinates. 

 

2/ How can I create click events in those markups ? 

 

Thank you all for your attention. 

4 REPLIES 4
Message 2 of 5

Hi,

 

1/ Use graphics.Text2DExtends to measure the box of your text, then use half the witdh and height to center it.

2/ Create an InputPlugin, inside MouseDown event check if the mouse (x and y) is over one of your markup.

Good luck

Message 3 of 5

Hi, thanks a lot for your return. 

I could manage to center my text using the TextExtents2D tool like below : 

igorbarcelosC54YD_0-1712819303816.pngigorbarcelosC54YD_1-1712819318811.png

 

I will try to implement the click events in the following days.

Thanks 

 

Message 4 of 5

Quick suggestion.
If you draw thousands of these, computing Text extends in the rendering loop (and also creating new TextFontInfo) is very CPU intensive.
I recommend to:
- compute the text extend once and store the value with the text itself (in an array of struct for exemple)
- for the TextFontInfo, if you use the same for all texts, just create it once and store it in your Renderer
Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
Message 5 of 5

Nice btw!
Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report