By Joe Ye
For wall, floor, and roof, they have a dedicated property to change their type.
i.e. with walls:
Dim newwalltype As WallType
newwalltype = existingwall.RoofType.Duplicate(newname)
newwalltype.SetCompoundStructure(newstructure)
existingwall. WallType = newwalltype
but with ceilings:
Dim newCeilingType As CeilingType
newCeilingType = existingceiling.Duplicate(newname)
newCeilingType.SetCompoundStructure(newstructure)
this works but now how can we set the CeilingType of the existing ceiling object in the new one (newCeilingType)?
For some elements, they don’t have dedicated shortcut property to change their type, as here mentioned Ceiling. Revit provide a more generic method, ChangeTypeId() within Element class, developers can use this method to change any element’s type, including Ceiling. Of cause, ChangeTypeId() method can also be used to change wall, floor, and roof type too. Pass in the target type’s Id, and that’s solution.
Here is the code snippet for changing the ceiling type.
Dim newCeilingType As CeilingType
newCeilingType = existingceiling.Duplicate(newname)
newCeilingType.SetCompoundStructure(newstructure)
existingCeiling.ChangeTypeId(newCeilingType.Id)