private void StreamEntityFieldValue(Field field) { try { var getEntityValueMethod = GetEntityFieldValueMethod(field); var valueType = GetFieldValueType(field); var genericGet = getEntityValueMethod.MakeGenericMethod(valueType); var fieldSpecType = field.GetSpecTypeId(); var unit = UnitUtils.IsMeasurableSpec(fieldSpecType) ? UnitUtils.GetValidUnits(field.GetSpecTypeId()).First() : UnitTypeId.Custom; var parameters = getEntityValueMethod.GetParameters().Length == 1 ? new object[] { field } : new object[] { field, unit }; var value = genericGet.Invoke(_entity, parameters); AddFieldValue(field, value); } catch (Exception ex) { _data.Add(new Data.Exception(field.FieldName, ex)); } }
private void StreamEntityFieldValue(Field field) { try { var getEntityValueMethod = GetEntityFieldValueMethod(field); var valueType = GetFieldValueType(field); var genericGet = getEntityValueMethod.MakeGenericMethod(valueType); //var unit = UnitUtils.GetValidDisplayUnits( field.UnitType ).First(); // 2020 var unit = UnitUtils.GetValidUnits(field.GetSpecTypeId()).First(); // 2021 var parameters = getEntityValueMethod.GetParameters().Length == 1 ? new object[] { field } : new object[] { field, unit }; var value = genericGet.Invoke(entity, parameters); AddFieldValue(field, value); } catch (Exception ex) { data.Add(new Snoop.Data.Exception(field.FieldName, ex)); } }
public static ForgeTypeId UnitTypeId(this ForgeTypeId specTypeId) { if (specTypeId == SpecTypeId.Number) { return(null); } IEnumerable <ForgeTypeId> unitTypeIds = UnitUtils.GetValidUnits(specTypeId); if (unitTypeIds == null || unitTypeIds.Count() == 0) { return(null); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Meters)) { return(Autodesk.Revit.DB.UnitTypeId.Meters); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Kilograms)) { return(Autodesk.Revit.DB.UnitTypeId.Kilograms); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Celsius)) { return(Autodesk.Revit.DB.UnitTypeId.Celsius); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Amperes)) { return(Autodesk.Revit.DB.UnitTypeId.Amperes); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Watts)) { return(Autodesk.Revit.DB.UnitTypeId.Watts); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.WattsPerCubicMeter)) { return(Autodesk.Revit.DB.UnitTypeId.WattsPerCubicMeter); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.WattsPerMeterKelvin)) { return(Autodesk.Revit.DB.UnitTypeId.WattsPerMeterKelvin); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.WattsPerSquareMeterKelvin)) { return(Autodesk.Revit.DB.UnitTypeId.WattsPerSquareMeterKelvin); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.CubicMeters)) { return(Autodesk.Revit.DB.UnitTypeId.CubicMeters); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.SquareMeters)) { return(Autodesk.Revit.DB.UnitTypeId.SquareMeters); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.CubicMetersPerSecond)) { return(Autodesk.Revit.DB.UnitTypeId.CubicMetersPerSecond); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.WattsPerSquareMeter)) { return(Autodesk.Revit.DB.UnitTypeId.WattsPerSquareMeter); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Volts)) { return(Autodesk.Revit.DB.UnitTypeId.Volts); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.KilogramsForce)) { return(Autodesk.Revit.DB.UnitTypeId.KilogramsForce); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Lux)) { return(Autodesk.Revit.DB.UnitTypeId.Lux); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Lumens)) { return(Autodesk.Revit.DB.UnitTypeId.Lumens); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.Pascals)) { return(Autodesk.Revit.DB.UnitTypeId.Pascals); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.PascalsPerMeter)) { return(Autodesk.Revit.DB.UnitTypeId.PascalsPerMeter); } if (unitTypeIds.Contains(Autodesk.Revit.DB.UnitTypeId.KilogramsPerCubicMeter)) { return(Autodesk.Revit.DB.UnitTypeId.KilogramsPerCubicMeter); } return(null); }
/// <summary> /// Constructor. /// </summary> /// <param name="revit">The revit application.</param> public STLExportForm(Autodesk.Revit.UI.UIApplication revit) { InitializeComponent(); m_Revit = revit; // get new data generator m_Generator = new DataGenerator(m_Revit.Application, m_Revit.ActiveUIDocument.Document, m_Revit.ActiveUIDocument.Document.ActiveView); // scan for categories to populate category list m_CategoryList = m_Generator.ScanCategories(true); foreach (Category category in m_CategoryList.Values) { TreeNode treeNode = GetChildNode(category, m_Revit.ActiveUIDocument.Document.ActiveView); if (treeNode != null) { tvCategories.Nodes.Add(treeNode); } } string unitName = "Use Internal: Feet"; m_DisplayUnits.Add(unitName, new ForgeTypeId()); int selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT.Empty()) { comboBox_DUT.SelectedIndex = selectedIndex; } Units currentUnits = m_Revit.ActiveUIDocument.Document.GetUnits(); ForgeTypeId currentDut = currentUnits.GetFormatOptions(SpecTypeId.Length).GetUnitTypeId(); unitName = "Use Current: " + LabelUtils.GetLabelForUnit(currentDut); m_DisplayUnits.Add(unitName, currentDut); selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT == currentDut) { comboBox_DUT.SelectedIndex = selectedIndex; } foreach (ForgeTypeId dut in UnitUtils.GetValidUnits(SpecTypeId.Length)) { if (currentDut == dut) { continue; } unitName = LabelUtils.GetLabelForUnit(dut); m_DisplayUnits.Add(unitName, dut); selectedIndex = comboBox_DUT.Items.Add(unitName); if (m_SelectedDUT == dut) { comboBox_DUT.SelectedIndex = selectedIndex; } } // initialize the UI differently for Families if (revit.ActiveUIDocument.Document.IsFamilyDocument) { cbIncludeLinked.Enabled = false; tvCategories.Enabled = false; btnCheckAll.Enabled = false; btnCheckNone.Enabled = false; } }