Skip to content

Commit

Permalink
implemented HideLightingFixtureHosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Tammik committed Mar 3, 2015
1 parent 483e840 commit 9261835
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions BcSamples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1020,3 +1020,4 @@ C:\a\lib\revit\2015\bc\BuildingCoder\BuildingCoder\bin\Debug\BuildingCoder.dll
BuildingCoder.CmdPostRequestInstancePlacement # version 2015.0.119.0



47 changes: 38 additions & 9 deletions BuildingCoder/BuildingCoder/CmdCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,35 @@ namespace BuildingCoder
[Transaction( TransactionMode.ReadOnly )]
class CmdCategories : IExternalCommand
{
void f( Document doc )
#region HideLightingFixtureHosts
/// <summary>
/// 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
/// </summary>
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;

Expand All @@ -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
Expand Down Expand Up @@ -67,6 +95,7 @@ InstanceBinding binding
doc.ParameterBindings.Insert( def, binding,
BuiltInParameterGroup.PG_CONSTRUCTION );
}
#endregion // ProblemAddingParameterBindingForCategory

public Result Execute(
ExternalCommandData commandData,
Expand All @@ -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 )
Expand All @@ -91,7 +120,7 @@ public Result Execute(

Debug.Print( " {0} ({1}), parent {2}",
c.Name, c.Id.IntegerValue,
(null == p ? "<none>" : p.Name) );
( null == p ? "<none>" : p.Name ) );
}

Array bics = Enum.GetValues(
Expand Down Expand Up @@ -134,14 +163,14 @@ List<BuiltInCategory> 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
Expand All @@ -168,7 +197,7 @@ IEnumerable<Category> 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" );
Expand Down
5 changes: 3 additions & 2 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" )]

0 comments on commit 9261835

Please sign in to comment.