zl程序教程

您现在的位置是:首页 >  其它

当前栏目

revit添加族参数

参数 添加 revit
2023-09-27 14:28:18 时间

 

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

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;
}
}