In the era of 2D CAD, many firms invested in custom tools and development staff to write and maintain them. A firm’s overall experience varied in terms of the success of this investment and just about everyone has a story to tell about being “burned” from spending money developing custom tools. However a number of market forces are coming into play that continue to drive the need to customize the Autodesk® Revit® software platform, and the question is, “Do you rely entirely on third-party software or go back down the road of customization?” This class explores the benefits of investing in the development of custom tools for your firm, and shows how Revit is really “different this time” for those who have a horror story to tell. This class looks at the tools Stantec has developed in the last year and the return on investment we have already seen. We also examine our overall strategy and approach to development.
Are rooms making it too slow to modify walls in your Revit model? An advanced Revit user recently contacted me to ask what could be done about it taking 10 seconds to move a wall because of Revit’s room calculations.
This demonstration shows how data about all rooms in the model can saved to file and the rooms deleted so that you can work without the room-associated performance penalty. Then when you want the rooms back, run the Import command to re-create the rooms based on the data that was saved to file.
The Revit API has two similar seeming versions of GetElement
Document.GetElement Method (String)
Document.GetElement Method (ElementId)
To use the string version, you must have a Element.UniqueId. This is not the same as the ElementID. The UniqueID is a hexadecimal GUID such as 4f2cb6f4-bd46-4877-8bd9-3dae7acfdfae-0002d7f3. Its usefulness is that it is stable across upgrades and workset operations such as Save To Central, while the ElementId property may change.
But what if you have an element ID stored as a string? Perhaps you read the ID as a string from a text file or the user entered the ID value in a text box of your user interface. As a human you would look at the number and see an integer. But if it is stored as a string in your code, then the computer will see a string and if you try to use it with GetElement then it will expect it to be a UniqueID GUID. You can’t use an element ID value as a string in Document.GetElement Method (String).
In this case, you will need to convert the id value from a string to an integer, use ElementId Constructor (Int32), and then use this element ID with GetElement. Here’s a bit of code showing how to do this conversion.
// Find the first wall in the project for testing
Element e = new FilteredElementCollector(doc).OfClass(typeof(Wall)).First();
string uniqueIDstring = e.UniqueId;
// a GUID such as 4f2cb6f4-bd46-4877-8bd9-3dae7acfdfae-0002d7f3
Element eFromString = doc.GetElement(uniqueIDstring);
string idFromString = e.Id.ToString();
// a string storing a value such as 186354int idInt = Convert.ToInt32(idFromString);
ElementId id = new ElementId(idInt);
Element eFromId = doc.GetElement(id);
TaskDialog.Show("Elements", eFromString.Id + "\n" + eFromId.Id);
Steve recently noted that “waiting for a Revit project to upgrade unnecessarily because I don’t know what version it was created in is a drag”. He mentioned two wishes:
“I’ve got a couple wishes. First I’d love it if Revit would store a value in the file properties that indicates Revit version. Second I’d love for Revit to ask first, “Do You WANT to UPGRADE? and a “NO, NOOOO, please on all things holy NOOOO” button.”
I’ve had a great time speaking at two Revit Technology Conferences in 2013 and look forward to doing so again next year. The application deadline is December 16, and I’d love to know what format and content would interest you? A hands-on lab? A lecture? More technical or less technical?