我編譯了代碼,並且有'創建'方法的問題。我無法弄清楚...任何想法,將不勝感激?這是用於修復2016.沒有「創建」的重載方法?
public static void createSharedParam(Document doc, string name)
{
DefinitionFile defFile = doc.Application.OpenSharedParameterFile();
DefinitionGroup dg = null;
if (defFile == null) throw new Exception("No Shared Parameter File!");
if (doc.ProjectInformation.Parameters.Cast<Parameter>().FirstOrDefault(q => q.Definition.Name.Equals(name)) != null)
{
return;
}
else
{
string pgroup = "Parameter Group";
dg = defFile.Groups.FirstOrDefault(g => g.Name == pgroup);
if (dg == null)
{
dg = defFile.Groups.Create(pgroup);
}
}
Category myCategory = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Views);
CategorySet myCategories = doc.Application.Create.NewCategorySet();
myCategories.Insert(myCategory);
ElementBinding binding = doc.Application.Create.NewInstanceBinding(myCategories);
Definition def = dg.Definitions.Cast<Definition>().FirstOrDefault(q => q.Name == name);
if (def == null)
def = dg.Definitions.Create(name, ParameterType.Text);
bool result = doc.ParameterBindings.Insert(def, binding, BuiltInParameterGroup.PG_DATA);
}
}
謝謝你的職位。我根據你的帖子調整了我的代碼,然後編譯,但我現在收到以下錯誤消息? 'System.TypeLoadException' –