Here is as far as I’ve gotten:
Export Shared Parameters-WIP (1).dyn (35.7 KB)
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
sys.path.append(r'C:\Program Files\IronPython 2.7\Lib')
import io
filepath = IN[0]
parameter_lists = IN[1]
id = IN[2]
name = IN[3]
# Separate all fields using tab char
parameters_in = ['\t'.join(p)+'\n' for p in parameter_lists]
# Create new group separated by tab chars
new_group = '{g}\t{i}\t{n}\n'.format(g='GROUP', i=id, n=name)
parameters_out = []
with io.open(filepath, 'r', encoding='utf-16') as f:
lines = f.readlines()
for line in lines:
parameters_out.append(line)
# Insert new group after *GROUP key
if line[:6] == '*GROUP':
parameters_out.append(new_group)
parameters_out.extend(parameters_in)
# Overwrite existing file with new data
with io.open(filepath, 'w', encoding='utf-16') as f:
f.writelines(parameters_out)
f.write('')
Revit still doesn’t consider this a valid shared parameters file, so I’m not sure what’s exactly happening but I’ve discovered a few things.
-
The shared parameters txt file appears to be encoded in UTF-16, as evidenced by null characters between every character if written in binary.
-
You are missing a few fields in your inputs, as noted in my other comment.
-
A group has to be added after the *GROUP line as shared parameters must exist within a group.
This is the output of the graph using the default construction template: