revit添加族参数

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

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

猜你喜欢

转载自www.cnblogs.com/liaocheng/p/12653604.html