Also I just noticed that the def __ and everything after it seems to have been moved over another chunk. (That was done automatically using the 2 > 3 button. )
You may have had too many spaces in the original version that caused issues in the transfer. What version of Dynamo are you transferring from/to? Can you confirm there’s an issue with spaces and tabs with a simple example?
But you definitely have extra spaces in the original code. You can see that the indent under the definition is larger than the one under the class. This would have to be fixed.
It’s not “forcing” you to spaces. It merely replaces tabs with spaces. Tabs and tabbing still work functionally the same. This isn’t the problem. The problem is that your original code in IP2 has too many spaces, so when it gets converted it results in extra tabs.
What do you mean by “different indents”? If you copy one piece of code that uses tabs and one that uses spaces you should be fine from what I’ve seen. The new editor specifically fixes this error by replacing tabs with spaces like I mentioned. If you mean that you copy one section of code that uses 4 space tabs and one section that uses 5 space tabs then, yeah, you’re gonna have a problem. That’s where you’d have to clean up the code. The easiest way I’ve found is to just dedent and re-indent to force the same spacing. I don’t think there’s any way around it but I’d be curious to see.
You either use spaces and deal with having to input every single space or you use tabs. In the latest version of the editor tabs get converted automatically, so you would just use the tab functionality while still maintaining your code in spaces.
Actually it looks like the old editor does that too. So I don’t know what to tell you. As long as you use the right number of spaces/tabs in an indent everything seems to work fine.
First up: In your Python preferences I recommend enabling the ‘Show Whitespace’ feature in Python. Now instead of guessing you should be able to know which are tabs and which are spaces.
Second up: you can remove and add tabs (or spaces depending on the editor) by highlighting blocks of text and using Tab to ‘indent’ or shift + tab to ‘Dede t’ the highlighted blocks.
And yes, tabs will still be tabs in some editors, but you can swap 40 spaces for 10 tabs by ‘dedenting’ and then ‘indenting’. It is painful, but this will shift entire blocks of text quickly.
Next up: I don’t recommend using the 2>3 converter unless you have a LOT of unsupported code. If you do, I recommend updating it outside of the Dynamo engine (ie: in visual studio). You can also copy text after upgrading in bulk (converting to spaces) if really needed. I recommend you copy the entire graph you want to copy from to a custom node if you do go that route (you can be in multiple custom nodes at once, but only one active workspace) and upgrade the Python in the custom node before copy-pasting anything. The bulk updater I have shared elsewhere can be modified to generate custom node versions of your entire library if it was desired.
Lastly, I recommend moving to CPython 3 and Revit 2022+, and no longer developing any code for Revit 2021 at this point. The new product line typically comes out around April, and that is only six months away. The organization and all projects should already be working on upgrading to ensure that everyone remains secure; and as developing for 2020 entails adding a LOT more work for something which shouldn’t be in high use, you are not getting any real ROI. Spend the cycles/effort upgrading projects instead.