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

Textnote - vertical alignment on line i Revit 2016?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
mobj
1827 Views, 7 Replies

Textnote - vertical alignment on line i Revit 2016?

I've managed to position textnotes rotated along lines.

rotate_text.png

 

Now, I need to set the vertical alignment of the text, so the text is centered on the lines:

rotate_text_aligned.png

In Revit 2015 I used the TextAlignFlags.TEF_ALIGN_MIDDLE, but it seems to be removed in 2016.

 

Is there method to align the vertical position of the text, or do I have to calculate a new position of the text according to text height and scale?

Morten Bastue Jacobsen
Rambøll Danmark A/S
www.ramboll.dk
7 REPLIES 7
Message 2 of 8
matthew_taylor
in reply to: mobj

Hi @mobj,

<rant>

The (frustrating) omission of the vertical text alignment mimics the user interface. Gah.

Labels in tag families do have a modifiable vertical alignment, but these can't often be rotated. Gah.

 

So you're in the frustrating position of working out the text position manually. Gah.

 

Enough to drive you gaga? 😉

 

It seems to me that the Revit developers have a mandate to stay away from simple drawing objects such as lines and text, and lean towards smarter objects like line-based families and tags. I commend that (if that is what is happening), but it also drives me nuts at times.

 

</rant>

 

I was in the situation you are in. I ended up creating a line-based family with a nested annotation symbol in it. I needed to programmatically manage some of the family placement/scale etc. The bonus of this was that it allowed the user to modify the lines once placed (without needing an iUpdater to do so).

 

If you just want text, you may be able to get away with getting the centre of the text bounding box and moving it to the midpoint of your line. You'll probably need two transactions to do that.

 

Cheers,

 

-Matt

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 8
jeremytammik
in reply to: mobj

Dear Morten,

 

Thank you for your query.

 

Is it possible to achieve what you show in your second figure using a custom line type?

 

Here are two solutions that come up immediately in an Internet search:

 

Creating linetype with text to represent utility and fence lines -- https://knowledge.autodesk.com/support/revit-products/troubleshooting/caas/sfdcarticles/sfdcarticles...

 

https://www.youtube.com/watch?v=swR-zJkc1fQ

 

The YouTube video is in Russian, by jivkomitev2 🙂

 

Both approaches above seem rather complicated to set up.

 

I have no idea off-hand whether they make sense, is usable, can be automated, is worth the effort...

 

Maybe you can tell?

 

Dear Matt,

 

Very sorry about the frustrating situation.

 

Have you raised a wish list for this in the Revit Idea Station?

 

You might get a lot of votes for that one.

 

Now to go on with the topic at hand.

 

It has been discussed here in the past:

 

http://forums.autodesk.com/t5/revit-api/text-alignments/m-p/6272246

 

Apparently, as far as the development team is concerned, the vertical alignment possibility should never have been implemented.

 

Arnošt Löbel explained that in detail in a discussion thread on creating a text note with the 2016 API changes:

 

http://forums.autodesk.com/t5/revit-api/creating-a-textnote-with-the-2016-api-changes/m-p/5629284

 

Please also refer to the comments by David Rushforth on What's New in the Revit 2016 API:

 

http://thebuildingcoder.typepad.com/blog/2015/04/whats-new-in-the-revit-2016-api.html

 

Can you check these out and see whether they help?

 

I do hope we can resolve this somehow, because this request has cropped up a few times now.

 

Please do let us know how you end up dealing with it.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 8
mobj
in reply to: jeremytammik

Hi Matt

 

 

For now, I'll prefer usin simple text notes, as these texts are only used for sheet views.

 

Also, some users might need to delete or move  a text element, to give way for more important geometry.

 

Thanks for the idéa about getting values from the text bounding box. That's probably the best way of calculating the offset distance.

 


@Anonymous wrote:

Dear Morten,

 

Thank you for your query.

 

Is it possible to achieve what you show in your second figure using a custom line type?

 

Here are two solutions that come up immediately in an Internet search:

 

Creating linetype with text to represent utility and fence lines -- https://knowledge.autodesk.com/support/revit-products/troubleshooting/caas/sfdcarticles/sfdcarticles/Creating-linetype-with-text-to-represent-utility-and-fence-lines.html

 

https://www.youtube.com/watch?v=swR-zJkc1fQ

 

The YouTube video is in Russian, by jivkomitev2 🙂

 

Both approaches above seem rather complicated to set up.

 

I have no idea off-hand whether they make sense, is usable, can be automated, is worth the effort...

 

Maybe you can tell?

 



I'm not using detail lines. The lines shown are actually Pipe system, shown with single line representation, sorry I wasn't clear on that.

 

And a line based family is too constricted for our needs.

 

Morten Bastue Jacobsen
Rambøll Danmark A/S
www.ramboll.dk
Message 5 of 8

Hi @mobj,

Glad you got it sorted.

 

Hi Jeremy,

Thanks for the info.

It doesn't help me understand why vertical alignment isn't included in either the UI or the API.

If Revit could do everything as a user would want it, text wouldn't exist. It would all be internal/external databases, tags, references etc. That is not the case.

So, a user (or programmer) must be able to add text that can be positioned in a manner that editing the text element's content doesn't make it wrap in an undesirable way.

 

There are 21 ideas in the Idea Station using the search 'text alignment'.

While the 'no vertical alignment' stance may make sense from an Autodesk point of view, it makes zero sense from a user viewpoint. Any user would have told the development team that. The 21 ideas voice this also.

 

I've been using the Revit API since Revit 2011.

Originally, I was like, I'll use TextNoteCreationData to batch create text, because that'll be faster than creating them individually (after some testing).

That got deprecated in Revit 2013 and obsoleted in Revit 2014.

In Revit 2013, the NewTextNote creation method was heralded as being as efficient as the batch method.

Then that was deprecated in Revit 2016, and obsoleted in Revit 2017.

In Revit 2016, enter the 'new' static Create method. A devolved version, in preparation for the Revit 2017 text element overhaul. Adjustment required after initial creation transaction.

 

The roadmap isn't clear.

 

It's not annoying, really, just disappointing, time sapping, and ambiguous. The 2017 'improvements' weren't enough!

Sorry, this message is longer than I wanted! And sorry it's another rant...

Cheers,

 

-Matt

 

 [Edit] Oh, and I deal with the text placement in the two ways I suggested to @mobj. [/Edit]


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 6 of 8
weidej
in reply to: mobj

Note that this is not supported functionality...

 

But it so happens that you can still set the vertical alignment through the 'TEXT_ALIGN_VERT' BuiltInParameter.  

 

Which needs to be set to'TextAlignFlags.TEF_ALIGN_TOP ', 'TextAlignFlags.TEF_ALIGN_MIDDLE' or 'TextAlignFlags.TEF_ALIGN_BOTTOM'.

 

Like this C# snippet:

 

            using (Autodesk.Revit.DB.Transaction t = new Autodesk.Revit.DB.Transaction(Document, "AlignTextNote") )
            {
                t.Start();
                textNote.get_Parameter(BuiltInParameter.TEXT_ALIGN_VERT).Set((Int32) TextAlignFlags.TEF_ALIGN_MIDDLE);
                t.Commit();
            }

 

Hope that helps.

 

Meanwhile we will have a look to see what is involved to get this formally exposed.

 

 

Message 7 of 8
mobj
in reply to: weidej


@weidej wrote:

Note that this is not supported functionality...

 

But it so happens that you can still set the vertical alignment through the 'TEXT_ALIGN_VERT' BuiltInParameter.  

 

Which needs to be set to'TextAlignFlags.TEF_ALIGN_TOP ', 'TextAlignFlags.TEF_ALIGN_MIDDLE' or 'TextAlignFlags.TEF_ALIGN_BOTTOM'.

 

Like this C# snippet:

 

            using (Autodesk.Revit.DB.Transaction t = new Autodesk.Revit.DB.Transaction(Document, "AlignTextNote") )
            {
                t.Start();
                textNote.get_Parameter(BuiltInParameter.TEXT_ALIGN_VERT).Set((Int32) TextAlignFlags.TEF_ALIGN_MIDDLE);
                t.Commit();
            }

 

Hope that helps.

 

Meanwhile we will have a look to see what is involved to get this formally exposed.

 

 


Perfect!! Just what I needed.

 

Thanks a lot

Morten Bastue Jacobsen
Rambøll Danmark A/S
www.ramboll.dk
Message 8 of 8
jeremytammik
in reply to: mobj

Many thanks to Weidej for the solution!

 

Published here:

 

http://thebuildingcoder.typepad.com/blog/2017/01/dynamic-scripts-model-elements-and-vertical-alignme...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community