Shared ParameterBinding Insert performance

Shared ParameterBinding Insert performance

Anonymous
Not applicable
371 Views
3 Replies
Message 1 of 4

Shared ParameterBinding Insert performance

Anonymous
Not applicable

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.

0 Likes
372 Views
3 Replies
Replies (3)
Message 3 of 4

Anonymous
Not applicable

No.It's different from what I think.

Anyway, The first question is secondary. The second question is the key.

 

The point is, is there a difference between the ParameterBinding.Insert() and ReInsert() methods?

ReInsert() is to create after Remove, and Insert() is to create only. Is there any other difference besides that?

 

Also, is there a difference in performance?

0 Likes
Message 4 of 4

jeremy_tammik
Alumni
Alumni

To determine the difference in performance, I would suggest that you try out both, benchmark them, and let us know what you discover. That will be very interesting for all. And you will know that you can trust the results. Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes