Cannot access ID for Projects and console issues in Spyder

Anonymous

Cannot access ID for Projects and console issues in Spyder

Anonymous
Not applicable

Hi. 

 

I am using the code below to extract the list of projects for a hub. I can then iterate through those projects and print out the names of them and everything works fine. However, when I try to access or print the id for a project, it errors out on me.

 

    dataHubs = app.data.dataHubs
        for hub in dataHubs:

            if hub.name == props['hub']:
                dataProjects = hub.dataProjects
                for i in range(len(dataProjects)):
                    thisProject = dataProjects.item(i)
                    print(thisProject.name)    # works

                    print(thisProject.id)     # does not work

 

 

I would like to be able to give you the error that comes up, but there doesn't seem to be one. Whatever print command I give within the Spyder IDE does not "work" until I press "Enter" with the cursor in the console of Spyder. (Took about a day to figure that out). When I do that without the print statement for the ID, everything is then printed out just fine. If I add in the print for the ID, I get a string of errors that seems unrelated to the issue.

 

Here are those errors. The first one results any time you hit enter in the console window of Spyder. The rest seem as if a cascading of some kind prevented a garbage cleaner from working.

 

This happens whether I try to print the ID or just use it somehow. I just want to know why I can't access the ID and if U could get Spyder to work a little better, that would be great.

 

 

 

File "<string>", line 0

^
SyntaxError: unexpected EOF while parsing

During handling of the above exception, another exception occurred:

SystemError: <built-in function delete_WebRequestEventArgs> returned a result with an error set

During handling of the above exception, another exception occurred:

SystemError: <built-in function delete_DataHubs> returned a result with an error set

During handling of the above exception, another exception occurred:

SystemError: <built-in function delete_DataHub> returned a result with an error set

During handling of the above exception, another exception occurred:

SystemError: <built-in function delete_DataProjects> returned a result with an error set

During handling of the above exception, another exception occurred:

SystemError: <built-in function delete_DataProject> returned a result with an error set

0 Likes
Reply
Accepted solutions (2)
878 Views
11 Replies
Replies (11)

JesusFreke
Advocate
Advocate

I'm not sure, but I think that error is probably something related to the console trying to interpret your empty command after hitting enter.

 

I'm not familiar with Spyder, so I can't help you much there. But you can also do logging by popping up a dialog (which is a bit annoying, and hard to copy text from), or by directly writing to a file.

 

You might also take a look at my fusion 360 plugin for IntelliJ IDEA/PyCharm, which I highly prefer to spyder.

0 Likes

Anonymous
Not applicable

Part of that error message is indeed a result of hitting enter. 

 

However, whenever I print the name parameter of the dataProject, everything works fine. When I attempt to print the id, it does not work and that makes no sense.

1 Like

JesusFreke
Advocate
Advocate

One of 2 things are likely occurring. Either it's erroring out, and you're not seeing/getting the error for some reason, or the ID is blank, so when you try to print it, nothing is actually printed.

 

To differentiate between the two, you can alter the print statement. e.g. something like print("project.id = '%s'"). And maybe throw in a print after that as well, to verify whether execution continues or if it's somehow silently crashing.

0 Likes

BrianEkins
Mentor
Mentor
Accepted solution

I just tested this and the error being returned is "API Function not yet implemented".  There was a mistake in the implementation for this because if the internal work hasn't been done to implement it, it shouldn't have been exposed publicly.  In short, the property doesn't work yet.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

Anonymous
Not applicable

That is very troubling for a couple of reasons.

 

First, how are you expected to correctly identify and access files without the use of a unique and unchanging ID?

 

Second, I just spent about three weeks trying to figure out why this was so confusing to me and why I couldn't get anything to work and most of that comes back to the fact that I was always trying to access the id.

0 Likes

JesusFreke
Advocate
Advocate

Out of curiousity, how are you catching/handling exceptions in your code? You really want to be able to see the error messages from these sorts of exceptions when they occur.

0 Likes

Anonymous
Not applicable

The code above was wrapped in a standard try / except. There was a ui box that should have come up whenever there was an error, but it never worked. I just switched that to a print statement for the exception and got the correct error - 

 

5 : API Function not yet implemented

 

0 Likes

akonovalenko
Contributor
Contributor

Does anyone know when we can expect FIX for project ID property(DataProject.id)? 
it is one of the common attributes which is needed to work with Forge API it is not possible to manipulate with Fusion files thru the Forge without it 😞

PS: windows build 2.0.6045 throws "API not implemented exception" while accessing DataProject.id attribyte

0 Likes

JeromeBriot
Mentor
Mentor

Hello,

 

@goyals any news about this bug?

 

Here is a small script to reproduce the issue:

 

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback
import platform
import os

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        if platform.system() == 'Windows':
            desktopPath = os.path.join(os.getenv('USERPROFILE'), 'Desktop')
        else:
            desktopPath = os.path.join(os.path.expanduser('~'), 'Desktop')

        txtFile = os.path.join(desktopPath, 'testDataFusion360.txt')

        with open(txtFile, 'w') as f:

            for dataHub in app.data.dataHubs:
                f.write(dataHub.name)
                for dataProject in dataHub.dataProjects:
                    f.write('\n\t' + dataProject.id)

        ui.messageBox('End')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

The error message:

fusion-360-api-bug-dataproject-id.PNG

 

0 Likes

goyals
Autodesk
Autodesk
Accepted solution

Thanks for bringing it up. May be it is late to make any code change for next Fusion release but We will definitely target this for release after next Fusion release. UP-31902 is ticket id. Thanks.



Shyam Goyal
Sr. Software Dev. Manager
0 Likes

Rahul.Khande
Enthusiast
Enthusiast

Hello @goyals 

I'm facing similar issue. Trying to access: activedoc->dataFile()->parentProject();
returns null. Any suggestions?

Thank you.

0 Likes