Files
SzmediTools/Szmedi.AIScriptRunner/Samples/ModifyParameter.csx
2025-09-16 16:06:41 +08:00

22 lines
833 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var selectedIds = uidoc.Selection.GetElementIds();
using (Transaction tx = new Transaction(doc, "修改参数"))
{
tx.Start();
foreach (ElementId id in selectedIds)
{
Element elem = doc.GetElement(id);
Parameter param = elem.LookupParameter("参数名称"); // 替换实际参数名
// 或者使用内置参数elem.get_Parameter(BuiltInParameter.参数枚举)
if (param != null && !param.IsReadOnly)
{
// 根据参数类型设置值
if (param.StorageType == StorageType.String)
param.Set("新值");
else if (param.StorageType == StorageType.Double)
param.Set(123.45);
}
}
tx.Commit();
}
uidoc.RefreshActiveView(); // 刷新界面显示新值