/// <summary> /// Assing number to element /// </summary> /// <param name="element"></param> /// <param name="partNumber"></param> public static void AssingPartNumber(Element element, string partNumber) { Category category = element.Category; BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue; List <BuiltInCategory> allBuiltinCategories = FabCategories.listCat(); if (allBuiltinCategories.Contains(enumCategory)) { try { element.get_Parameter(BuiltInParameter.FABRICATION_PART_ITEM_NUMBER).Set(partNumber); ListOfElements.Add(element); ActualCounter = partNumber; uidoc.RefreshActiveView(); uidoc.Selection.SetElementIds(new List <ElementId>() { element.Id }); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { Guid guid = new Guid("460e0a79-a970-4b03-95f1-ac395c070beb"); element.get_Parameter(guid).Set(partNumber); ListOfElements.Add(element); uidoc.Selection.SetElementIds(new List <ElementId>() { element.Id }); } }
/// <summary> /// Get number from element as string /// </summary> /// <param name="element"></param> /// <returns></returns> public static string getNumber(Element element) { currentNumber = ""; Category category = element.Category; BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue; List <BuiltInCategory> allBuiltinCategories = FabCategories.listCat(); if (allBuiltinCategories.Contains(enumCategory)) { try { var value = element.get_Parameter(BuiltInParameter.FABRICATION_PART_ITEM_NUMBER).AsString(); currentNumber = value; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { Guid guid = new Guid("460e0a79-a970-4b03-95f1-ac395c070beb"); var value = element.get_Parameter(guid).AsString(); currentNumber = value; } return(currentNumber); }