当前位置:网站首页>Revit secondary development - modify wall thickness

Revit secondary development - modify wall thickness

2022-07-07 22:22:00 Hey, hey, hey, hey, hey

The wall thickness is read-only , Can't modify , So we can only modify the layer thickness of its internal structure .

1、 Get the wall structure

2、 Get all layers , And traverse and modify the thickness

3、 The modified layer set is set to the structure , And set the structure to the wall type

The approximate code is as follows :

 

Wall wall;
double dThickness = 500 / 304.8;
double dHeight = wall.get_Prarmeter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble();
double dOffset = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble();
LocationCurve lc = wall.Location as LocationCurve;
Curve curve = lc.Curve;
using(Transaction trans = new Transaction(doc,"edit"))
{
    trans.Start();
    try
    {
        // Thickness type attribute , It is suggested to create a new wall type 
        WallType newType = wall.WallType.Duplicate("NewWallType") as WallType;
        CompoundStructure cs = newType.GetCompoundStrycture();
        // Get all layers 
        IList<CompoundStructureLayer> lstLayers = cs.GetLayers();
        foreach(CompoundStructureLayer item in lstLayers)
        {
            if(item.Function == MaterialFunctionAssignment.Structure)
            {// Only one structural layer is considered here , If there are more than one, calculate by yourself 
                item.Width = dThickness;
                break;
            }
        }
        // Set it again after modification 
        cs.SetLayers(lstLayers);
        newType.SetCompoundStructure(cs);
        Wall.Create(doc,curve,newType.Id,wall.LevelId,dHeight,dOffset,false,false);
        doc.Delete(wall.Id);
        trans.Commit();
    }
    catch
    {
        trans.RollBack();
    }
}
原网站

版权声明
本文为[Hey, hey, hey, hey, hey]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130606207231.html