Message 1 of 4
Shared ParameterBinding Insert performance

Not applicable
03-09-2021
10:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
It is necessary to check the performance of how to fetch the shared parameter from the outside.
using (var t = new Transaction(document, "Shared Parameter Create"))
{
t.Start();
var definitionOptions = new ExternalDefinitionCreationOptions(parameter.Name, parameter.ParameterType)
{
GUID = Guid.NewGuid(), // ★1
Visible = true
};
var definition = sharedGroup.Definitions.Create(definitionOptions);
var catSet = document.Application.Create.NewCategorySet();
catSet.Insert(element.Category);
if (parameter.IsInstance)
{
var instance = document.Application.Create.NewInstanceBinding(catSet);
// ★★2
if(document.ParameterBindings.Insert(definition, instance) == false)
{
document.ParameterBindings.ReInsert(definition, instance);
}
// ★★3
document.ParameterBindings.ReInsert(definition, instance);
element.get_Parameter(definition).Set(parameter.Value);
}
else
{
// Type ... ...
}
t.Commit();
}
★1. Use Guid.NewGuid() to create guids for shared parameters. Does the guid exist even if the guid overlaps?
★★2. If the name exists in the Insert, it returns false and reinserts it.
When handling in Insert, exception handling is required, but if ReInsert is used, there is no need to use it.
Does this make a big difference in performance? If not, isn't it a good idea to use only ReInsert? Like a comment ★★★3.
Thanks.