Code Red > .NET

BricsCAD - Changing parametric blocks selected option descreases performance

(1/1)

Kralj_klokan:
Hi,

I 'm encountering an interesting issue while working on a BricsCAD plugin.

I have a drawing with about 120 block definitions which of some are nested within other block definitions.
Most if not all of those blocks have a parameter visibility option called visibility.

Changing that option programatically results in a very slow drawing which changes layouts for about 15 seconds.

Here is my code:


--- Code - C#: ---        private void SetDropDownValue(string dropDownValue, ObjectId brefId, string blockName, bool isMultiSelect)        {            using (var tr = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())            {                try                {                    log.Info($"{System.Reflection.MethodBase.GetCurrentMethod().Name} started.");                    var originalDropDownValue = dropDownValue;                    log.Info($"Block [{blockName}] blockreference is being checked and changed for dropdown value");                     var bref = tr.GetObject(brefId, OpenMode.ForWrite) as BlockReference;                    if (!bref.IsDynamicBlock)                    {                        var parameter = Utility.GetBlockParameter(bref.Id, "Visibility");                         if (parameter.StringValue != null)                        {                            log.Info($"Blockreference from [{blockName}] is dynamic and will be changed.");                             List<string> dropDownValuesList = new List<string>();                            dropDownValuesList = dropDownValue.Split(';').ToList();                            if (dropDownValuesList.Count == 1)                            {                                log.Info($"Dropdownvalue after handler is [{dropDownValue}].");                                if (!string.IsNullOrEmpty(dropDownValue))                                {                                    try                                    {                                        log.Info($"Block reference dropdown value [{parameter.StringValue}] is being changed to [{dropDownValue}]");                                         if (parameter.StringValue != dropDownValue)                                             parameter.Expression = dropDownValue;                                    }                                    catch                                    {                                        parameter.Expression = "Select";                                    }                                }                                else                                {                                    parameter.Expression = "Select";                                }                            }                        }                         bref.RecordGraphicsModified(true);                    }                     bref.Dispose();                    tr.Commit();                 }                catch                {                    tr.Abort();                }                finally                {                     log.Info($"{System.Reflection.MethodBase.GetCurrentMethod().Name} ended.");                }            }        }  
Does anybody have ideas on why this would occur? The same issue does not happen for AutoCAD dynamic blocks.


edit,Kerry : code tag [ code = csharp ]

cmwade77:
I was running into similar issues with Dynamic Blocks in AutoCAD that used constraints, in my case it turned out that the issue was with some linetypes and setting LTSCALE to 1000 first solved the issues, then return LTSCALE to the previous value afterwards. I don't know if it will help you or not, but worth a shot. And if not, BricsCAD has excellent customer support, you could ask them.

Navigation

[0] Message Index

Go to full version