Over the weekend, I was invited to Bergen County NJ, Where the VR Mini Hackathon took place at the Bergen Makerspace. This Mini Hackathon provided an exploratory environment where disruption, innovation, and creative ideas were brought to life. This time young hackers from grades 5-8 had the access to the latest immersive technologies, such as Oculus Rift, Leap Motion sensors, 3D printers, Google Cardboards, were some of the tools they got to hack. I got to spend my Saturday with this younger minds very hungry for knowledge and VR and two participants that impress me the most, ended up using TinkerCAD for designing their 3D model ( Link from Zelda and an custom-made Iphone 5C case with Stitch as an invisible background) and A360 to share it with their friends, and they even got featured on the A360 Twitter account, Trust me they had a blast.
This week I’m sharing with all of you a great use of four new Create methods added to the Revit 2016 API for Text notes, a great solution in response to a forum question by one of our Revit Engineers, Arnošt Löbel.
Question:Hi, I am a newbie with the Revit API and I want to create a textnote on a sheet. I have seen sample codes using the old methods but. TextNote.Create() has just been introduced and seeing a sample code using this method will help me understand it and allow me implement my version. Thanks, Jack
Answer:Hello Jack, there are four new Create methods added in the R2016 API for Text notes. I believe all of them are rather simple and straightforward to use. I'll show two code snippets here, but I am positive you will have no problems to adjust it to your concrete needs:
This one snippet creates a text note which has an adjustable width (width that grows with the text contained within). Typically, this creation method is used for creating one-line annotations. In this particular snippet I use the currently default TextNoteType, but you can use any other available text-note-type if you wish so.
using (Transaction tran = new Transaction
(RevitDoc, "Creating a Text note"))
{
XYZ origin = new XYZ(10, 10, 0);
ElementId defaultTypeId = RevitDoc.
GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);
tran.Start();
TextNote note = TextNote.Create(RevitDoc,
someView.Id, origin, "Text Note", defaultTypeId);
tran.Commit();
}
The next snippet shows creating a text box - that is a text note with a fixed width, as is normally created vi the UI when the end-user specifies the box of the new text note. Text content then wraps inside the box and extends the box' height if needed. The box' size can be controlled via the UI later after creation using the control points of the box. Also, in this example I show how to use the options to change some of the default properties of the new text object - the alignment in this particular case.
using (Transaction tran = new Transaction
(RevitDoc, "Creating a Text note"))
{
XYZ origin = new XYZ(10, 10, 0);
double width = 3.0 / 12.0; // feet on paper
TextNoteOptions options = new TextNoteOptions();
options.HorizontalAlignment = HorizontalTextAlignment.Center;
options.TypeId = RevitDoc.GetDefaultElementTypeId
(ElementTypeGroup.TextNoteType);
tran.Start();
TextNote note = TextNote.Create(RevitDoc,
someView.Id, origin, width, "Text Box Content", options);
tran.Commit();
}
I hope this helps and you and others find it useful.
Response: Thank you so much, only been at this two weeks and I'm trying to learn as much as I can. This is a great help.
Thank you once again Arnošt Löbel for sharing these four new TextNote methods that are part of the new Revit 2016 API. Check out what else is new with the API here.