UtilityNode - creating a custom node to modify existing Feature properties

Hi All,

I'm hoping someone might be able to help me on the remaining piece to the puzzle. What I have built so far is a custom node as a PropertyHandler to extend the abilities of GC. The first 'node technique' reads all the available access strings and values using the Bentley.Interop.MicroStationDGN.PropertyHandler:

Next thing I want to do is have a new 'technique' that can be used to update the input elements properties. This will be useful for things like updating parametric cell variables / variations values, which GC does not currently do. Here is what I have so far:

        static NodeUpdateResult WriteProperties(UtilityNode node, NodeUpdateContext updateContext)
        {
            PropertyHandlerUtility propertyHandler = (PropertyHandlerUtility)node;
            List<Feature> outputElements = new List<Feature>();

            for (int i = 0; i < propertyHandler.ElementsList.Count(); ++i)
            {
                try
                {
                    Element ele = propertyHandler.ElementsList[i].GetElement();

                    //What do I do now? Do I need to copy the element so that I can edit the properties without GC locking the element from editing?
                    //Or can I edit the original element programmatically?

                    Bentley.Interop.MicroStationDGN.PropertyHandler oPH = MSApp.CreatePropertyHandler(ele);
                    string[] access = propertyHandler.AccessStringsList;
                    object[] value = propertyHandler.ValuesList;

                    for (int j = 0; j < access.Length; ++j)
                    {
                        oPH.SelectByAccessString(access[j]);
                        try
                        {
                            oPH.SetValue(value[j]);
                            //This is where it fails... cannot set the value for the existing element. 
                            //Even when creating a duplicate element I cannot seem to change any of the properties programmatically...
                        }
                        catch
                        {
                            return new NodeUpdateResult.TechniqueInvalidArguments(NameOfValuesList + " Error with property values found; please review input lists");
                        }
                    }
                }
                catch
                {
                    return new NodeUpdateResult.TechniqueInvalidArguments(NameOfElementsList + " Error with input elements found; please review input lists");
                }
            }

            return NodeUpdateResult.Success;
        }

Unfortunately it fails when trying to update the existing element and I have no idea why since I am new to GC node developement... I imagine it will be easy with a little know how - any help would be much appreciated!

Thanks,

Ed

Parents Reply
  • Hi Ed.

    This is perfect. Thank you for sharing.

    Chris

    Regards

    Chris


    AECOM Roads UK&I Digital Engineering, Design & Solutions Lead | Sector Information Management Lead

    Associate Director – Digital

    OpenRoads Designer 10.12 | MicroStation 2023 | ProjectWise CE 10.3.4 | ContextCapture | ProjectWise PowerShell 2023 | ProjectWise WSG API | Generative Components | OpenBridge Designer 10.12

    Civil 3D 2023 | Dynamo | Navisworks Manage

    PowerShell | Visual Studio | Office 365 | Power Platform | Teams | SharePoint | Visio

    Speckle | BIMVision | Revizto | Solibri

Children
No Data