Hi
I need to round the Area value to 2 digits. It always comes as 3 digits. We use m² as unit. How to do this in this code(the line in red):
best regards
I need to round the Area value to 2 digits. It always comes as 3 digits. We use m² as unit. How to do this in this code(the line in red):
Code:
namespace RoomComments { [Transaction(TransactionMode.Automatic)] class SetRoomComments : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; List<Element> rooms = new List<Element>(); List<Element> areas = new List<Element>(); FilteredElementCollector collector = new FilteredElementCollector(uidoc.Document); collector.OfCategory(BuiltInCategory.OST_Rooms); rooms.AddRange(collector); FilteredElementCollector Acollector = new FilteredElementCollector(uidoc.Document); Acollector.OfCategory(BuiltInCategory.OST_Areas); areas.AddRange(Acollector); string m_AV = null; try { foreach (Room m_room in rooms) { Parameter p = m_room.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS); string m_roomnumber = m_room.Number; foreach (Area m_area in areas) { string m_areanumber = m_area.Number; [COLOR="#B22222"]string m_areavalue = m_area.get_Parameter(BuiltInParameter.ROOM_AREA).AsValueString();[/COLOR] if (m_roomnumber == m_areanumber) { m_AV = m_areavalue.TrimEnd('m','²'); } } p.Set(m_AV); } return Result.Succeeded; } catch { return Result.Failed; } } } }
Comment