From 926183596067e8b8bbccc666c0fc571d9e511814 Mon Sep 17 00:00:00 2001 From: Jeremy Tammik Date: Tue, 3 Mar 2015 20:46:16 +0100 Subject: [PATCH] implemented HideLightingFixtureHosts --- BcSamples.txt | 1 + BuildingCoder/BuildingCoder/CmdCategories.cs | 47 +++++++++++++++---- .../BuildingCoder/Properties/AssemblyInfo.cs | 5 +- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/BcSamples.txt b/BcSamples.txt index e2652014..be653fd4 100644 --- a/BcSamples.txt +++ b/BcSamples.txt @@ -1020,3 +1020,4 @@ C:\a\lib\revit\2015\bc\BuildingCoder\BuildingCoder\bin\Debug\BuildingCoder.dll BuildingCoder.CmdPostRequestInstancePlacement # version 2015.0.119.0 + diff --git a/BuildingCoder/BuildingCoder/CmdCategories.cs b/BuildingCoder/BuildingCoder/CmdCategories.cs index 7b758b29..32ed35b1 100644 --- a/BuildingCoder/BuildingCoder/CmdCategories.cs +++ b/BuildingCoder/BuildingCoder/CmdCategories.cs @@ -22,7 +22,35 @@ namespace BuildingCoder [Transaction( TransactionMode.ReadOnly )] class CmdCategories : IExternalCommand { - void f( Document doc ) + #region HideLightingFixtureHosts + /// + /// Hide the LightingFixtures category + /// Hosts subcategory in the given view, cf. + /// http://forums.autodesk.com/t5/revit-api/how-to-get-image-of-a-family-model-without-showing-host-element/td-p/5526085 + /// http://forums.autodesk.com/t5/revit-api/how-to-change-visibility-setting/td-p/5526076 + /// + void HideLightingFixtureHosts( View view ) + { + Document doc = view.Document; + + Categories categories = doc.Settings.Categories; + + Category catLightingFixtures + = categories.get_Item( + BuiltInCategory.OST_LightingFixtures ); + + CategoryNameMap subcats + = catLightingFixtures.SubCategories; + + Category catHosts = subcats.get_Item( "Hosts" ); + + view.SetVisibility( catHosts, false ); + } + #endregion // HideLightingFixtureHosts + + #region ProblemAddingParameterBindingForCategory + void ProblemAddingParameterBindingForCategory( + Document doc ) { Application app = doc.Application; @@ -35,8 +63,8 @@ DefinitionFile sharedParametersFile //Definition def = group.Definitions.Create( // 2014 // "ReinforcementParameter", ParameterType.Text ); - ExternalDefinitonCreationOptions opt - = new ExternalDefinitonCreationOptions( + ExternalDefinitonCreationOptions opt + = new ExternalDefinitonCreationOptions( "ReinforcementParameter", ParameterType.Text ); Definition def = group.Definitions.Create( opt ); // 2015 @@ -67,6 +95,7 @@ InstanceBinding binding doc.ParameterBindings.Insert( def, binding, BuiltInParameterGroup.PG_CONSTRUCTION ); } + #endregion // ProblemAddingParameterBindingForCategory public Result Execute( ExternalCommandData commandData, @@ -80,9 +109,9 @@ public Result Execute( int nCategories = categories.Size; - Debug.Print( + Debug.Print( "{0} categories and their parents obtained " - + "from the Categories collection:", + + "from the Categories collection:", nCategories ); foreach( Category c in categories ) @@ -91,7 +120,7 @@ public Result Execute( Debug.Print( " {0} ({1}), parent {2}", c.Name, c.Id.IntegerValue, - (null == p ? "" : p.Name) ); + ( null == p ? "" : p.Name ) ); } Array bics = Enum.GetValues( @@ -134,14 +163,14 @@ List bics_exception s = ex.GetType().Name + " " + ex.Message; } - Debug.Print( " {0} --> {1}", + Debug.Print( " {0} --> {1}", bic.ToString(), s ); } int nBicsNull = bics_null.Count; int nBicsException = bics_exception.Count; - #if ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR +#if ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR // Trying to use OfClass( typeof( Category ) ) // throws an ArgumentException exception saying // "Input type Category is not a recognized @@ -168,7 +197,7 @@ IEnumerable cats { Debug.Print( " {0}", c.Name ); } - #endif // ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR +#endif // ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR TaskDialog dlg = new TaskDialog( "Hidden Built-in Categories" ); diff --git a/BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs b/BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs index e47d7d39..186e0e4e 100644 --- a/BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs +++ b/BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs @@ -75,6 +75,7 @@ // 2015-02-20 2015.0.117.5 updated CmdListMarks to use TransactionMode.Manual instead of Automatic // 2015-02-20 2015.0.118.0 implemented CmdItemExecuted and added reference to PresentationFramework assembly // 2015-03-02 2015.0.119.0 implemented CmdPostRequestInstancePlacement +// 2015-03-03 2015.0.119.1 implemented HideLightingFixtureHosts // -[assembly: AssemblyVersion( "2015.0.119.0" )] -[assembly: AssemblyFileVersion( "2015.0.119.0" )] +[assembly: AssemblyVersion( "2015.0.119.1" )] +[assembly: AssemblyFileVersion( "2015.0.119.1" )]