How to get the number of editable documents

How to get the number of editable documents

kandennti
Mentor Mentor
1,251 Views
7 Replies
Message 1 of 8

How to get the number of editable documents

kandennti
Mentor
Mentor

Hello everyone.


There is an add-in I created that creates a new document (f3d) and saves it.

https://github.com/kantoku-code/Fusion360_Rescue_F3D 

 

Currently there is a limit of 10 editable documents for personal license users, and I have received reports of errors when using the add-in with 10 documents.

 

1.png

We want to warn the user before executing the process. Is there any way to know what the current capacity is?

0 Likes
Accepted solutions (2)
1,252 Views
7 Replies
Replies (7)
Message 2 of 8

goyals
Autodesk
Autodesk

@kandennti May I know at what point it is failing. I mean add-in command fail when a new document is created after reaching the limit of editable documents or during the save. 



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 3 of 8

kandennti
Mentor
Mentor

Thank you @goyals .

 

When I run the add-in when the capacity is 10/10, I get an error saving the document.

https://github.com/kantoku-code/Fusion360_Rescue_F3D/blob/main/Rescue_F3D/Rescue_F3D_core.py#L69 


This is the correct thing to do for a personal license.
Avoiding the error is easy to do using try~except.


Giving a warning after making the user wait for processing time does not seem like a user-friendly add-in.
What I would like to do is to give the user a warning immediately after executing the command.

0 Likes
Message 4 of 8

goyals
Autodesk
Autodesk
Accepted solution

Thanks @kandennti  for providing more information. We will definitely explore option to add API to get edited document limit in Fusion. 



Shyam Goyal
Sr. Software Dev. Manager
Message 5 of 8

kandennti
Mentor
Mentor

I found a text command to get the editable documents count.

 

# Fusion360API Python script
import adsk.core, adsk.fusion, traceback

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

        docCount = getEditableDocsCount()
        msg = ''
        if docCount < 0:
            msg = 'There is no limit to the number of documents that can be edited.'
        else:
            msg = f'Editable documents count is {docCount}.'

        ui.messageBox(msg)

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


# return:
#  personal licenses -> Editable Documents Count
#  non-personal licenses -> -1
def getEditableDocsCount() -> int:
    app :adsk.fusion.Application = adsk.core.Application.get()

    res = app.executeTextCommand(u'ActiveDocuments.Summary')
    txts = res.split('\n')
    if len(txts) < 2:
        return -1

    for txt in txts:
        if not 'Active and deactivating documents' in txt:
            continue

        return int(txt.split(':')[-1])
    return -1

1.png

 

However, I hope that it will continue to be provided as an API.

0 Likes
Message 6 of 8

kandennti
Mentor
Mentor

We have confirmed that the PersonalUseLimits object has been added to Ver.2.0.10244. Thank you.

 

I tested it with a Commercial license and unlike the documentation,

it did not return Null (or None in python).

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-E1B04ACA-1965-4F99-9DFD-46D20EC3DBA3 

 

It could be solved by determining the type of license in use, but this is the only way I know of at the moment, and it is not very desirable.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/get-if-a-user-is-using-a-paid-version-of-f... 

0 Likes
Message 7 of 8

goyals
Autodesk
Autodesk
Accepted solution

This is oversight. We will fix it. Thanks for reporting it. 



Shyam Goyal
Sr. Software Dev. Manager
Message 8 of 8

kandennti
Mentor
Mentor

@goyals .

 

Ver 2.0.10356 has been confirmed to work correctly.
Thank you.

0 Likes