Set Ceiling width value

Set Ceiling width value

miguelBW5DE
Contributor Contributor
597 Views
3 Replies
Message 1 of 4

Set Ceiling width value

miguelBW5DE
Contributor
Contributor

Greetings from perú!

For this opportunity, I'm looking to change the ceiling thickness:

miguelBW5DE_0-1666129158104.png

so far I've managed to get the width value but I still confused about the appropriate syntax to change the width value:

 

			List<HostObjAttributes> ceilings = new FilteredElementCollector(doc).WhereElementIsElementType().OfCategory(BuiltInCategory.OST_Ceilings).Cast<HostObjAttributes>().Where(ceiling=>ceiling.GetCompoundStructure() != null).ToList();
			foreach (HostObjAttributes ceiling in ceilings) {
				//stb.AppendLine(ceiling.Name);
				if (ceiling.Name =="Soffit Only Above Cabinets - H10\"") {
					IList<CompoundStructureLayer> layers = ceiling.GetCompoundStructure().GetLayers();
					foreach (var layer in layers) {
						layer.Width = 3; 
						
						
					}
					
				}
				
				
			}

After running the script, the ceiling thickness does not change. I would appreciate some help on this one. Thanks in advance.

Best regards,

Miguel G

 

Accepted solutions (1)
598 Views
3 Replies
Replies (3)
Message 2 of 4

RPTHOMAS108
Mentor
Mentor
Accepted solution

Where there is a Get there is usually a Set.

 

The Get returns a detached copy which you need to return back with changes made, you have two 'Gets' there in the above.

 

So you have various 'Sets' also for your 3-foot-deep ceiling layer to take effect:

CompoundStructure.SetLayers
or perhaps
CompoundStructure.SetLayerWidth

then

HostObjAttributes.SetCompoundStructure

Message 3 of 4

miguelBW5DE
Contributor
Contributor

Hi Richard, nice to hear from you again. Thanks for your prompt reply. I even tried this syntax and do not work at all:

 

			List<HostObjAttributes> ceilings = new FilteredElementCollector(doc).WhereElementIsElementType().OfCategory(BuiltInCategory.OST_Ceilings).Cast<HostObjAttributes>().Where(ceiling=>ceiling.GetCompoundStructure() != null).ToList();
			foreach (HostObjAttributes ceiling in ceilings) {
				//stb.AppendLine(ceiling.Name);
				if (ceiling.Name =="Soffit Only Above Cabinets - H10\"") {
					CompoundStructure compStr = ceiling.GetCompoundStructure();
					int indexCore = compStr.GetFirstCoreLayerIndex();
					compStr.SetLayerWidth(indexCore,7);
					stb.AppendLine(indexCore.ToString());
				}
			}

 

I will check out what you have suggested right now

Message 4 of 4

miguelBW5DE
Contributor
Contributor

Thank you Richard you are the boss! what I was missing in the last portion of code was " ceiling.SetCompoundStructure(compStr);" 

All the best!

Miguel G.