DynamoWishlist
DynamoWishlist copied to clipboard
Improvement: ability to "type hint" inputs to python node or code block
If this issue is with Dynamo for Revit, please post your issue on the Dynamo for Revit Issues page.
If this issue is not a bug report or improvement request, please check the Dynamo forum, and start a thread there to discuss your issue.
Dynamo version
1.1.0
Operating system
win 7
Request
When I am writing scripts in python or design script, I try to write them as generally as possible - so that they work on items, or lists, or lists of lists. I do this by writing them to operate on a single item and then making them a custom node, where I can specify a type hint of :var or :<Type> so that dynamo will handle iterating over the list if I pass it one. (Contrast this to many Clockwork nodes, which wrap each python script in a "Turn into list" / "Return List or single value" workflow which frequently fails and cannot be properly list.mapped over a sequence.)
This requires a somewhat tedious sequence in practice - where I'm trying to write my script this way but have a list to work with, so I have to:
- grab the first item on my list
- write the script to function properly on that item
- wrap the script in a custom node
- run it again over the entire list And then, if there's a bug or failure, custom node reporting of internal errors is spotty at best - to debug I usually have to go into the custom node, copy the script, paste it back in the document, find the item causing the error, test it on this item, and when solved update the custom node.
ALLL THIS is to say - if python scripts (or code block nodes, by extension) had an interface that exposed a type hint, much of this hassle could be avoided. It would also serve to elevate what I think is a critical best practice for reusability from a "sneaky trick" into a first-class feature.
Grasshopper scripting nodes all have this ability - and it is very useful.