13c29412eb
* Use of obsolete members now generates warning * format --------- Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
32 lines
640 B
C#
32 lines
640 B
C#
using Autodesk.Revit.DB;
|
|
|
|
namespace Speckle.Connectors.RevitShared;
|
|
|
|
public static class ElementIdHelper
|
|
{
|
|
public static ElementId? GetElementIdFromUniqueId(Document doc, string uniqueId)
|
|
{
|
|
Element element = doc.GetElement(uniqueId);
|
|
return element?.Id;
|
|
}
|
|
|
|
public static ElementId? GetElementId(string elementId)
|
|
{
|
|
#if REVIT2024_OR_GREATER
|
|
if (long.TryParse(elementId, out long elementIdInt))
|
|
{
|
|
return new ElementId(elementIdInt);
|
|
}
|
|
#else
|
|
if (int.TryParse(elementId, out int elementIdInt))
|
|
{
|
|
return new ElementId(elementIdInt);
|
|
}
|
|
#endif
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|