diff --git a/BuildingCoder/BuildingCoder/CmdCategories.cs b/BuildingCoder/BuildingCoder/CmdCategories.cs index 5347979..02d9484 100644 --- a/BuildingCoder/BuildingCoder/CmdCategories.cs +++ b/BuildingCoder/BuildingCoder/CmdCategories.cs @@ -53,19 +53,19 @@ CategoryNameMap subcats #endregion // HideLightingFixtureHosts #region ProblemAddingParameterBindingForCategory - static Util.SpellingErrorCorrector - _spellingErrorCorrector = null; + //static Util.SpellingErrorCorrector + // _spellingErrorCorrector = null; void ProblemAddingParameterBindingForCategory( Document doc ) { Application app = doc.Application; - if( null == _spellingErrorCorrector ) - { - _spellingErrorCorrector - = new Util.SpellingErrorCorrector( app ); - } + //if( null == _spellingErrorCorrector ) + //{ + // _spellingErrorCorrector + // = new Util.SpellingErrorCorrector( app ); + //} DefinitionFile sharedParametersFile = app.OpenSharedParameterFile(); @@ -89,11 +89,12 @@ ExternalDefinitionCreationOptions opt // 2022 // To handle both ExternalDefinitonCreationOptions // and ExternalDefinitionCreationOptions: - def = _spellingErrorCorrector.NewDefinition( - group.Definitions, "ReinforcementParameter", - ParameterType.Text ); + //def = _spellingErrorCorrector.NewDefinition( + // group.Definitions, "ReinforcementParameter", + // //ParameterType.Text // 2021 + // SpecTypeId.String.Text ); // 2022 - List bics + List bics = new List(); //bics.Add(BuiltInCategory.OST_AreaRein); diff --git a/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs b/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs index bc24f50..c071c9a 100644 --- a/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs +++ b/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs @@ -909,7 +909,7 @@ Element projInfoElem ParameterValueProvider provider = new ParameterValueProvider( paraId ); - FilterRule rule = new FilterStringRule( + FilterRule rule = new FilterStringRule( // 2021 provider, new FilterStringEquals(), paramValue, true ); diff --git a/BuildingCoder/BuildingCoder/CmdCreateSharedParams.cs b/BuildingCoder/BuildingCoder/CmdCreateSharedParams.cs index c7a824f..e1f0e84 100644 --- a/BuildingCoder/BuildingCoder/CmdCreateSharedParams.cs +++ b/BuildingCoder/BuildingCoder/CmdCreateSharedParams.cs @@ -30,7 +30,8 @@ class CmdCreateSharedParams : IExternalCommand const string _filename = "C:/tmp/SharedParams.txt"; const string _groupname = "The Building Coder Parameters"; const string _defname = "SP"; - ParameterType _deftype = ParameterType.Number; + //ParameterType _deftype = ParameterType.Number; // 2021 + ForgeTypeId _deftype = SpecTypeId.Number; // 2022 // What element types are we interested in? The standard // SDK FireRating sample uses BuiltInCategory.OST_Doors. diff --git a/BuildingCoder/BuildingCoder/CmdGetMaterials.cs b/BuildingCoder/BuildingCoder/CmdGetMaterials.cs index a6428a7..640f0da 100644 --- a/BuildingCoder/BuildingCoder/CmdGetMaterials.cs +++ b/BuildingCoder/BuildingCoder/CmdGetMaterials.cs @@ -873,7 +873,8 @@ public Material GetMaterial( if( p.StorageType == StorageType.ElementId && def.ParameterGroup == BuiltInParameterGroup.PG_MATERIALS - && def.ParameterType == ParameterType.Material ) + //&& def.ParameterType == ParameterType.Material // 2021) + && def.GetDataType() == SpecTypeId.Reference.Material ) // 2022 { ElementId materialId = p.AsElementId(); diff --git a/BuildingCoder/BuildingCoder/CmdNewDimensionLabel.cs b/BuildingCoder/BuildingCoder/CmdNewDimensionLabel.cs index 0e4501c..3a74c1f 100644 --- a/BuildingCoder/BuildingCoder/CmdNewDimensionLabel.cs +++ b/BuildingCoder/BuildingCoder/CmdNewDimensionLabel.cs @@ -134,7 +134,9 @@ FamilyParameter familyParam = doc.FamilyManager.AddParameter( "length", BuiltInParameterGroup.PG_IDENTITY_DATA, - ParameterType.Length, false ); + ParameterType.Length, // 2021 + //SpecTypeId.Length, // 2022 + false ); //dim.Label = familyParam; // 2013 dim.FamilyLabel = familyParam; // 2014 diff --git a/BuildingCoder/BuildingCoder/CmdSetTagType.cs b/BuildingCoder/BuildingCoder/CmdSetTagType.cs index dc58e69..08ed9f9 100644 --- a/BuildingCoder/BuildingCoder/CmdSetTagType.cs +++ b/BuildingCoder/BuildingCoder/CmdSetTagType.cs @@ -327,8 +327,10 @@ public void SetTagColorToElementColor( UIDocument uiDoc ) foreach( var e in tags ) { IndependentTag tag = doc.GetElement( e.Id ) as IndependentTag; - Element taggedElem = tag.GetTaggedLocalElement(); - taggedElements.Add( taggedElem ); + //Element taggedElem = tag.GetTaggedLocalElement(); // 2021 + //taggedElements.Add( taggedElem ); + ICollection taggedElems = tag.GetTaggedLocalElements(); // 2022 + taggedElements.AddRange( taggedElems ); } //get the color of the ductsystem diff --git a/BuildingCoder/BuildingCoder/Util.cs b/BuildingCoder/BuildingCoder/Util.cs index adf3dd3..eb07e65 100644 --- a/BuildingCoder/BuildingCoder/Util.cs +++ b/BuildingCoder/BuildingCoder/Util.cs @@ -1294,7 +1294,8 @@ public static void ListForgeTypeIds() } } - IList specs = UnitUtils.GetAllSpecs(); + //IList specs = UnitUtils.GetAllSpecs(); // 2021 + IList specs = UnitUtils.GetAllMeasurableSpecs(); // 2022 Debug.Print( "{0} specs:", specs.Count ); @@ -2288,63 +2289,63 @@ void GenerateAddInManifest( } #endregion // Generate add-in manifest on the fly - #region Compatibility fix for spelling error change - /// - /// Wrapper to fix a spelling error prior to Revit 2016. - /// - public class SpellingErrorCorrector - { - static bool _in_revit_2015_or_earlier; - static Type _external_definition_creation_options_type; - - public SpellingErrorCorrector( Application app ) - { - _in_revit_2015_or_earlier = 0 - <= app.VersionNumber.CompareTo( "2015" ); - - string s - = _in_revit_2015_or_earlier - ? "ExternalDefinitonCreationOptions" - : "ExternalDefinitionCreationOptions"; - - _external_definition_creation_options_type - = System.Reflection.Assembly - .GetExecutingAssembly().GetType( s ); - } - - object NewExternalDefinitionCreationOptions( - string name, - ParameterType parameterType ) - { - object[] args = new object[] { - name, parameterType }; - - return _external_definition_creation_options_type - .GetConstructor( new Type[] { - _external_definition_creation_options_type } ) - .Invoke( args ); - } - - public Definition NewDefinition( - Definitions definitions, - string name, - ParameterType parameterType ) - { - //return definitions.Create( - // NewExternalDefinitionCreationOptions() ); - - object opt - = NewExternalDefinitionCreationOptions( - name, - parameterType ); - - return typeof( Definitions ).InvokeMember( - "Create", BindingFlags.InvokeMethod, null, - definitions, new object[] { opt } ) - as Definition; - } - } - #endregion // Compatibility fix for spelling error change + //#region Compatibility fix for spelling error change + ///// + ///// Wrapper to fix a spelling error prior to Revit 2016. + ///// + //public class SpellingErrorCorrector + //{ + // static bool _in_revit_2015_or_earlier; + // static Type _external_definition_creation_options_type; + + // public SpellingErrorCorrector( Application app ) + // { + // _in_revit_2015_or_earlier = 0 + // <= app.VersionNumber.CompareTo( "2015" ); + + // string s + // = _in_revit_2015_or_earlier + // ? "ExternalDefinitonCreationOptions" + // : "ExternalDefinitionCreationOptions"; + + // _external_definition_creation_options_type + // = System.Reflection.Assembly + // .GetExecutingAssembly().GetType( s ); + // } + + // object NewExternalDefinitionCreationOptions( + // string name, + // ParameterType parameterType ) + // { + // object[] args = new object[] { + // name, parameterType }; + + // return _external_definition_creation_options_type + // .GetConstructor( new Type[] { + // _external_definition_creation_options_type } ) + // .Invoke( args ); + // } + + // public Definition NewDefinition( + // Definitions definitions, + // string name, + // ParameterType parameterType ) + // { + // //return definitions.Create( + // // NewExternalDefinitionCreationOptions() ); + + // object opt + // = NewExternalDefinitionCreationOptions( + // name, + // parameterType ); + + // return typeof( Definitions ).InvokeMember( + // "Create", BindingFlags.InvokeMethod, null, + // definitions, new object[] { opt } ) + // as Definition; + // } + //} + //#endregion // Compatibility fix for spelling error change } #region Extension Method Classes @@ -2813,47 +2814,47 @@ public static XYZ GetPoint2( } #endregion // Autodesk.Revit.DB.Curve - #region Autodesk.Revit.DB.Definitions - public static Definition Create2( - this Definitions definitions, - Document doc, - string nome, - ParameterType tipo, - bool visibilidade ) - { - // Does this need updating to check for - // ExternalDefinitionCreationOptions with - // the additional 'i' in Revit 2016? - - Definition value = null; - List ls = doc.GetType().Assembly - .GetTypes().Where( a => a.IsClass && a - .Name == "ExternalDefinitonCreationOptions" ).ToList(); - if( ls.Count > 0 ) - { - Type t = ls[ 0 ]; - ConstructorInfo c = t - .GetConstructor( new Type[] { typeof(string), - typeof(ParameterType) } ); - object ed = c - .Invoke( new object[] { nome, tipo } ); - ed.GetType().GetProperty( "Visible" ) - .SetValue( ed, visibilidade, null ); - value = definitions.GetType() - .GetMethod( "Create", new Type[] { t } ).Invoke( definitions, - new object[] { ed } ) as Definition; - } - else - { - value = definitions.GetType() - .GetMethod( "Create", new Type[] { typeof(string), - typeof(ParameterType), typeof(bool) } ).Invoke( definitions, - new object[] { nome, tipo, - visibilidade } ) as Definition; - } - return value; - } - #endregion // Autodesk.Revit.DB.Definitions + //#region Autodesk.Revit.DB.Definitions + //public static Definition Create2( + // this Definitions definitions, + // Document doc, + // string nome, + // ParameterType tipo, + // bool visibilidade ) + //{ + // // Does this need updating to check for + // // ExternalDefinitionCreationOptions with + // // the additional 'i' in Revit 2016? + + // Definition value = null; + // List ls = doc.GetType().Assembly + // .GetTypes().Where( a => a.IsClass && a + // .Name == "ExternalDefinitonCreationOptions" ).ToList(); + // if( ls.Count > 0 ) + // { + // Type t = ls[ 0 ]; + // ConstructorInfo c = t + // .GetConstructor( new Type[] { typeof(string), + // typeof(ParameterType) } ); + // object ed = c + // .Invoke( new object[] { nome, tipo } ); + // ed.GetType().GetProperty( "Visible" ) + // .SetValue( ed, visibilidade, null ); + // value = definitions.GetType() + // .GetMethod( "Create", new Type[] { t } ).Invoke( definitions, + // new object[] { ed } ) as Definition; + // } + // else + // { + // value = definitions.GetType() + // .GetMethod( "Create", new Type[] { typeof(string), + // typeof(ParameterType), typeof(bool) } ).Invoke( definitions, + // new object[] { nome, tipo, + // visibilidade } ) as Definition; + // } + // return value; + //} + //#endregion // Autodesk.Revit.DB.Definitions #region Autodesk.Revit.DB.Document public static Element GetElement2(