Author Topic: BricsCAD - Changing parametric blocks selected option descreases performance  (Read 225 times)

0 Members and 1 Guest are viewing this topic.

Kralj_klokan

  • Newt
  • Posts: 23
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#: [Select]
  1.         private void SetDropDownValue(string dropDownValue, ObjectId brefId, string blockName, bool isMultiSelect)
  2.         {
  3.             using (var tr = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
  4.             {
  5.                 try
  6.                 {
  7.                     log.Info($"{System.Reflection.MethodBase.GetCurrentMethod().Name} started.");
  8.                     var originalDropDownValue = dropDownValue;
  9.                     log.Info($"Block [{blockName}] blockreference is being checked and changed for dropdown value");
  10.  
  11.                     var bref = tr.GetObject(brefId, OpenMode.ForWrite) as BlockReference;
  12.                     if (!bref.IsDynamicBlock)
  13.                     {
  14.                         var parameter = Utility.GetBlockParameter(bref.Id, "Visibility");
  15.  
  16.                         if (parameter.StringValue != null)
  17.                         {
  18.                             log.Info($"Blockreference from [{blockName}] is dynamic and will be changed.");
  19.  
  20.                             List<string> dropDownValuesList = new List<string>();
  21.                             dropDownValuesList = dropDownValue.Split(';').ToList();
  22.                             if (dropDownValuesList.Count == 1)
  23.                             {
  24.                                 log.Info($"Dropdownvalue after handler is [{dropDownValue}].");
  25.                                 if (!string.IsNullOrEmpty(dropDownValue))
  26.                                 {
  27.                                     try
  28.                                     {
  29.                                         log.Info($"Block reference dropdown value [{parameter.StringValue}] is being changed to [{dropDownValue}]");
  30.  
  31.                                         if (parameter.StringValue != dropDownValue)
  32.                                             parameter.Expression = dropDownValue;
  33.                                     }
  34.                                     catch
  35.                                     {
  36.                                         parameter.Expression = "Select";
  37.                                     }
  38.                                 }
  39.                                 else
  40.                                 {
  41.                                     parameter.Expression = "Select";
  42.                                 }
  43.                             }
  44.                         }
  45.  
  46.                         bref.RecordGraphicsModified(true);
  47.                     }
  48.  
  49.                     bref.Dispose();
  50.                     tr.Commit();
  51.  
  52.                 }
  53.                 catch
  54.                 {
  55.                     tr.Abort();
  56.                 }
  57.                 finally
  58.                 {
  59.  
  60.                     log.Info($"{System.Reflection.MethodBase.GetCurrentMethod().Name} ended.");
  61.                 }
  62.             }
  63.         }
  64.  
  65.  

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 ]
« Last Edit: February 18, 2024, 02:34:43 PM by kdub_nz »

cmwade77

  • Swamp Rat
  • Posts: 1443
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.