编程添加墙的一层材料或楼板的一层材料
在Revit2012中提供了墙类型、楼板类型等类型中的层编辑和新建的功能。可以修改WallType,FloorType。。等中的层。下面是代码为选择的墙的类型创建了一个保温层,并添加到墙类型中。
view plaincopy
[Autodesk.Revit.Attributes.Transaction(
Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class CreateWallLayer : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string messages,
ElementSet elements)
{
//
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Transaction trans = new Transaction(doc);
trans.Start("createNewLayer");
//select one wall
Reference ref1 = uiDoc.Selection.PickObject(
ObjectType.Element, "Pick a wall");
ElementId id = ref1.ElementId;
Element elem = doc.get_Element(id);
Wall wall = elem as Wall;
if (wall == null)
return Result.Failed;
CompoundStructure cs = wall.WallType.GetCompoundStructure();
ElementId matId = Material.Create(doc, "MyMaterial");
CompoundStructureLayer layer = new CompoundStructureLayer(
0.4, MaterialFunctionAssignment.Insulation, matId);
cs.SetLayer(cs.GetFirstCoreLayerIndex(), layer);
wall.WallType.SetCompoundStructure(cs);
trans.Commit();
return Result.Succeeded;
}
}
作者:叶雄进文章来源:http://blog.csdn.net/joexiongjin/article/category/782739
顶起来…………
页:
[1]