So I’ve been working on a tool that looks and selects data from an Excel database and then writes a txt. file with the necessary Keynotes Revit syntax.
The objective is that users can generate Keynotes text files by editing some Dynamo Player input nodes without having to know how Keynotes work. Then they can import them into Revit.
For the first time I am taking advantage of pandas and numpy python libraries to achieve what I want, but I am getting some unexpected results in Revit.
Left result:
- generated .txt file from Dynamo
Right result:
- generated excel file from Dynamo;
- opened file and selected the function “wrap text” on the specific column;
- saved as unicode format.
As you can see there is a line break after the word “gevel” and I cannot understand the cause of it.
Both of Keynote tags instances are the same family and type with the option “Wrap between parameters only” set to False. The string clearly didn’t reach the label’s boundary but there is still a forced line break.
(image of the output from both txt files)
As you see there is a syntax difference between both text files and unfortunately I wasn’t able to reproduce the right output syntax on my code.
Final lines of code to export the Excel file
# Seting up excel file
final_concat_excel = pd.concat(dataframe_list)
excel_file = r'V:\Revit\09-dynamo scripts\97-developing\07-Keynotes\result_1.xlsx'
excel_sheet_name = "Keynotes_automatically gen"
final_concat_excel.to_excel(excel_file, excel_sheet_name, header=False, index=False)
Final lines of code to export the Text file
# Setting up .txt file
final_concat_txt_file = pd.concat(dataframe_list)
final_concat_txt_file = final_concat_txt_file.replace('\n','\r', regex=True) # Replacing new lines with carriage returns
text = np.savetxt(text_path_output, final_concat_txt_file.values, fmt='%s' , delimiter='\t', encoding="utf-8") # Added encoding parameter since ≤ and ≥ in excel weren't recognized when saved to .txt file
OUT = (f'Success, you can now use your txt file!\
\n{text_path_output}') # Output the final message to the user
Maybe someone can point in the right direction? I am struggling with this for some time, maybe I am missing a very obvious or simple detail but I cannot figure out what it is.
Thank you in advance.