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
Good stuff Ed!
I've had similar issues using "simple" VBA with many property handler elements throwing "Unknown Error" messages when trying to set some values.
Does it do the same for properties added using Item Types?
Regards,
Mark
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
Thanks mate,
Essentially this script is replicating what I already had written in vba (which works well) but within GC environment; so I assume it is simply a lack of knowledge on GC node types preventing it from working!
Item types require a different method to read / write to elements, but I do plan on implementing that as well, since it would be useful to be able to easily apply item types with some customisable logic via GC for asset tagging etc.
Cheers,
Ed
Hi both.
Either of you made any progress with using gc to add metadata as properties or itemtypes.
Looking to try and do the same myself now
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
Hi Chris,You can download my GitHub repo here https://github.com/edashbolt/generative-components which allows you to write any custom item types you have created to elements (and also update any existing items attached to elements). Currently I have only supported writing to them, I still need to finish off the read method
Hi Ed.
This is perfect. Thank you for sharing.