Hello everyone!
I’ve recently started studying Phyton scripts inside Dynamo and I’ve a problem that i haven’t been able to solve yet. When i finish a script that works fine i save it in a OneNote Notebook by copy/paste the script from the Python windows. When i try to copy/paste this text in a new python node it always give me this kind of error:
.
Even though the script is correct and it has no syntax errors, every time i have to write the script from scratch, it’s really annoying specially because i often have to switch from a dynamo version to another, so it’s impossible to copy/paste directly the python node. Anyway, i have the same error even when i copy the text from a dyn file of the same version.
What am i doing wrong?
Thank you very much!
One thing it could be is when copying code from text files or even online is the code can lose its formatting and tabs are converted to spaces. Make sure all indents are as tabs and not mixed tabs and spaces.
Do you have an example of your code that is failing?
Thanks Daniel for your answer.
It seems there is an error almost in every line, in the image below there is a very simple python script where i’ve just added a few references. Even if i keep just the first line, where i import the clr, the error is the same even if there are no indentation or extra-spaces…
@jacob.small I’ve registered a video where i copy/paste a working script from a .dyn file to a one note page and then copy/paste it from one note to a python script in a new .dyn file without success but i am not able to upload it because i am a new user. i am using the 2.0 version.
@Kulkul no, i haven’t pyRevit installed on my PC. Would it be of any use to solve my problem?
Try post it again, and if that fails due to permissions, file size, or other reason use another hosting service like Dropbox, OneDrive, Box, GoogleDrive, or similar.
@Paslet87 don’t use the notebook. Better to use a python editor (notepad++, spider, etc). Save tour files in gdrive or onedrive. Use the node Python from string. This way you can still copy and paste(in nodepad++) and you don’t loose the formatting. Plus nodepad++ has more functionality than the dynamo python editor.
@salvatoredragotta true, it seems that when I copy the text of the script in one note it loses its format. I saved it in a .py file and it worked fine, many thanks!