码迷,mamicode.com
首页 > 其他好文 > 详细

revit添加族参数

时间:2020-04-07 15:29:50      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:external   des   mil   new   app   ext   ram   group   catch   

 

打开一个族文件,并为族文件添加参数

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
UIApplication uiApp = commandData.Application;
Autodesk.Revit.ApplicationServices.Application app = uiApp.Application;
Document newDoc = app.OpenDocumentFile(@"F:\test.rfa");
if (newDoc != null)
{
using (Transaction trans = new Transaction(newDoc))
{
trans.Start("Add Parameter");
FamilyManager flyMgr = newDoc.FamilyManager;
string paraName = "NewParam4";
BuiltInParameterGroup paraGroup = BuiltInParameterGroup.PG_TEXT;
ParameterType paraType = ParameterType.Text;

flyMgr.AddParameter(paraName, paraGroup, paraType, false);
trans.Commit();
}
}
SaveOptions saveOpt = new SaveOptions();
saveOpt.Compact = true;

//newDoc.Save(saveOpt);
newDoc.Close();
return Result.Succeeded;
}
catch (Exception exception)
{
message = exception.Message;
return Result.Failed;
}
}

revit添加族参数

标签:external   des   mil   new   app   ext   ram   group   catch   

原文地址:https://www.cnblogs.com/liaocheng/p/12653604.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!