[CE U14 C#] Parametric Cell - Parameters not up to date

I have a DGN, where I placed a parametric Cell with Variables attached to it (used with constraints). When I only read and write with my function, everything works as expected. When I edit the value of one Parameter inside the Microstation (Element Info), my Function gets old Data, when reading it. Restarting the Microstation doesn't help and I still get the old data.

My Function:

         if (!(elementIn is ParametricCellElement cell)) return;
         ParameterDefinitions defs = cell.CellDefinition.GetParameterDefinitions();
         IList<ParameterDefinition> lstDefinitions = defs.GetParameterDefinitions();

         foreach (ParameterDefinition def in lstDefinitions)
         {
            //IDgnECInstance ins = defs.Properties as IDgnECInstance;
            IECInstance ins = cell.CellDefinition.Parameters;
            IECPropertyValue pv = ins.FindPropertyValue(def.AccessString, false, false, false, true);
            //def.DisplayLabel, pv.DoubleValue
         }

I tried both IDgnECInstance ins = defs.Properties as IDgnECInstance; and IECInstance ins = cell.CellDefinition.Parameters; but it made no difference. The other comment is just an example on how I access the values (the actual access is more complex).

The Question now is, how I can get the actual data. Do I access the parameters wrong? Is there a synchronize command? Is the SDK broken?
I ripped the Functions from the SDK examples: MicroStation\mdl\examples\Constraints\ParametricModelingExample
This example is for the Model, but re writing it a bit and it works for Elements too.

Parents
  • Hi J-P,

    a quick idea (I am outside office ;-)  In your code you are retrieving parameters from cell definition (from ParametricCellDefinitionElement), not from the cell instance. Even when internally very different, Parametric cells work are stored as shared cells: One definition for all instances, so I guess you receive "default data", defined by the variables.

    I am not sure how to obtain the parameters, but it cannot be done using the cell definition element. I guess it's about to find ECInstances on the parametric cell instance element. From the cell definition, you know ECClasses, so you can find their instances on placed cell.

    With regards,

      Jan

    Answer Verified By: Jean-Pierre Hundhausen 

  • The ParameterDefinition is not for the value, actually, there is no value behind this Class. I get IECInstance in the foreach loop. I'm a bit more worried about FindPropertyValue. The true parameter is for includeAdhoc. In other occasions I use GetPropertyValue but this doesn't work for Parameters.

    As it looks: IDgnECInstance ins = defs.Properties as IDgnECInstance; is better than IECInstance ins = cell.CellDefinition.Parameters; I had this in this way, before starting to investigate. Also it looks like it changed a bit with U14. I wrote this function in U13 and didn't bothered to check it in U14, before letting my coworker implementing this function.
    Whats weird is when I say to Element A its value is 10 and B is 20, when I check A, it says its 20 (MS says its 10). I say it via my write function, and not via the Microstation. The write process is similar to reading. Writing is not the problem, because the MS gets the values right.

    What I don't know is what includeAdhoc does mean in that context. Without it, it won't work.

    Mit freundlichen Grüßen / Best regards
    Jean-Pierre Hundhausen

    |  AB_DATE Engineering  Software   |  ab-date.de  |

Reply
  • The ParameterDefinition is not for the value, actually, there is no value behind this Class. I get IECInstance in the foreach loop. I'm a bit more worried about FindPropertyValue. The true parameter is for includeAdhoc. In other occasions I use GetPropertyValue but this doesn't work for Parameters.

    As it looks: IDgnECInstance ins = defs.Properties as IDgnECInstance; is better than IECInstance ins = cell.CellDefinition.Parameters; I had this in this way, before starting to investigate. Also it looks like it changed a bit with U14. I wrote this function in U13 and didn't bothered to check it in U14, before letting my coworker implementing this function.
    Whats weird is when I say to Element A its value is 10 and B is 20, when I check A, it says its 20 (MS says its 10). I say it via my write function, and not via the Microstation. The write process is similar to reading. Writing is not the problem, because the MS gets the values right.

    What I don't know is what includeAdhoc does mean in that context. Without it, it won't work.

    Mit freundlichen Grüßen / Best regards
    Jean-Pierre Hundhausen

    |  AB_DATE Engineering  Software   |  ab-date.de  |

Children