Revit API创建墙的保温层修改墙厚度
start
url:http://greatverve.cnblogs.com/p/revit-api-CompoundStructure.html
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Transaction ts = new Transaction(uiDoc.Document, "http://revit.5d6d.com");
ts.Start();
Wall wall = uiDoc.Document.GetElement(uiDoc.Selection.PickObject(ObjectType.Element, "wall")) as Wall;
//取得一种材质
Materials materials = doc.Settings.Materials;
ElementId materialId = materials.get_Item("隔热层/保温层 - 空心填充").Id;
//得到墙结果
CompoundStructure cs = wall.WallType.GetCompoundStructure();
//ElementId matId = Material.Create(doc, "MyMaterial");//创建材质
//创建保温层(厚度,功能,材质)
CompoundStructureLayer layer = new CompoundStructureLayer(100 / 304.8, MaterialFunctionAssignment.Insulation, materialId);
cs.SetLayer(cs.GetFirstCoreLayerIndex(), layer);
//修改墙体厚度
IList<CompoundStructureLayer> listLayer = cs.GetLayers();
int iIdx = 0;
foreach (CompoundStructureLayer cLayer in listLayer)
{
if (MaterialFunctionAssignment.Structure == cLayer.Function)
{
break;
}
iIdx += 1;
}
cs.SetLayerWidth(iIdx, 400 / 304.8);
//调用更新
wall.WallType.SetCompoundStructure(cs);
ts.Commit();
return Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Transaction ts = new Transaction(uiDoc.Document, "http://revit.5d6d.com");
ts.Start();
Wall wall = uiDoc.Document.GetElement(uiDoc.Selection.PickObject(ObjectType.Element, "wall")) as Wall;
//取得一种材质
Materials materials = doc.Settings.Materials;
ElementId materialId = materials.get_Item("隔热层/保温层 - 空心填充").Id;
//得到墙结果
CompoundStructure cs = wall.WallType.GetCompoundStructure();
//ElementId matId = Material.Create(doc, "MyMaterial");//创建材质
//创建保温层(厚度,功能,材质)
CompoundStructureLayer layer = new CompoundStructureLayer(100 / 304.8, MaterialFunctionAssignment.Insulation, materialId);
cs.SetLayer(cs.GetFirstCoreLayerIndex(), layer);
//修改墙体厚度
IList<CompoundStructureLayer> listLayer = cs.GetLayers();
int iIdx = 0;
foreach (CompoundStructureLayer cLayer in listLayer)
{
if (MaterialFunctionAssignment.Structure == cLayer.Function)
{
break;
}
iIdx += 1;
}
cs.SetLayerWidth(iIdx, 400 / 304.8);
//调用更新
wall.WallType.SetCompoundStructure(cs);
ts.Commit();
return Result.Succeeded;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。