[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  |

  • As it looks: IDgnECInstance ins = defs.Properties as IDgnECInstance; is better than IECInstance ins = cell.CellDefinition.Parameters;

    As I wrote earlier, I think the problem is that you work with the cell definition parameters, not with cell instance parameters.

    What I don't know is what includeAdhoc does mean in that context.

    AdHoc properties are described in EC documentation. I am not quite sure why they should be important in the discussed case, because they are used to hold data specific for specific instance, but not for all ones.

    With regards,

      Jan

  • As I wrote earlier, I think the problem is that you work with the cell definition parameters, not with cell instance parameters.

    The Question is how I get it in that case? Sure I probably can directly access the ECObject Class but is this the right way?
    I will look into this again if I attacked this problem from the wrong direction and starting at the Element is the wrong direction. It will only take some time, because other Projects have a higher priority and I'm going back to the office and need to update everything.

    What I don't know is what includeAdhoc does mean in that context.

    AdHoc properties are described in EC documentation. I am not quite sure why they should be important in the discussed case, because they are used to hold data specific for specific instance, but not for all ones.

    I don't know, that's why I asked.
    I just searched in the wrong Documentation. Also most of the code was just Copy&Paste from the Example. I tested it not good enough and thought it works and didn't asked many questions.

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

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  • Sure I probably can directly access the ECObject Class but is this the right way?

    ECObject class represents definition, whereas to change any value, you have to access instance (represented e.g. by IDgnECInstance interface).

    I will look into this again if I attacked this problem from the wrong direction

    I do not think it's wrong direction, it's about to think deeper into used EC data structures ... which can look not very simple for the first sight.

    The Question is how I get it in that case?

    I will try to find some code for you ;-)

    I am not quite sure why they should be important in the discussed case

    I have to correct myself. After quick check how parametric cell instance (its definition is not important now) is stored in a model, I found variables values are stored as Adhoc properties, using ParameterValuesContainer. My fault, I should check relevant EC schema at first :-(

    Regards,

      Jan

Reply Children
No Data