Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Python console bug?

Le_Bear
Collaborator

Python console bug?

Le_Bear
Collaborator
Collaborator

If I type a block of conditions in the the console, like:

if a < 0:
   print('a is smaller than zero')
else:
   print('a is greater than , or equal to zero')

I get

  File "<string>", line 3
    else:
        ^
IndentationError: unindent does not match any outer indentation level


Typing the very same thing in a standard console (with Fusion 360 python.exe) give the expected result, without any error.
Not sure if it's true, but this leads me to believe there is some kind of problem with the console integrated into Fusion 360.

Bernard Grosperrin

Autodesk Certified Instructor

FaceBook Group | Forum | YouTube

Group Network Leader
 
0 Likes
Reply
Accepted solutions (1)
921 Views
6 Replies
Replies (6)

marshaltu
Autodesk
Autodesk

Hello,

 

Which console did you get the error? I can give a quick try.

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes

Le_Bear
Collaborator
Collaborator

@marshaltuwrote:

Hello,

 

Which console did you get the error? I can give a quick try.

 

Thanks,

Marshal


Hi Marshal,

it's Fusion 360 built-in console (Window Text Commands, with Py radio button on)

Thanks,

Bernard

Bernard Grosperrin

Autodesk Certified Instructor

FaceBook Group | Forum | YouTube

Group Network Leader
 
0 Likes

JeromeBriot
Mentor
Mentor

Bonjour,

 

the execution fails if you simply copy/paste the code in the Python console of Spyder:

 

>>> if a < 0:
...   print('a is smaller than zero')   
else:
   print('a is greater than , or equal to zero')
......
  File "<string>", line 3
    else:
        ^
SyntaxError: unexpected EOF while parsing

The symbol "..." is  a secondary prompt. Every new line in a block of code must start with this prompt.

 

 

Here is the good syntax (entered manually):

 

>>> if a < 0:
...    print('a is smaller than zero')
...else:
...    print('a is greater than , or equal to zero')
...
a is greater than , or equal to zero
>>> 

 

Fusion 360 is distributed with an outdated version of Spyder (2.3.2 released in 2012). The Python console was removed from Spyder in version 3.2. It was replaced by an IPython console in which you can safely copy/past and execute the code.

 

From a separate Python installation (Anaconda with Spyder 3.2.5):

 

Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 6.1.0 -- An enhanced Interactive Python.

In [1]: a = 5

In [2]: if a < 0:
   ...:    print('a is smaller than zero')   
   ...: else:
   ...:    print('a is greater than , or equal to zero')
   ...:    
a is greater than , or equal to zero

In [3]: 

 

It's up to the Fusion 360 team to upgrade the Spyder IDE. But I read in a previous post that they built a custom Python environment. So it's probably easier said than done.

 

 

0 Likes

Le_Bear
Collaborator
Collaborator

Thank you Jerome. I did not cut and paste, but entered the code, line after line, NOT in Spyder console, but in Fusion 360 "console". As you said, actually it works as expected in Spyder console, or any other console, for that matter. Which is why I suspect a bug in Fusion 360 implementation.

 

2018-03-28 20_04_01-.png

Bernard Grosperrin

Autodesk Certified Instructor

FaceBook Group | Forum | YouTube

Group Network Leader
 
0 Likes

marshaltu
Autodesk
Autodesk
Accepted solution

Hello,

 

As you may be aware, the functionality in text command window didn't intend to provide a full python console in Fusion 360. If you know more about the history of Fusion/API, we had delivered a set of old APIs (e.g. list in neu_dev module) based text commands. That would be to let users be able to check/try the api quickly. The set of APIs still work today. But we don't recommend clients to use them.

 

Essentially we use Python to interpret/execute the codes in background. So it also supports to run new APIs. Unfortunately there would be some flaws when we implemented it so that it looks not to be as powerful as a real Python console. 

 

Thanks,

Marshal

 

PythonCommands.png



Marshal Tu
Fusion Developer
>
1 Like

Le_Bear
Collaborator
Collaborator

Thanks you Marshal,

No, I did not realize it was not a full implementation. But now I know, thanks to you! 🙂

Bernard

Bernard Grosperrin

Autodesk Certified Instructor

FaceBook Group | Forum | YouTube

Group Network Leader
 
0 Likes