How can I calculate Text Note height without making a commit for performance

How can I calculate Text Note height without making a commit for performance

WorldDue
Enthusiast Enthusiast
680 Views
2 Replies
Message 1 of 3

How can I calculate Text Note height without making a commit for performance

WorldDue
Enthusiast
Enthusiast

Hello,

In case of inserting many Text notes, I want to commit once without making sub Transactions or such which is costly to performance.

 

So how can I pre-calculate the text height in C#

Can I use the Graphics.MeasureString() function? If so how can I set the size and width of the TextNoteType in C# Graphics module, and also what about the units used in both the API and the Graphics c# class..

 

Thanks.

0 Likes
Accepted solutions (1)
681 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

Well, apparently querying the bounding box requires a regeneration; that is a lot less heavy than a sub-transaction or transaction:

 

https://thebuildingcoder.typepad.com/blog/2016/05/idea-station-and-textnote-bounding-box.html#3

 

Here is a sample showing how to use MeasureText:

 

https://thebuildingcoder.typepad.com/blog/2014/10/new-text-note-and-text-width-calculation.html

 

I hope that is useful.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

jeremy_tammik
Alumni
Alumni

I just noticed that you already studied this related solution:

 

https://forums.autodesk.com/t5/revit-api-forum/textnote-height/m-p/8045275

 

Adding the pointer for others searching the same...

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes