How can I get the Structure Wall Types of a Stacked Wall Type

How can I get the Structure Wall Types of a Stacked Wall Type

Rockit_for_Revit
Advocate Advocate
454 Views
4 Replies
Message 1 of 5

How can I get the Structure Wall Types of a Stacked Wall Type

Rockit_for_Revit
Advocate
Advocate

Hello,

How can I get the Structure Wall Types of a Stacked Wall Type? In the following code I am trying to get to the CompoundStructure however this seems to return nothing.

                    Dim compoundStructure As CompoundStructure = objStackedWallType.GetCompoundStructure
                    If compoundStructure Is Nothing Then
                        MsgBox("Nothing")
                    End If

Regards

David 

0 Likes
455 Views
4 Replies
Replies (4)
Message 2 of 5

moturi.magati.george
Autodesk
Autodesk

Hi @Rockit_for_Revitm,

 

I have simulated the same on my end and got the same results. I have asked the engineering team for more information about the same.

  Moturi George,     Developer Advocacy and Support,  ADN Open
0 Likes
Message 3 of 5

moturi.magati.george
Autodesk
Autodesk

Hi @Rockit_for_Revit,

 

The functionality you are looking for has not been exposed in the API yet because stacked walls use a custom compound structure class.

 

You can request this functionality at the Revit Idea Station.

Please search there for a corresponding wish list entry for the suggested functionality and add your comments to it, or create a new one, if none already exists:

 

https://forums.autodesk.com/t5/revit-ideas/idb-p/302

 

Tag it as an API wish:

https://forums.autodesk.com/t5/revit-ideas/idb-p/302/tab/most-recent/label-name/api

Ensure it gets as many votes as possible to underline its importance to you and the rest of the developer community.

The Revit Idea Station is currently one of the main driving input forces for Revit API enhancements.

The Revit development team look there. Your comment here in the discussion forum might be overlooked.

  Moturi George,     Developer Advocacy and Support,  ADN Open
Message 4 of 5

Rockit_for_Revit
Advocate
Advocate

Hi,
Thank you for the info, so you don't think I can even get the wall type names?
The reason is that I'm writing a command to purge unused wall types. However I can't purge the basic wall types that are either used, or if they are referred to in a Staked Wall Type.

Kind Regards
David

Message 5 of 5

harilalmn
Advocate
Advocate

Stackwd walls are walls made up of multiple wall types at different height. So, getting the compound structure of a stacked wallwill raise the question, "at what height". Assuming that you query a stacked wall by providing a height as a parameter, you can do this;

public void ExtractStackedWallStructure()
		{
			Wall wall = (Wall) doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, new WallSelectionFilter(), "Pick a stacked wall"));
			double height = 6.5; // In feet
			
			CompoundStructure compoundStructure = GetStackedWallCompoundStructure(wall, height);
			IList<CompoundStructureLayer> layers = compoundStructure.GetLayers();
			List<string> materialNames = new List<string>();
			try {
				foreach (CompoundStructureLayer layer in layers)
				{
					Material material = doc.GetElement(layer.MaterialId) as Material;
					if (material != null)
					{
						materialNames.Add(material.Name);
					}
				}
				
				TaskDialog.Show("Compound structure layers", materialNames[0]);
			} catch (Exception e) {
				
				throw e;
			}
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <param name="stackedWall"></param>
		/// <param name="height"> This variable is to get the wall at the height provided</param>
		/// <returns></returns>
		private CompoundStructure GetStackedWallCompoundStructure(Wall stackedWall, double height = 0.0)
		{

			// The GetStackedWallMemberIds() method returns the element ids of the member walls of a stacked wall
			if (stackedWall.IsStackedWall == false) return null;
			List<Wall> walls = stackedWall.GetStackedWallMemberIds()
				.Select(w => (Wall) doc
				        .GetElement(w))
				.ToList();
			
			// If height is zero, the first member wall's compound structure is returned
			if (height - 0.0 < 0.00001)
			{
				WallType wallType = walls[0].WallType;
				CompoundStructure co = wallType.GetCompoundStructure();
				return co;
			}

			// return the wall type of the wall at the given height
			foreach (Wall wall in walls)
			{
				double baseHeight = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble();
				double topHeight = baseHeight + wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble();

				if (height >= baseHeight && height <= topHeight)
				{
					WallType wallType = wall.WallType;
					return wallType.GetCompoundStructure();
				}
			}
			return null;
		}
		
	}
	
	class WallSelectionFilter : ISelectionFilter
	{
		
		
		public bool AllowElement(Element elem)
		{
			Wall wall = elem as Wall;
			if (wall == null){
				return false;
			}
			
			return wall.IsStackedWall;
		}
		
		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}
	}

 

Here, the private method takes a height parameter, which in case not provided, will return the compound structure of the bottom most wall type.

Hope this helps.