Convert List of Parameters to Strings

Hi,

I am trying to retrieve values of a project parameter (“Phase Demolished” for my case) from all the elements active in the view. I am able to retrieve these values, however, my goal is to convert them to strings in order to analyze them. There is a node that is capable of converting one parameter value to string (“parameter to value” node), however, I cannot seem to find any node or workflow for converting a list of parameter values to list of strings. I tried using the “object to string” node, however, it does not fully convert the parameter values to string. For instance, instead of producing “phase 2” as the value of a “phase demolished” parameter, it produces “phase”. Does anyone know any node/workflow to get around this? (i.e. converting a list of parameters/parameter values to a list of string?)

Thanks,

dynamo_problem_2

Element.Name may help here.

Hi Jacob,

I appreciate your help. Unfortunately, it does not. None of the predefined nodes seem to be able to convert a list of values to list of strings.

This isn’t a strings issue - it’s an object types issue. You have lots of string values of “none” which wont’ return a name as it isn’t a class (maybe my vocab is incorrect here) but a value. So really it’s a data management issue at heart (then again isn’t everything?).

3 Options:

  1. Change your python to return an empty list or some other object instead of a string. Element Id -1 might work Then use a List.Clean to remove the nulls. This may not work if you want to keep the data structure as you have it.

  2. Use the Element.Name (Universal) node in clockwork package with lacing set to longest to maintain the order. This works as long as you have clockwork installed on all systems which need the script (which really you should).

  3. Use a custom function in a code block to ensure that all elements passed in are reviewed and return your desired value. This works in just about all cases but requires a little bit of coding to call the built in function names. However this may result in an error which you may or may not be able to ignore. Editing the python to replace the “none” values for an empty list or other class of object may be a better bet in the end.

Capture

The Element.Phases node is also from the Clockwork package FYI.

1 Like

Jacob, thank you so much for the comprehensive instructions! That was very helpful! I just managed to find a solution that fits best to the problem. I used the “LunchBox Get Parameter Value” from the “LunchBox” package. It helps handling the object type issue: here’s a snapshot:

image

1 Like