[CONNECT C++] How to Set Item Type Property to Read Only

I noticed that DgnECInstance has a function IsPropertyReadOnly(), but I don't see a corresponding SetPropertyReadOnly(). Is there a way to set a property within an Item Type grouping to read-only? I have tried SetReadOnly thinking this would be applied to all properties in the  DgnECInstance, but this doesn't seem to work.

The function doc indicates "...it may be ignored if implementation does not support...". Since it didn't work I'm going to assume my implementation doesn't support it. Any ideas how to implement a DgnECInstance that supports read-only? This would be a work-around as I would prefer to set permissions on individual props. Any thoughts welcome!

  • Hi Marc,

    You cannot set ItemType property readonly.

    Will you like to consider to define your own ECSchema. You can define ECProperty as read only in schema or programmatically in code.

    General steps would be:

    1. Create schema

    2. Import schema: DgnECManager::GetManager().ImportSchema

    3. Get enabler:

    DgnECInstanceEnablerP widgetEnabler = dgnECManager.ObtainInstanceEnablerByName (schemaName, ecClassName, *dgnFile);

    4. Get WIP instance:

    StandaloneECInstanceR widgetWipInstance = widgetEnabler->GetSharedWipInstance ();

    5. Fill in properties:

    widgetWipInstance.SetValue (L"Grade", ECValue (5)); At this stage you can set property readOnly.

    6. Create instance on element:

    widgetEnabler->CreateInstanceOnElement (&writtenInstance, widgetWipInstance, ElementHandle (eh.GetElementRef(), &dgnModel));

    If you have existing instance on element. You can retrieve it DgnECManager.FindInstance and update it.

    Btw, we have published managed example in U11. "MicroStationCONNECTSDK\examples\DgnEC\DgnECManagedCrudExample". I will try to get native example in next update.


    This is a test

    Answer Verified By: Mark Stefanchuk