700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Revit二次开发知识分享(二十一)修改墙的厚度(楼板同理)

Revit二次开发知识分享(二十一)修改墙的厚度(楼板同理)

时间:2023-12-14 19:54:45

相关推荐

Revit二次开发知识分享(二十一)修改墙的厚度(楼板同理)

最近总会遇到对墙构件的厚度进行修改,就去了解了一下墙修改的类,下面和大家分享一下~~~

主要想通过代码去修改墙类型属性中结构相关内容

对应的类是CompoundStructure 类

每一行数据都对应的一个CompoundStructureLayer ,CompoundStructure 类中提供了获取和修改的方法,GetLayer方法可以获取,SetLayer方法可以设置修改。CompoundStructureLayer 里面包含功能、材质、厚度这些参数都可以手动修改

下面是实操的代码块。

[Transaction(TransactionMode.Manual)]public class ChangeWallThicknessDemo : IExternalCommand{public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements){UIDocument uidoc = commandData.Application.ActiveUIDocument;Document doc = uidoc.Document;Reference selRef = null;try{selRef = uidoc.Selection.PickObject(ObjectType.Element,new SelectedWall(),"请选择需要改变厚度的墙");}catch {return Result.Failed;}//改变后墙的厚度double nwWallThickness = 500;Wall selWall = doc.GetElement(selRef) as Wall;WallType selWallType = selWall.WallType;//墙结构的编辑部件界面CompoundStructure wallTypeStructure = selWallType.GetCompoundStructure();//拿到墙的整体厚度double wallThickness = wallTypeStructure.GetWidth();//拿到核心边界里面的第一个图层再所有图层里面的开始编号和结束编号。如果两个不一样的时候,需要考虑改变的是哪一个图层的厚度int startIndex = wallTypeStructure.GetFirstCoreLayerIndex();int eneIndex = wallTypeStructure.GetLastCoreLayerIndex();Transaction trans = new Transaction(doc, "修改墙厚度");trans.Start();//修改厚度wallTypeStructure.SetLayerWidth(startIndex, nwWallThickness / 304.8);//墙类型重新赋值selWallType.SetCompoundStructure(wallTypeStructure);mit();return Result.Succeeded;}}public class SelectedWall : ISelectionFilter{public bool AllowElement(Element elem){if (elem is Wall) return true;return false;}public bool AllowReference(Reference reference, XYZ position){return true;}}

这个类里面可以挖掘的方法还有很多,这里不一一叙述,后面可以继续挖掘。这次分享的内容不多,希望可以给你指个方向。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。