Message 1 of 5
Perhaps I'm missing something in the UI about assigning materials to categories but...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
While I was looking at some stuff concerning wall layers I ran across this code sample in the API help:
Public Sub GetWallLayerMaterial(document As Autodesk.Revit.DB.Document, wall As Wall)
' get WallType of wall
Dim aWallType As WallType = wall.WallType
' Only Basic Wall has compoundStructure
If WallKind.Basic = aWallType.Kind Then
' Get CompoundStructure
Dim comStruct As CompoundStructure = aWallType.GetCompoundStructure()
Dim allCategories As Categories = document.Settings.Categories
' Get the category OST_Walls default Material;
' use if that layer's default Material is <By Category>
Dim wallCategory As Category = allCategories.Item(BuiltInCategory.OST_Walls)
Dim wallMaterial As Autodesk.Revit.DB.Material = wallCategory.Material
For Each structLayer As CompoundStructureLayer In comStruct.GetLayers()
Dim layerMaterial As Autodesk.Revit.DB.Material = TryCast(document.GetElement(structLayer.MaterialId), Material)
' If CompoundStructureLayer's Material is specified, use default
' Material of its Category
If layerMaterial Is Nothing Then
Select Case structLayer.[Function]
Case MaterialFunctionAssignment.Finish1
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsFinish1).Material
Exit Select
Case MaterialFunctionAssignment.Finish2
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsFinish2).Material
Exit Select
Case MaterialFunctionAssignment.Membrane
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsMembrane).Material
Exit Select
Case MaterialFunctionAssignment.[Structure]
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsStructure).Material
Exit Select
Case MaterialFunctionAssignment.Substrate
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsSubstrate).Material
Exit Select
Case MaterialFunctionAssignment.Insulation
layerMaterial = allCategories.Item(BuiltInCategory.OST_WallsInsulation).Material
Exit Select
Case Else
' It is impossible to reach here
Exit Select
End Select
If layerMaterial Is Nothing Then
' CompoundStructureLayer's default Material is its SubCategory
layerMaterial = wallMaterial
End If
End If
TaskDialog.Show("Revit", "Layer Material: " & layerMaterial.ToString())
Next
End If
End Sub
According to that sample a person should be able to assign default materials to the function sub-categories of walls.
The UI has no such ability:
So the code sample always returns the material assigned to the main Walls category for each layer if the layer does not have a material assignment (it never returns any material assigned to the wall function subcategories because there isn't any way to assign a material to them).
What am I missing?
-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)