[MStn CE U13] Access to elements in Parametric cell

Hi,

this my question is one from "best practices questions" (and also about feature design), not specifically targeted to C++ or NET API (I did tests using C#):

Question: Is it possible to access elements inside parametric cell instance?

Why: In some scenarios, it would be nice to have a parametric cell with attached custom data (XAttributes or EC data) inside and to access the data after the cell is placed.

Now (see this my post in MicroStation forum) it seems that to attach EC data to elements or to cell (model) is not supported and when the instance is created, the cell definition content is "black boxed" and not available.

What I tried: I think, after reading C++ API doc and implementing some tests in C#, I understand how parametric cells persistence is implemented:

  • When the parametric cell is placed, the instance is created in dictionary model (but ParametricCellDefinitionElement (ParametricCellDefHandler) returns default model as its container?), so it's not "visible".
  • Similarly to shared cells, the parametric cell instance is represented by ParametricCellElement (ParametricCellHandler).
  • It's possible, using classes like ParametricCellDefinitionElement, PrametricCellinfo etc., to obtain the cell details like variables, location, transformation....
  • Using ElementGraphicsProcess, it's also possible to receive the cell geometry.

But there is no way to obtain source definition (elements, constraints...) from instance or hidden cell definition, and to check whether custom data has been attached to the cell. Even EC representation does not provide any details.

Is it "by design", so it's not possible to go inside the cell and custom data can be attached only after the cell is placed (so they will be attached to the instance element)?

With regards,

  Jan

Parents
  • Hi Jan,
    Did you find an answer to this question? I am working on something similar, I have created parametric cells (within Generative Components) and managed to update the individual variables using the following code:

    IECClass ecClass = pCell.Parameters.ClassDefinition;
    IDgnECInstance eci = DgnECManager.FindECInstanceOnElement(pCell, ecClass);
    
    for (int i = 0; i < CellVariableNames.Length; ++i)
    {
        IEnumerator<IECPropertyValue> props = eci.GetEnumerator(true, true);
        while (props.MoveNext())
        {
            if (props.Current.Property.DisplayLabel == CellVariableNames[i].ToString())
            {
                props.Current.StringValue = CellVariableValues[i].ToString();
            }
        }
    }
    eci.WriteChanges();

    You can always just return the current values by modifying the code to not write the value. Also I am pushing all values through as a string currently but you can modify this to be the native value if you wish (I will be doing this in the next iteration, it was just easier for concept to use a single type). I'm not sure if this is the best approach, it is just something I hacked together since documentation is scarce!

    I am now interested in obtaining the geometry from the cell instance (not cell definition) as well, since I will be using this in processes downstream. I'll let you know if I find a solution to that problem

    Thanks,


    Ed

  • Hi Edward,

    You can always just return the current values by modifying the code to not write the value.

    I am not interested in variables (did I wrote anything about variables in my question?) ... it's simple task in my opinion.

    I am now interested in obtaining the geometry from the cell instance (not cell definition) as well
    I'll let you know if I find a solution to that problem

    Sorry, but it seems you have not read my text carefully enough: I explicitly wrote that it's possible to obtain the cell geometry (I guess the cell definition and the cell instance should behave the same) using ElementGraphicsProcessor. This task is, again, simple, standard and can be used nearly anywhere.

    My interest is in element, not in geometry, which is something different.

    With regards,

      Jan

  • Right I see what you were saying now after re-reading; I guess I didn't read it too thoroughly... I was in a hurry to head to an appointment. Good luck with it, I'd be interested to know the outcome if you find a solution!

    Sorry for hijacking your thread, if you happen to have an example or some documentation on how to obtain the elements within a ParametricCell using the ElementGraphicsProcessor it would be great if you could provide assistance in this post: https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/193004/microstation-ce-u13-elementgraphicsprocessor-example-in-c

    Thanks,

    Ed

Reply Children
No Data