What is the formatProvider input for this node? Could you give me an example for it?
Hey,
A lot of Revit API calls allow ‘ToString’, this node is an alternative to ‘String from Object’ but allows extra control of the output.
Unfortunately it appears not to have any documentation, it is also not clear which nodes might output an ‘iformatProvider’. IformatProviders cannot be constructed in Cpython3 either.
I think this has probably not been resolved because everyone just uses String from Object.
For myself, it would be most useful to control ‘format’ with something like DateTime, but it’s rare to get that from an Element, which is why I’ve not used it?
Feel free to chase on github…
Hope that is useful,
Mark
Not an expert on this particular implementation (as we don’t need to use it), but I’ll peel back some of the onion layers for everyone.
First up we can identify the object type IFormatProvider. This is a .net class used to control how stuff is displayed when localized. The MS article on the class is likely the best example to learn from: https://learn.microsoft.com/en-us/dotnet/api/system.iformatprovider?view=net-8.0
Now onto Dynamo’s use of the method. My belief is that Dynamo for Revit uses this internally in it’s ToString method to convert things in a meaningful way for use in display - specifically you can see how it’s managing the application of the method override for XYZ points here: DynamoRevit/src/Libraries/RevitNodes/Elements/ReferencePoint.cs at 8f79cc7d20db8488a9be4118080933c7bd860eb6 · DynamoDS/DynamoRevit · GitHub.
Which finally brings us to ‘why is it exposed to users?’. The answer of which is "I have no idea, but since it doesn’t break anything and is really just there to control how ‘ToString’ works for various elements which are unique to Revit. It maybe that it should be ‘hidden’ in the Dynamo library, but as this is >6 years old, doing so now might break someone’s workflow (as these nodes can be called in conjunction with custom nodes that provide the IFormatProvider as one example). However as I haven’t seen or heard of anyone using this, I’ll log an issue on the Dynamo for Revit GitHub incase this is causing confusion.
Edit The GitHub issue for reference is here: ELement.ToString node has non-functional inputs · Issue #3107 · DynamoDS/DynamoRevit · GitHub
Why do we need inputs for null?
You don’t - just use String.FromObject, which wraps adds the functions of this node with the format and format provider. They cannot be accurately provided in the UI as currently designed.