Change Wall Thickness : Revit API Python Scripting

Dear all,
I have to write a python script that changes the core layer thickness of a newly created walltype by duplicating an existing walltype. I have tried so many times and failed. If someone could help me, it would be great. I have tried the solutions in related posts here, without any luck. Please check what I am doing wrong.

This is my import statements;

import Autodesk
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

Here is the portion of the code which should change the wall thickness;

t = Transaction(doc, "change_wall_thickness")
t.Start()
cs = wall_type.GetCompoundStructure()
i = cs.GetFirstCoreLayerIndex()
thickness_to_set = 0.754593
cs.SetLayerWidth(i, thickness_to_set)
t.Commit()

I tried this too;

t = Transaction(doc, "change_wall_thickness")
t.Start()
cs = wall_type.GetCompoundStructure()
layers = cs.GetLayers()
layers[0].Width = 0.754593
t.Commit()

Still no luck…
I am using Interactive Python Shell to run this, not Dynamo’s Python script node.

@harilalmn Taking reference from @Dimitar_Venkov’s code:
It seems like you are missing the last line to SetCompoundStructure

cs = wall_type.GetCompoundStructure()
i = cs.GetFirstCoreLayerIndex()
cs.SetLayerWidth(i,thickness_to_set)
wall_type.SetCompoundStructure(cs)
1 Like

Thanks a lot my friend…! That worked…!

1 Like