Revit API修改保温层厚度
start
url:http://greatverve.cnblogs.com/p/revit-api-CompoundStructureLayer.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;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, this.ToString());
ts.Start();
//
Reference refWall = selection.PickObject(ObjectType.Element, "选择墙:");
Wall wall = doc.GetElement(refWall) as Wall;
WallType wallType = wall.WallType;
CompoundStructure cs = wallType.GetCompoundStructure();
bool bHas = false;//是否拥有保温层
int iWidth = 100;//要设置的保温层厚度
IList<CompoundStructureLayer> layers = cs.GetLayers();//找到所有层
foreach (CompoundStructureLayer layer in layers)
{
if (layer.Function == MaterialFunctionAssignment.Insulation)//判断保温层
{
bHas = true;
layer.Width = iWidth / 304.8;
}
}
if (!bHas)//没有保温层则创建
{
CompoundStructureLayer newLayer = new CompoundStructureLayer();
newLayer.Function = MaterialFunctionAssignment.Insulation;
newLayer.Width = iWidth / 304.8;
//layers.Add(newLayer);
layers.Insert(0, newLayer);
}
cs.SetLayers(layers);
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;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, this.ToString());
ts.Start();
//
Reference refWall = selection.PickObject(ObjectType.Element, "选择墙:");
Wall wall = doc.GetElement(refWall) as Wall;
WallType wallType = wall.WallType;
CompoundStructure cs = wallType.GetCompoundStructure();
bool bHas = false;//是否拥有保温层
int iWidth = 100;//要设置的保温层厚度
IList<CompoundStructureLayer> layers = cs.GetLayers();//找到所有层
foreach (CompoundStructureLayer layer in layers)
{
if (layer.Function == MaterialFunctionAssignment.Insulation)//判断保温层
{
bHas = true;
layer.Width = iWidth / 304.8;
}
}
if (!bHas)//没有保温层则创建
{
CompoundStructureLayer newLayer = new CompoundStructureLayer();
newLayer.Function = MaterialFunctionAssignment.Insulation;
newLayer.Width = iWidth / 304.8;
//layers.Add(newLayer);
layers.Insert(0, newLayer);
}
cs.SetLayers(layers);
wallType.SetCompoundStructure(cs);
//
ts.Commit();
return Result.Succeeded;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 大模型 Token 究竟是啥:图解大模型Token
· 35岁程序员的中年求职记:四次碰壁后的深度反思
· 继承的思维:从思维模式到架构设计的深度解析
· 如何在 .NET 中 使用 ANTLR4
· 后端思维之高并发处理方案
· BotSharp + MCP 三步实现智能体开发
· BotSharp 5.0 MCP:迈向更开放的AI Agent框架
· 5. RabbitMQ 消息队列中 Exchanges(交换机) 的详细说明
· 【ESP32】两种模拟 USB 鼠标的方法
· 设计模式脉络
2013-03-01 C++ 单例模式